Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Python 2 support #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://jinja.pocoo.org/>`_ templates
to generate LaTeX files.
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/ex4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
32 changes: 16 additions & 16 deletions latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'{]}',
'[': '{[}',
']': '{]}',
}


Expand Down
7 changes: 3 additions & 4 deletions latex/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion latex/jinja2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import absolute_import


from markupsafe import Markup
from jinja2 import Environment
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
]
)