Commit 99888832 authored by Andrey Golovizin's avatar Andrey Golovizin

Sort imports with isort

parent 7b1af258
......@@ -24,7 +24,7 @@
"""Generate man pages for pybtex and pybtex-convert.
"""
from __future__ import with_statement, print_function
from __future__ import print_function, with_statement
import os
import sys
......
......@@ -25,13 +25,17 @@ from __future__ import absolute_import
import re
from string import ascii_letters, digits
from pygments.style import Style
from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, default, words
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Literal, Punctuation, Text
from pybtex.database.input.bibtex import NAME_CHARS
from pygments.lexer import (
ExtendedRegexLexer, RegexLexer, default, include, words
)
from pygments.style import Style
from pygments.token import (
Comment, Error, Generic, Keyword, Literal, Name, Number, Operator,
Punctuation, String, Text
)
from . import add_entry_point
......
......@@ -12,8 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import sys
from datetime import datetime
from pybtex import __version__
......
......@@ -12,8 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import sys
import os
import sys
from datetime import datetime
from pybtex import __version__
......
from setuptools import setup
setup(name='Sample Pybtex plugins',
author='Andrey Golovizin',
py_modules=['toyplugins'],
......
......@@ -25,11 +25,10 @@
import imp
from pybtex.utils import OrderedCaseInsensitiveDict
from pybtex.database.output import BaseWriter
from pybtex.database import BibliographyData, Entry, FieldDict, Person
from pybtex.database.input import BaseParser
from pybtex.database import BibliographyData, Entry, Person, FieldDict
from pybtex.database.output import BaseWriter
from pybtex.utils import OrderedCaseInsensitiveDict
class PythonWriter(BaseWriter):
......
......@@ -22,6 +22,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from os import path
from pybtex.cmdline import CommandLine, make_option, standard_option
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,9 +19,11 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import warnings
from pybtex import __version__ as version # noqa
msg = 'pybtex.__version__.version is deprecated since 0.19: use pybtex.__version__ attribute'
warnings.warn(msg, DeprecationWarning)
from pybtex import __version__ as version # noqa
......@@ -22,14 +22,13 @@
"""parse LaTeX aux file
"""
from __future__ import with_statement
from __future__ import unicode_literals
from __future__ import unicode_literals, with_statement
import re
import pybtex.io
from pybtex.exceptions import PybtexError
from pybtex.errors import report_error
from pybtex.exceptions import PybtexError
class AuxDataError(PybtexError):
......
......@@ -38,10 +38,10 @@ HTML output backend.
"""
from __future__ import unicode_literals
from xml.sax.saxutils import escape
from pybtex.backends import BaseBackend
import pybtex.io
from pybtex.backends import BaseBackend
PROLOGUE = u"""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
......@@ -91,4 +91,3 @@ class Backend(BaseBackend):
def write_entry(self, key, label, text):
self.output(u'<dt>%s</dt>\n' % label)
self.output(u'<dd>%s</dd>\n' % text)
......@@ -38,11 +38,9 @@ LaTeX output backend.
"""
from __future__ import unicode_literals
import codecs
import latexcodec # noqa
from pybtex.backends import BaseBackend
......@@ -105,4 +103,3 @@ class Backend(BaseBackend):
def write_entry(self, key, label, text):
self.output(u'\n\n\\bibitem[%s]{%s}\n' % (label, key))
self.output(text)
......@@ -39,12 +39,10 @@ Markdown output backend.
"""
from __future__ import unicode_literals
from xml.sax.saxutils import escape
from pybtex.backends import BaseBackend
SPECIAL_CHARS = [
u'\\', # backslash
u'`', # backtick
......@@ -123,4 +121,3 @@ class Backend(BaseBackend):
else:
self.output(u'[%s] ' % label)
self.output(u'%s \n' % text)
from __future__ import unicode_literals
from pybtex.backends import BaseBackend
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,7 +24,6 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from pybtex.backends import BaseBackend
class Backend(BaseBackend):
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,10 +19,18 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import re
from pybtex.bibtex.interpreter import (Integer, String, QuotedVar,
Identifier, FunctionLiteral)
import pybtex.io
from pybtex.bibtex.interpreter import (
FunctionLiteral, Identifier, Integer, QuotedVar, String
)
from pybtex.scanner import (
Literal, Pattern, PybtexSyntaxError, Scanner, TokenRequired
)
#ParserElement.enablePackrat()
......@@ -80,10 +87,6 @@ def strip_comment(line):
return line
from pybtex.scanner import (
Scanner, Pattern, Literal,
TokenRequired, PybtexSyntaxError,
)
class BstParser(Scanner):
......@@ -165,4 +168,3 @@ if __name__ == '__main__':
import sys
from pprint import pprint
pprint(parse_file(sys.argv[1]))
......@@ -23,18 +23,16 @@
CAUTION: functions should PUSH results, not RETURN
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
from functools import update_wrapper
import pybtex.io
from pybtex.errors import report_error
from pybtex.bibtex.exceptions import BibTeXError
from pybtex.utils import memoize
from pybtex.bibtex import utils
from pybtex.bibtex.exceptions import BibTeXError
from pybtex.bibtex.names import format_name as format_bibtex_name
from pybtex.errors import report_error
from pybtex.utils import memoize
def print_warning(msg):
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,7 +19,10 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from pybtex.exceptions import PybtexError
class BibTeXError(PybtexError):
pass
from __future__ import print_function
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -21,12 +19,15 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import six
from __future__ import print_function, unicode_literals
from pybtex.utils import CaseInsensitiveDict
from pybtex.bibtex.exceptions import BibTeXError
import six
from pybtex.bibtex.builtins import builtins, print_warning
from pybtex.bibtex.exceptions import BibTeXError
from pybtex.bibtex.utils import wrap
from pybtex.utils import CaseInsensitiveDict
#from pybtex.database.input import bibtex
......
......@@ -45,11 +45,10 @@ from __future__ import unicode_literals
import re
from pybtex.bibtex.utils import bibtex_abbreviate, bibtex_len
from pybtex.database import Person
from pybtex.bibtex.utils import bibtex_len, bibtex_abbreviate
from pybtex.scanner import (
Scanner, Pattern, Literal,
PybtexSyntaxError, PrematureEOF
Literal, Pattern, PrematureEOF, PybtexSyntaxError, Scanner
)
......@@ -365,4 +364,3 @@ class NameFormatParser(Scanner):
def eat_whitespace(self):
pass
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,14 +19,14 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
import re
from pybtex.utils import pairwise
import six
from pybtex.bibtex.exceptions import BibTeXError
from pybtex.py3compat import fix_unicode_literals_in_doctest
import six
from pybtex.utils import pairwise
whitespace_re = re.compile(r'(\s)')
purify_special_char_re = re.compile(r'^\\[A-Za-z]+')
......@@ -561,4 +560,3 @@ def bibtex_abbreviate(string, delimiter=None, separator='-'):
if delimiter is None:
delimiter = '.-'
return delimiter.join(_bibtex_abbreviate())
......@@ -25,8 +25,7 @@
"""
Make a table of character widths to use with bibtex width$ function.
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import print_function, unicode_literals
def make_table(font_filename, output):
......
......@@ -22,12 +22,13 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import sys
import optparse
import sys
from pybtex import errors, __version__
from pybtex import __version__, errors
from pybtex.plugin import enumerate_plugin_names, find_plugin
from pybtex.textutils import add_period
from pybtex.plugin import find_plugin, enumerate_plugin_names
def check_plugin(option, option_string, value):
......
......@@ -23,6 +23,7 @@
from __future__ import unicode_literals
from pybtex.cmdline import CommandLine, make_option, standard_option
......
......@@ -23,6 +23,7 @@
from __future__ import unicode_literals
from pybtex.cmdline import CommandLine, standard_option
......
......@@ -70,18 +70,17 @@ http://www.sciencemag.org/cgi/content/abstract/276/5315/1109
"""
from __future__ import unicode_literals
import re
from string import ascii_letters, digits
import re
from pybtex.utils import CaseInsensitiveDict, CaseInsensitiveSet
from pybtex import textutils
from pybtex.bibtex.utils import split_name_list
from pybtex.database import Entry, Person
from pybtex.database.input import BaseParser
from pybtex.bibtex.utils import split_name_list
from pybtex import textutils
from pybtex.scanner import (
Scanner, Pattern, Literal,
PrematureEOF, PybtexSyntaxError,
Literal, Pattern, PrematureEOF, PybtexSyntaxError, Scanner
)
from pybtex.utils import CaseInsensitiveDict, CaseInsensitiveSet
month_names = {
'jan': 'January',
......@@ -395,4 +394,3 @@ class Parser(BaseParser):
def parse_stream(self, stream):
text = stream.read()
return self.parse_string(text)
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,11 +19,13 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from xml.etree import cElementTree as ET
from pybtex.database import Entry, Person
from pybtex.database.input import BaseParser
bibtexns = '{http://bibtexml.sf.net/}'
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,14 +19,14 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
from collections import OrderedDict
import six
import yaml
from pybtex.database.input import BaseParser
from pybtex.database import Entry, Person
import six
from pybtex.database.input import BaseParser
class OrderedDictSafeLoader(yaml.SafeLoader):
......
......@@ -22,6 +22,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import codecs
from pybtex.bibtex.exceptions import BibTeXError
......@@ -167,4 +168,3 @@ class Writer(BaseWriter):
for type, value in entry.fields.items():
self._write_field(stream, type, value)
stream.write(u'\n}\n')
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -21,8 +20,8 @@ from __future__ import unicode_literals
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import io
import io
from xml.sax.saxutils import XMLGenerator
from xml.sax.xmlreader import AttributesImpl
......@@ -134,4 +133,3 @@ class Writer(BaseWriter):
writer.newline()
writer.end()
writer.close()
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,10 +19,11 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from collections import OrderedDict
import yaml
from pybtex.database.output import BaseWriter
......
from __future__ import print_function
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -21,13 +19,13 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import absolute_import
from __future__ import absolute_import, print_function, unicode_literals
from contextlib import contextmanager
import pybtex.io
import six
strict = True
error_code = 0
captured_errors = None
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,9 +19,11 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import
import six
class PybtexError(Exception):
def __init__(self, message, filename=None):
super(PybtexError, self).__init__(message)
......
......@@ -22,12 +22,11 @@
"""Unicode-aware IO routines."""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
import io
import sys
from os import path, environ
from os import environ, path
from pybtex.exceptions import PybtexError
from pybtex.kpathsea import kpsewhich
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,7 +19,9 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from subprocess import Popen, PIPE
from __future__ import unicode_literals
from subprocess import PIPE, Popen
def kpsewhich(filename):
......
......@@ -22,7 +22,6 @@
import sys
PY3 = sys.version_info[0] >= 3
......
......@@ -57,16 +57,15 @@ one~two~\emph{three}
>>> print(unicode(t))
one<nbsp>two<nbsp>three
"""
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
from __future__ import absolute_import
import warnings
import itertools
import warnings
from abc import ABCMeta, abstractmethod
from pybtex import textutils
from pybtex.utils import deprecated, collect_iterable
import six
from pybtex import textutils
from pybtex.utils import collect_iterable, deprecated
# workaround for doctests in Python 2/3
......@@ -1014,4 +1013,3 @@ class Symbol(BaseText):
nbsp = Symbol('nbsp')
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,6 +19,8 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
class FormattedEntry(object):
"""Formatted bibliography entry. Consists of
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,6 +19,8 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
......
from __future__ import unicode_literals
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,7 +24,6 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
class Style(UnsrtStyle):
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,14 +19,16 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
import re
from pybtex.richtext import Symbol, Text
from pybtex.style.formatting import BaseStyle, toplevel
from pybtex.style.template import (
join, words, together, field, optional, first_of,
names, sentence, tag, optional_field, href
field, first_of, href, join, names, optional, optional_field, sentence,
tag, together, words
)
from pybtex.richtext import Text, Symbol
def dashify(text):
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,6 +19,8 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
......
from __future__ import unicode_literals
# Copyright (c) 2006-2017 Andrey Golovigin
#
# Permission is hereby granted, free of charge, to any person obtaining
......@@ -20,6 +19,8 @@ from __future__ import unicode_literals
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from pybtex.plugin import Plugin
from pybtex.textutils import width
......
......@@ -22,20 +22,22 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from __future__ import unicode_literals
from __future__ import absolute_import
from __future__ import absolute_import, unicode_literals
import re
import sys
import unicodedata
import six
from pybtex.style.labels import BaseLabelStyle
from pybtex.textutils import abbreviate
if sys.version_info < (2, 7):
from counter import Counter
else:
from collections import Counter