[Checkins] SVN: zopyx.convert2/trunk/ support for commandlineoptions.txt for the Calibre converter

Andreas Jung andreas at andreas-jung.com
Sun Apr 3 09:00:26 EDT 2011


Log message for revision 121209:
  support for commandlineoptions.txt for the Calibre converter
  

Changed:
  U   zopyx.convert2/trunk/CHANGES.txt
  U   zopyx.convert2/trunk/setup.py
  U   zopyx.convert2/trunk/src/zopyx/convert2/calibre.py

-=-
Modified: zopyx.convert2/trunk/CHANGES.txt
===================================================================
--- zopyx.convert2/trunk/CHANGES.txt	2011-04-03 10:30:52 UTC (rev 121208)
+++ zopyx.convert2/trunk/CHANGES.txt	2011-04-03 13:00:25 UTC (rev 121209)
@@ -1,3 +1,7 @@
+2.2.5 (2011-04-03)
+==================
+- calibre converter now honors the commandlineoptions.txt file
+
 2.2.4 (2010-12-16)
 ==================
 - stripping of BASE tag for XFC-based converters 

Modified: zopyx.convert2/trunk/setup.py
===================================================================
--- zopyx.convert2/trunk/setup.py	2011-04-03 10:30:52 UTC (rev 121208)
+++ zopyx.convert2/trunk/setup.py	2011-04-03 13:00:25 UTC (rev 121209)
@@ -12,7 +12,7 @@
     'Programming Language :: Python',
 ]
 
-version = '2.2.4'
+version = '2.2.5'
 
 desc = unicode(file('README.txt').read().strip(), 'utf-8')
 changes = file('CHANGES.txt').read().strip()

Modified: zopyx.convert2/trunk/src/zopyx/convert2/calibre.py
===================================================================
--- zopyx.convert2/trunk/src/zopyx/convert2/calibre.py	2011-04-03 10:30:52 UTC (rev 121208)
+++ zopyx.convert2/trunk/src/zopyx/convert2/calibre.py	2011-04-03 13:00:25 UTC (rev 121209)
@@ -22,7 +22,7 @@
 
 calibre_available = _check_calibre()
 
-def html2calibre(html_filename, output_filename=None, **calibre_options):
+def html2calibre(html_filename, output_filename=None, cmdopts='', **calibre_options):
     """ Convert a HTML file using calibre """
 
     if not html_filename.endswith('.html'):
@@ -45,7 +45,9 @@
     if sys.platform == 'win32':
         raise NotImplementedError('No support for using Calibre on Windows available')
     else:
-        cmd = '"ebook-convert" "%s" "%s" %s' % (html_filename, output_filename, ' '.join(options))
+        options = ' '.join(options)
+        options = options + ' ' + cmdopts
+        cmd = '"ebook-convert" "%s" "%s" %s' % (html_filename, output_filename, options)
     
     status, output = runcmd(cmd)
     if status != 0:
@@ -68,8 +70,15 @@
         return calibre_available
 
     def convert(self, output_filename=None, **calibre_options):
+    
+        # check for commandlineoptions.txt file
+        cmdopts = '' 
+        cmdopts_filename = os.path.join(os.path.dirname(self.filename), 'commandlineoptions.txt')
+        if os.path.exists(cmdopts_filename):
+            cmdopts = file(cmdopts_filename).read()
+
         tidy_filename = tidyhtml(self.filename, self.encoding)
-        result = html2calibre(tidy_filename, output_filename, **calibre_options)
+        result = html2calibre(tidy_filename, output_filename, cmdopts=cmdopts, **calibre_options)
         os.unlink(tidy_filename)
         return result
 



More information about the checkins mailing list