Example #1
0
 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,
         ],
     ]
Example #2
0
 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
Example #3
0
 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)
Example #4
0
 def format_url(self, e):
     # based on urlbst format.url
     return href [
         field('url'),
         join(' ') [
             'http',
             ]
         ]
Example #5
0
 def format_url(self, e):
     # based on urlbst format.url
     return href [
         field('url'),
         join(' ') [
             'URL:',
             field('url')
             ]
         ]
Example #6
0
 def format_chapter_and_pages(self, e):
     return join(sep=', ') [
         field('title', apply_func=dquote),
         words [
             optional [words ['chapter', field('chapter'), 'of']],
             tag('emph') [field('booktitle')]
         ],
         optional [words ['pages', pages]],
     ]
Example #7
0
 def format_doi(self, e):
     # based on urlbst format.doi
     return href [
         join [
             'http://dx.doi.org/' , 
             field('doi')
             #field('doi')
             ],
         join(' ') [
             'doi'
             ]
         ]
Example #8
0
 def format_editor(self, e, as_sentence=True):
     editors = self.format_names('editor', as_sentence=False)
     if 'editor' not in e.persons:
         # when parsing the template, a FieldIsMissing exception
         # will be thrown anyway; no need to do anything now,
         # just return the template that will throw the exception
         return editors
     if len(e.persons['editor']) > 1:
         word = 'editors'
     else:
         word = 'editor'
     result = join(sep=', ') [editors, word]
     if as_sentence:
         return sentence(capfirst=False) [result]
     else:
         return result
Example #9
0
 def format_volume_and_series(self, e):
     volume_and_series = optional [
         sentence(capfirst=False, sep=' ') [
             'Volume', field('volume'), optional [
                 words ['of', field('series')]
             ]
         ]
     ]
     number_and_series = optional [
         sentence(capfirst=False, sep=' ') [
             join(sep=Symbol('nbsp')) ['Number', field('number')],
             optional [
                 words ['in', field('series')]
             ]
         ]
     ]
     series = optional [ sentence(capfirst=False) [field('series')] ]
     return first_of [
             volume_and_series,
             number_and_series,
             series,
         ]
def toplevel(children, data):
    return join(sep=' ') [children].format_data(data)
Example #11
0
def toplevel(children, data):
    return join(sep=Symbol('newblock'))[children].format_data(data)
Example #12
0
def names(children, data, role, **kwargs):
    assert not children
    persons = data.persons[role]
    return join(**kwargs) [[NameStyle().format(person, abbr=True)
                            for person in persons]].format_data(data)
Example #13
0
 def format_chapter_and_pages(self, e):
     return join(sep=', ') [
         optional [words ['chapter', field('chapter')]],
         optional [words ['pages', pages]],
     ]
Example #14
0
 def format_isbn(self, e):
     return join(sep=' ') [ 'ISBN', field('isbn') ]
Example #15
0
def toplevel(children, data):
    return join(sep=Symbol('newblock')) [children].format_data(data)
Example #16
0
 def format_url(self, e):
     return words['URL:', href[raw_field('url'),
                               join(' ')[raw_field('url')]]]
Example #17
0
 def format_url(self, e):
     # based on urlbst format.url
     return href[field('url'), join(' ')['URL:', field('url')]]
Example #18
0
 def format_chapter_and_pages(self, e):
     return join(sep=', ')[optional[together['chapter',
                                             field('chapter')]],
                           optional[together['pages', pages]], ]
Example #19
0
def names(children, data, role, **kwargs):
    assert not children
    persons = data.persons[role]
    return join(**kwargs)[[NameStyle().format(person, abbr=True)
                           for person in persons]].format_data(data)
 def format_url(self, entry):
     return ['[', href[field('url'), join(' ')['URL']], ']']