diff --git a/README.rst b/README.rst index 22aff04..3a2635f 100644 --- a/README.rst +++ b/README.rst @@ -20,7 +20,7 @@ Allows calling LaTeX from Python without leaving a mess. Similar to the pdf = build_pdf(min_latex) # look at the first few bytes of the header - print bytes(pdf)[:10] + print(bytes(pdf)[:10]) Also comes with support for using `Jinja2 `_ templates to generate LaTeX files. diff --git a/docs/examples/ex4.py b/docs/examples/ex4.py index 377f5ab..c6faa82 100644 --- a/docs/examples/ex4.py +++ b/docs/examples/ex4.py @@ -13,7 +13,7 @@ build_pdf(src) except LatexBuildError as e: for err in e.get_errors(): - print u'Error in {0[filename]}, line {0[line]}: {0[error]}'.format(err) + print('Error in {0[filename]}, line {0[line]}: {0[error]}'.format(err)) # also print one line of context - print u' {}'.format(err['context'][1]) - print + print(' {}'.format(err['context'][1])) + print() diff --git a/latex/__init__.py b/latex/__init__.py index 3a8c9cc..5da0c02 100644 --- a/latex/__init__.py +++ b/latex/__init__.py @@ -4,26 +4,26 @@ from .build import build_pdf CHAR_ESCAPE = { - u'&': u'\\&', - u'%': u'\\%', - u'$': u'\\$', - u'#': u'\\#', - u'_': u'\\_', - u'{': u'\\{', - u'}': u'\\}', - u'~': u'\\textasciitilde{}', - u'^': u'\\textasciicircum{}', - u'\\': u'\\textbackslash{}', + '&': '\\&', + '%': '\\%', + '$': '\\$', + '#': '\\#', + '_': '\\_', + '{': '\\{', + '}': '\\}', + '~': '\\textasciitilde{}', + '^': '\\textasciicircum{}', + '\\': '\\textbackslash{}', # these may be optional: - u'<': u'\\textless{}', - u'>': u'\\textgreater{}', - u'|': u'\\textbar{}', - u'"': u'\\textquotedbl{}', + '<': '\\textless{}', + '>': '\\textgreater{}', + '|': '\\textbar{}', + '"': '\\textquotedbl{}', # to prevent issues with '\\' linebreaks - u'[': u'{[}', - u']': u'{]}', + '[': '{[}', + ']': '{]}', } diff --git a/latex/build.py b/latex/build.py index 9fad818..3e0e8bb 100644 --- a/latex/build.py +++ b/latex/build.py @@ -2,10 +2,9 @@ import subprocess from subprocess import CalledProcessError -from future.utils import raise_from from data import Data as I from data.decorators import data -from shutilwhich import which +from shutil import which from six.moves import shlex_quote from tempdir import TempDir @@ -110,7 +109,7 @@ def build_pdf(self, source, texinputs=[]): stdout=open(os.devnull, 'w'), stderr=open(os.devnull, 'w'), ) except CalledProcessError as e: - raise_from(LatexBuildError(base_fn + '.log'), e) + raise LatexBuildError(base_fn + '.log') from e return I(open(output_fn, 'rb').read(), encoding=None) @@ -174,7 +173,7 @@ def build_pdf(self, source, texinputs=[]): stdin=open(os.devnull, 'r'), stdout=open(os.devnull, 'w'), ) except CalledProcessError as e: - raise_from(LatexBuildError(base_fn + '.log'), e) + raise LatexBuildError(base_fn + '.log') from e # check aux-file aux = open(aux_fn, 'rb').read() diff --git a/latex/jinja2.py b/latex/jinja2.py index 27f7a35..8f4fef6 100644 --- a/latex/jinja2.py +++ b/latex/jinja2.py @@ -1,4 +1,4 @@ -from __future__ import absolute_import + from markupsafe import Markup from jinja2 import Environment diff --git a/setup.py b/setup.py index 2de4fbc..959d744 100644 --- a/setup.py +++ b/setup.py @@ -20,9 +20,8 @@ def read(fname): url='http://github.com/mbr/latex', license='MIT', packages=find_packages(exclude=['tests']), - install_requires=['tempdir', 'data', 'future', 'shutilwhich'], + install_requires=['tempdir', 'data'], classifiers=[ - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', ] )