• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python template.optional_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pybtex.style.template.optional_field函数的典型用法代码示例。如果您正苦于以下问题:Python optional_field函数的具体用法?Python optional_field怎么用?Python optional_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了optional_field函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: format_proceedings

 def format_proceedings(self, e):
     template = toplevel [
         first_of [
             # there are editors
             optional [
                 join(' ')[
                     self.format_editor(e),
                     sentence [
                         self.format_btitle(e, 'title', as_sentence=False),
                         self.format_volume_and_series(e, as_sentence=False),
                         self.format_address_organization_publisher_date(e),
                     ],
                 ],
             ],
             # there is no editor
             optional_field('organization'),
             sentence [
                 self.format_btitle(e, 'title', as_sentence=False),
                 self.format_volume_and_series(e, as_sentence=False),
                 self.format_address_organization_publisher_date(
                     e, include_organization=False),
             ],
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:26,代码来源:unsrt.py


示例2: format_address_organization_publisher_date

 def format_address_organization_publisher_date(
     self, e, include_organization=True):
     """Format address, organization, publisher, and date.
     Everything is optional, except the date.
     """
     # small difference from unsrt.bst here: unsrt.bst
     # starts a new sentence only if the address is missing;
     # for simplicity here we always start a new sentence
     if include_organization:
         organization = optional_field('organization')
     else:
         organization = None
     return first_of[
         # this will be rendered if there is an address
         optional [
             join(sep=' ') [
                 sentence[
                     field('address'),
                     date,
                 ],
                 sentence[
                     organization,
                     optional_field('publisher'),
                 ],
             ],
         ],
         # if there is no address then we have this
         sentence[
             organization,
             optional_field('publisher'),
             date,
         ],
     ]
开发者ID:OVii,项目名称:communityvisweb,代码行数:33,代码来源:unsrt.py


示例3: format_inbook

 def format_inbook(self, e):
     template = toplevel [
         tag('pubtitle') [tag('b') [field('title')]],
         Symbol('br'),
         sentence [self.format_names('author')],
         self.format_volume_and_series(e),
         Symbol('br'),
         words [
             sentence(capfirst=True) [
                 self.format_chapter_and_pages(e),
                 #optional[ self.format_editor(e, as_sentence=False) ],
                 self.format_btitle(e, 'booktitle', as_sentence=False),
                 #self.format_volume_and_series(e, as_sentence=False),
                 #self.format_chapter_and_pages(e),
             ],
         Symbol('br'),
         sentence [
             field('publisher'),
             optional_field('address'),
             optional [
                 words [field('edition'), 'edition']
             ],
             #date,
             #Symbol('br'),
             #optional_field('note'),
             ],
         ],
         Symbol('br'),
         sentence [
             optional_field('note'),
         ],
         Symbol('br'),
         #self.format_web_refs(e),
     ]
     return template.format_data(e)
开发者ID:rahulsavani,项目名称:pelican_homepage,代码行数:35,代码来源:rahul_style.py


示例4: format_inproceedings

 def format_inproceedings(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         sentence [self.format_chapter_and_pages(e)],
         sentence [
             field('publisher'),
             optional_field('address'),
             date,
             optional_field('note'),
         ]
     ]
     return template.format_data(e)
开发者ID:rybesh,项目名称:pybtex,代码行数:12,代码来源:custom.py


示例5: format_booklet

 def format_booklet(self, e):
     template = toplevel [
         self.format_names('author'),
         self.format_title(e, 'title'),
         sentence [
             optional_field('howpublished'),
             optional_field('address'),
             date,
             optional_field('note'),
         ]
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:12,代码来源:unsrt.py


示例6: format_phdthesis

 def format_phdthesis(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         self.format_btitle(e, 'title'),
         sentence[
             'PhD thesis',
             field('school'),
             optional_field('address'),
             date,
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:13,代码来源:unsrt.py


示例7: format_book

 def format_book(self, e):
     template = toplevel [
         self.format_author_or_editor(e),
         self.format_btitle(e, 'title'),
         self.format_volume_and_series(e),
         sentence [
             field('publisher'),
             optional_field('address'),
             self.format_edition(e),
             date
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:14,代码来源:unsrt.py


示例8: format_mastersthesis

 def format_mastersthesis(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         self.format_title(e, 'title'),
         sentence[
             "Master's thesis",
             field('school'),
             optional_field('address'),
             date,
         ],
         sentence(capfirst=False) [ optional_field('note') ],
         self.format_web_refs(e),
     ]
     return template.format_data(e)
开发者ID:andreas-h,项目名称:pybtex,代码行数:14,代码来源:unsrt.py


示例9: format_manual

 def format_manual(self, e):
     # TODO this only corresponds to the bst style if author is non-empty
     # for empty author we should put the organization first
     template = toplevel [
         optional [ sentence [ self.format_names('author') ] ],
         self.format_btitle(e, 'title'),
         sentence [
             optional_field('organization'),
             optional_field('address'),
             self.format_edition(e),
             optional[ date ],
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:15,代码来源:unsrt.py


示例10: format_volume_and_series

 def format_volume_and_series(self, e, as_sentence=True):
     volume_and_series = optional [
         words [
             'volume', field('volume'), optional [
                 words ['of', field('series')]
             ]
         ]
     ]
     number_and_series = optional [
         words [
             join(sep=Symbol('nbsp')) ['number', field('number')],
             optional [
                 words ['in', field('series')]
             ]
         ]
     ]
     series = optional_field('series')
     result = first_of [
             volume_and_series,
             number_and_series,
             series,
         ]
     if as_sentence:
         return sentence(capfirst=False) [result]
     else:
         return result
开发者ID:OVii,项目名称:communityvisweb,代码行数:26,代码来源:unsrt.py


示例11: format_inbook

 def format_inbook(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         sentence [self.format_chapter_and_pages(e)],
         self.format_volume_and_series(e),
         sentence [
             field('publisher'),
             optional_field('address'),
             optional [
                 words [field('edition'), 'edition']
             ],
             date,
             optional_field('note'),
         ]
     ]
     return template.format_data(e)
开发者ID:rybesh,项目名称:pybtex,代码行数:16,代码来源:custom.py


示例12: format_techreport

 def format_techreport(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         self.format_title(e, 'title'),
         sentence [
             words[
                 first_of [
                     optional_field('type'),
                     'Technical Report',
                 ],
                 optional_field('number'),
             ],
             field('institution'),
             optional_field('address'),
             date,
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:19,代码来源:unsrt.py


示例13: format_article

 def format_article(self, e):
     template = toplevel [
         self.format_names('author'),
         self.format_title(e, 'title'),
         join [tag('emph') [field('journal')], ' ',
             tag('strong')[field('volume')], ', ', unsrt.pages,
             ' (', field('year'), ')'],
         sentence(capfirst=False) [ optional_field('note') ],
         self.format_web_refs(e),
         ]
     return template.format_data(e)
开发者ID:cycomanic,项目名称:pelican-bibtex,代码行数:11,代码来源:pelican_perpagepublications.py


示例14: format_misc

 def format_misc(self, e):
     template = toplevel [
         optional[ sentence [self.format_names('author')] ],
         optional[ self.format_title(e, 'title') ],
         sentence[
             optional[ field('howpublished') ],
             optional[ date ],
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:11,代码来源:unsrt.py


示例15: format_incollection

 def format_incollection(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         self.format_title(e, 'title'),
         words [
             'In',
             sentence(capfirst=False) [
                 optional[ self.format_editor(e, as_sentence=False) ],
                 self.format_btitle(e, 'booktitle', as_sentence=False),
                 self.format_volume_and_series(e, as_sentence=False),
                 self.format_chapter_and_pages(e),
             ],
         ],
         sentence [
             optional_field('publisher'),
             optional_field('address'),
             self.format_edition(e),
             date,
         ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:21,代码来源:unsrt.py


示例16: format_inproceedings

 def format_inproceedings(self, e):
     template = toplevel [
         sentence [self.format_names('author')],
         self.format_title(e, 'title'),
         words [
             'In',
             sentence(capfirst=False) [
                 optional[ self.format_editor(e, as_sentence=False) ],
                 self.format_btitle(e, 'booktitle', as_sentence=False),
                 self.format_volume_and_series(e, as_sentence=False),
                 optional[ pages ],
             ],
             self.format_address_organization_publisher_date(e),
         ],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:17,代码来源:unsrt.py


示例17: format_article

 def format_article(self, e):
     volume_and_pages = first_of [
         # volume and pages, with optional issue number
         optional [
             join [
                 field('volume'),
                 optional['(', field('number'),')'],
                 ':', pages
             ],
         ],
         # pages only
         words ['pages', pages],
     ]
     template = toplevel [
         self.format_names('author'),
         self.format_title(e, 'title'),
         sentence(capfirst=False) [
             tag('emph') [field('journal')],
             optional[ volume_and_pages ],
             date],
         sentence(capfirst=False) [ optional_field('note') ],
     ]
     return template.format_data(e)
开发者ID:OVii,项目名称:communityvisweb,代码行数:23,代码来源:unsrt.py


示例18: import

import re

from pybtex.style.formatting import BaseStyle, toplevel
from pybtex.style.template import (
    join, words, field, optional, first_of,
    names, sentence, tag, optional_field
)
from pybtex.richtext import Text, Symbol

def dashify(text):
    dash_re = re.compile(r'-+')
    return Text(Symbol('ndash')).join(dash_re.split(text))

pages = field('pages', apply_func=dashify)

date = words [optional_field('month'), field('year')]

class Style(BaseStyle):
    name = 'unsrt'

    def format_names(self, role, as_sentence=True):
        formatted_names = names(role, sep=', ', sep2 = ' and ', last_sep=', and ')
        if as_sentence:
            return sentence(capfirst=False) [formatted_names]
        else:
            return formatted_names

    def format_article(self, e):
        volume_and_pages = first_of [
            # volume and pages, with optional issue number
            optional [
开发者ID:OVii,项目名称:communityvisweb,代码行数:31,代码来源:unsrt.py



注:本文中的pybtex.style.template.optional_field函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python template.sentence函数代码示例发布时间:2022-05-25
下一篇:
Python template.join函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap