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

Inkscape_r2p: Fix imports for Python 2/3 #826

Merged
merged 2 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions rst2pdf/createpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#
#####################################################################################


__docformat__ = 'reStructuredText'
from importlib import import_module
import six
Expand Down Expand Up @@ -1577,11 +1576,13 @@ def __init__(self):
sys.path.insert(0, prefix)
log.info('Importing extension module %s', repr(modname))
firstname = path_given and modname or (modname + '_r2p')
_names = [firstname, modname]
try:
try:
module = import_module(firstname)
except ImportError as e:
module = import_module(modname)
for _name in _names:
try:
module = import_module(_name, 'rst2pdf')
except ImportError:
continue
except ImportError as e:
if str(e).split()[-1].replace("'", '') not in [firstname, modname]:
raise
Expand Down
7 changes: 5 additions & 2 deletions rst2pdf/extensions/inkscape_r2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
import sys, os, tempfile, subprocess
from weakref import WeakKeyDictionary
from rst2pdf.log import log

from vectorpdf_r2p import VectorPdf
try:
from vectorpdf_r2p import VectorPdf
except:
from .vectorpdf_r2p import VectorPdf

import rst2pdf.image


Expand Down