Skip to content

Commit

Permalink
Python 3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jellby committed Nov 20, 2020
1 parent f9a1c99 commit 96c69f2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PrincePDFPlugin(InterfaceActionBase):
description = _('Converts to PDF using the Prince software (third-party)')
supported_platforms = ['linux', 'windows']
author = 'Jellby'
version = (1, 4, 4)
version = (1, 5, 0)
minimum_calibre_version = (2, 72, 0)
actual_plugin = 'calibre_plugins.prince_pdf.ui:InterfacePlugin'

Expand Down
5 changes: 5 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from calibre.utils.config import JSONConfig
from calibre_plugins.prince_pdf.texteditwithtooltip import TextEditWithTooltip

try:
unicode = str
except:
pass

load_translations()

prefs = JSONConfig('plugins/prince_pdf')
Expand Down
11 changes: 8 additions & 3 deletions convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from calibre_plugins.prince_pdf.config import prefs
from calibre_plugins.prince_pdf.texteditwithtooltip import TextEditWithTooltip

try:
unicode = str
except:
pass

load_translations()

# This dialog is created after the input book has been unpacked
Expand Down Expand Up @@ -208,7 +213,7 @@ def replace_templates(self, text):
result = SafeFormat().safe_format(match.group(1), self.mi, ('EXCEPTION: '), self.mi)
# Escape quotes, backslashes and newlines
result = re.sub(r'''['"\\]''', r'\\\g<0>', result)
result = re.sub('\n', r'\A ', result)
result = re.sub('\n', r'\\A ', result)
results[match.group(1)] = result
text = text[:match.start(0)] + result + text[match.end(0):]
if DEBUG:
Expand Down Expand Up @@ -238,11 +243,11 @@ def prince_convert(self):
if not exists(base_dir): raise

# Create a temporary CSS file with the box contents
custom_CSS = PersistentTemporaryFile()
custom_CSS = PersistentTemporaryFile(mode='w+')
custom_CSS.write(unicode(self.css1.toPlainText()))
custom_CSS.close()
# Create a temporary file with the list of input files
file_list = PersistentTemporaryFile()
file_list = PersistentTemporaryFile(mode='w+')
for item in self.oeb.spine:
file_list.write(item.href + "\n")
file_list.close()
Expand Down
4 changes: 4 additions & 0 deletions history.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
1.5.0 (2020-11-20)
Python 3 update

1.4.4 (2020-09-19)
Fix saving in different filesystem from the temporary directory
Update translations

1.4.3 (2018-03-11)
Fix resizing of configuration dialog under Windows (contribution from Raffaele Mancuso)
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def convert_to_PDF(self):
self.add_pdf(book_id, pdf_file, ('pdf' in fmts))
else:
self.save_pdf(pdf_file, pdf_base_file)
if DEBUG: print('===========')
return
if DEBUG: print('===========')
return
# No matching format in the book
return error_dialog(self.gui, _('Cannot convert to PDF'), _('No supported format available'), show=True)

Expand Down

0 comments on commit 96c69f2

Please sign in to comment.