Loading pybtex/database/__init__.py +4 −4 Original line number Diff line number Diff line Loading @@ -592,9 +592,9 @@ class Person(object): [u'Dixit'] >>> print(p.lineage_names) [] >>> print(unicode(p)) >>> print(six.text_type(p)) Dixit, Avinash K. >>> p == Person(unicode(p)) >>> p == Person(six.text_type(p)) True >>> p = Person('Dixit, Jr, Avinash K. ') >>> print(p.first_names) Loading @@ -607,9 +607,9 @@ class Person(object): [u'Dixit'] >>> print(p.lineage_names) [u'Jr'] >>> print(unicode(p)) >>> print(six.text_type(p)) Dixit, Jr, Avinash K. >>> p == Person(unicode(p)) >>> p == Person(six.text_type(p)) True >>> p = Person('abc') Loading pybtex/database/input/bibtex.py +3 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ True >>> rief97b = bib_data.entries['rief97b'] >>> authors = rief97b.persons['author'] >>> for author in authors: ... print(unicode(author)) ... print(six.text_type(author)) Rief, Matthias Gautel, Mathias Oesterhelt, Filipp Loading @@ -73,6 +73,8 @@ from __future__ import unicode_literals import re from string import ascii_letters, digits import six from pybtex import textutils from pybtex.bibtex.utils import split_name_list from pybtex.database import Entry, Person Loading pybtex/richtext.py +11 −11 Original line number Diff line number Diff line Loading @@ -26,35 +26,35 @@ Usage: >>> t = Text('this ', 'is a ', Tag('em', 'very'), Text(' rich', ' text')) >>> print(t.render_as('latex')) this is a \emph{very} rich text >>> print(unicode(t)) >>> print(six.text_type(t)) this is a very rich text >>> t = t.capitalize().add_period() >>> print(t.render_as('latex')) This is a \emph{very} rich text. >>> print(unicode(t)) >>> print(six.text_type(t)) This is a very rich text. >>> print(Symbol('ndash').render_as('latex')) -- >>> t = Text('Some ', Tag('em', Text('nested ', Tag('tt', 'Text', Text(' objects')))), '.') >>> print(t.render_as('latex')) Some \emph{nested \texttt{Text objects}}. >>> print(unicode(t)) >>> print(six.text_type(t)) Some nested Text objects. >>> t = t.upper() >>> print(t.render_as('latex')) SOME \emph{NESTED \texttt{TEXT OBJECTS}}. >>> print(unicode(t)) >>> print(six.text_type(t)) SOME NESTED TEXT OBJECTS. >>> t = Text(', ').join(['one', 'two', Tag('em', 'three')]) >>> print(t.render_as('latex')) one, two, \emph{three} >>> print(unicode(t)) >>> print(six.text_type(t)) one, two, three >>> t = Text(Symbol('nbsp')).join(['one', 'two', Tag('em', 'three')]) >>> print(t.render_as('latex')) one~two~\emph{three} >>> print(unicode(t)) >>> print(six.text_type(t)) one<nbsp>two<nbsp>three """ from __future__ import absolute_import, unicode_literals Loading Loading @@ -152,9 +152,9 @@ class BaseText(object): """Join a list using this text (like string.join) >>> letters = ['a', 'b', 'c'] >>> print(unicode(String('-').join(letters))) >>> print(six.text_type(String('-').join(letters))) a-b-c >>> print(unicode(String('-').join(iter(letters)))) >>> print(six.text_type(String('-').join(iter(letters)))) a-b-c """ Loading Loading @@ -202,11 +202,11 @@ class BaseText(object): Add a period to the end of text, if the last character is not ".", "!" or "?". >>> text = Text("That's all, folks") >>> print(unicode(text.add_period())) >>> print(six.text_type(text.add_period())) That's all, folks. >>> text = Text("That's all, folks!") >>> print(unicode(text.add_period())) >>> print(six.text_type(text.add_period())) That's all, folks! """ Loading Loading @@ -709,7 +709,7 @@ class String(BaseText): All arguments must be plain unicode strings. Arguments are concatenated together. >>> print(unicode(String('November', ', ', 'December', '.'))) >>> print(six.text_type(String('November', ', ', 'December', '.'))) November, December. """ Loading pybtex/style/template.py +17 −14 Original line number Diff line number Diff line Loading @@ -36,13 +36,16 @@ Inspired by Brevé -- http://breve.twisty-industries.com/ >>> book_format = sentence(capfirst=True, sep=', ') [ ... field('title'), field('year'), optional [field('sdf')] ... ] >>> print(unicode(book_format.format_data({'entry': e}))) >>> print(six.text_type(book_format.format_data({'entry': e}))) The Book, 2000. >>> print(unicode(words ['one', 'two', words ['three', 'four']].format_data(e))) >>> print(six.text_type(words ['one', 'two', words ['three', 'four']].format_data(e))) one two three four """ from __future__ import unicode_literals import six from pybtex import richtext from pybtex.exceptions import PybtexError from pybtex.py3compat import fix_unicode_literals_in_doctest Loading Loading @@ -156,13 +159,13 @@ def node(f): @node def join(children, data, sep='', sep2=None, last_sep=None): """Join text fragments together. >>> print(unicode(join.format())) >>> print(six.text_type(join.format())) <BLANKLINE> >>> print(unicode(join ['a', 'b', 'c', 'd', 'e'].format())) >>> print(six.text_type(join ['a', 'b', 'c', 'd', 'e'].format())) abcde >>> print(unicode(join(sep=', ', sep2=' and ', last_sep=', and ') ['Tom', 'Jerry'].format())) >>> print(six.text_type(join(sep=', ', sep2=' and ', last_sep=', and ') ['Tom', 'Jerry'].format())) Tom and Jerry >>> print(unicode(join(sep=', ', sep2=' and ', last_sep=', and ') ['Billy', 'Willy', 'Dilly'].format())) >>> print(six.text_type(join(sep=', ', sep2=' and ', last_sep=', and ') ['Billy', 'Willy', 'Dilly'].format())) Billy, Willy, and Dilly """ Loading Loading @@ -191,15 +194,15 @@ def together(children, data, last_tie=False): """ Try to keep words together, like BibTeX does. >>> print(unicode(together ['very', 'long', 'road'].format())) >>> print(six.text_type(together ['very', 'long', 'road'].format())) very long road >>> print(unicode(together(last_tie=True) ['very', 'long', 'road'].format())) >>> print(six.text_type(together(last_tie=True) ['very', 'long', 'road'].format())) very long<nbsp>road >>> print(unicode(together ['a', 'very', 'long', 'road'].format())) >>> print(six.text_type(together ['a', 'very', 'long', 'road'].format())) a<nbsp>very long road >>> print(unicode(together ['chapter', '8'].format())) >>> print(six.text_type(together ['chapter', '8'].format())) chapter<nbsp>8 >>> print(unicode(together ['chapter', '666'].format())) >>> print(six.text_type(together ['chapter', '666'].format())) chapter 666 """ from pybtex.textutils import tie_or_space Loading @@ -223,11 +226,11 @@ def together(children, data, last_tie=False): def sentence(children, data, capfirst=False, capitalize=False, add_period=True, sep=', '): """Join text fragments, capitalyze the first letter, add a period to the end. >>> print(unicode(sentence.format())) >>> print(six.text_type(sentence.format())) <BLANKLINE> >>> print(unicode(sentence(capitalize=True, sep=' ') ['mary', 'had', 'a', 'little', 'lamb'].format())) >>> print(six.text_type(sentence(capitalize=True, sep=' ') ['mary', 'had', 'a', 'little', 'lamb'].format())) Mary had a little lamb. >>> print(unicode(sentence(capitalize=False, add_period=False) ['uno', 'dos', 'tres'].format())) >>> print(six.text_type(sentence(capitalize=False, add_period=False) ['uno', 'dos', 'tres'].format())) uno, dos, tres """ Loading Loading
pybtex/database/__init__.py +4 −4 Original line number Diff line number Diff line Loading @@ -592,9 +592,9 @@ class Person(object): [u'Dixit'] >>> print(p.lineage_names) [] >>> print(unicode(p)) >>> print(six.text_type(p)) Dixit, Avinash K. >>> p == Person(unicode(p)) >>> p == Person(six.text_type(p)) True >>> p = Person('Dixit, Jr, Avinash K. ') >>> print(p.first_names) Loading @@ -607,9 +607,9 @@ class Person(object): [u'Dixit'] >>> print(p.lineage_names) [u'Jr'] >>> print(unicode(p)) >>> print(six.text_type(p)) Dixit, Jr, Avinash K. >>> p == Person(unicode(p)) >>> p == Person(six.text_type(p)) True >>> p = Person('abc') Loading
pybtex/database/input/bibtex.py +3 −1 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ True >>> rief97b = bib_data.entries['rief97b'] >>> authors = rief97b.persons['author'] >>> for author in authors: ... print(unicode(author)) ... print(six.text_type(author)) Rief, Matthias Gautel, Mathias Oesterhelt, Filipp Loading @@ -73,6 +73,8 @@ from __future__ import unicode_literals import re from string import ascii_letters, digits import six from pybtex import textutils from pybtex.bibtex.utils import split_name_list from pybtex.database import Entry, Person Loading
pybtex/richtext.py +11 −11 Original line number Diff line number Diff line Loading @@ -26,35 +26,35 @@ Usage: >>> t = Text('this ', 'is a ', Tag('em', 'very'), Text(' rich', ' text')) >>> print(t.render_as('latex')) this is a \emph{very} rich text >>> print(unicode(t)) >>> print(six.text_type(t)) this is a very rich text >>> t = t.capitalize().add_period() >>> print(t.render_as('latex')) This is a \emph{very} rich text. >>> print(unicode(t)) >>> print(six.text_type(t)) This is a very rich text. >>> print(Symbol('ndash').render_as('latex')) -- >>> t = Text('Some ', Tag('em', Text('nested ', Tag('tt', 'Text', Text(' objects')))), '.') >>> print(t.render_as('latex')) Some \emph{nested \texttt{Text objects}}. >>> print(unicode(t)) >>> print(six.text_type(t)) Some nested Text objects. >>> t = t.upper() >>> print(t.render_as('latex')) SOME \emph{NESTED \texttt{TEXT OBJECTS}}. >>> print(unicode(t)) >>> print(six.text_type(t)) SOME NESTED TEXT OBJECTS. >>> t = Text(', ').join(['one', 'two', Tag('em', 'three')]) >>> print(t.render_as('latex')) one, two, \emph{three} >>> print(unicode(t)) >>> print(six.text_type(t)) one, two, three >>> t = Text(Symbol('nbsp')).join(['one', 'two', Tag('em', 'three')]) >>> print(t.render_as('latex')) one~two~\emph{three} >>> print(unicode(t)) >>> print(six.text_type(t)) one<nbsp>two<nbsp>three """ from __future__ import absolute_import, unicode_literals Loading Loading @@ -152,9 +152,9 @@ class BaseText(object): """Join a list using this text (like string.join) >>> letters = ['a', 'b', 'c'] >>> print(unicode(String('-').join(letters))) >>> print(six.text_type(String('-').join(letters))) a-b-c >>> print(unicode(String('-').join(iter(letters)))) >>> print(six.text_type(String('-').join(iter(letters)))) a-b-c """ Loading Loading @@ -202,11 +202,11 @@ class BaseText(object): Add a period to the end of text, if the last character is not ".", "!" or "?". >>> text = Text("That's all, folks") >>> print(unicode(text.add_period())) >>> print(six.text_type(text.add_period())) That's all, folks. >>> text = Text("That's all, folks!") >>> print(unicode(text.add_period())) >>> print(six.text_type(text.add_period())) That's all, folks! """ Loading Loading @@ -709,7 +709,7 @@ class String(BaseText): All arguments must be plain unicode strings. Arguments are concatenated together. >>> print(unicode(String('November', ', ', 'December', '.'))) >>> print(six.text_type(String('November', ', ', 'December', '.'))) November, December. """ Loading
pybtex/style/template.py +17 −14 Original line number Diff line number Diff line Loading @@ -36,13 +36,16 @@ Inspired by Brevé -- http://breve.twisty-industries.com/ >>> book_format = sentence(capfirst=True, sep=', ') [ ... field('title'), field('year'), optional [field('sdf')] ... ] >>> print(unicode(book_format.format_data({'entry': e}))) >>> print(six.text_type(book_format.format_data({'entry': e}))) The Book, 2000. >>> print(unicode(words ['one', 'two', words ['three', 'four']].format_data(e))) >>> print(six.text_type(words ['one', 'two', words ['three', 'four']].format_data(e))) one two three four """ from __future__ import unicode_literals import six from pybtex import richtext from pybtex.exceptions import PybtexError from pybtex.py3compat import fix_unicode_literals_in_doctest Loading Loading @@ -156,13 +159,13 @@ def node(f): @node def join(children, data, sep='', sep2=None, last_sep=None): """Join text fragments together. >>> print(unicode(join.format())) >>> print(six.text_type(join.format())) <BLANKLINE> >>> print(unicode(join ['a', 'b', 'c', 'd', 'e'].format())) >>> print(six.text_type(join ['a', 'b', 'c', 'd', 'e'].format())) abcde >>> print(unicode(join(sep=', ', sep2=' and ', last_sep=', and ') ['Tom', 'Jerry'].format())) >>> print(six.text_type(join(sep=', ', sep2=' and ', last_sep=', and ') ['Tom', 'Jerry'].format())) Tom and Jerry >>> print(unicode(join(sep=', ', sep2=' and ', last_sep=', and ') ['Billy', 'Willy', 'Dilly'].format())) >>> print(six.text_type(join(sep=', ', sep2=' and ', last_sep=', and ') ['Billy', 'Willy', 'Dilly'].format())) Billy, Willy, and Dilly """ Loading Loading @@ -191,15 +194,15 @@ def together(children, data, last_tie=False): """ Try to keep words together, like BibTeX does. >>> print(unicode(together ['very', 'long', 'road'].format())) >>> print(six.text_type(together ['very', 'long', 'road'].format())) very long road >>> print(unicode(together(last_tie=True) ['very', 'long', 'road'].format())) >>> print(six.text_type(together(last_tie=True) ['very', 'long', 'road'].format())) very long<nbsp>road >>> print(unicode(together ['a', 'very', 'long', 'road'].format())) >>> print(six.text_type(together ['a', 'very', 'long', 'road'].format())) a<nbsp>very long road >>> print(unicode(together ['chapter', '8'].format())) >>> print(six.text_type(together ['chapter', '8'].format())) chapter<nbsp>8 >>> print(unicode(together ['chapter', '666'].format())) >>> print(six.text_type(together ['chapter', '666'].format())) chapter 666 """ from pybtex.textutils import tie_or_space Loading @@ -223,11 +226,11 @@ def together(children, data, last_tie=False): def sentence(children, data, capfirst=False, capitalize=False, add_period=True, sep=', '): """Join text fragments, capitalyze the first letter, add a period to the end. >>> print(unicode(sentence.format())) >>> print(six.text_type(sentence.format())) <BLANKLINE> >>> print(unicode(sentence(capitalize=True, sep=' ') ['mary', 'had', 'a', 'little', 'lamb'].format())) >>> print(six.text_type(sentence(capitalize=True, sep=' ') ['mary', 'had', 'a', 'little', 'lamb'].format())) Mary had a little lamb. >>> print(unicode(sentence(capitalize=False, add_period=False) ['uno', 'dos', 'tres'].format())) >>> print(six.text_type(sentence(capitalize=False, add_period=False) ['uno', 'dos', 'tres'].format())) uno, dos, tres """ Loading