clean unused and non-working methods
[librarian.git] / librarian / pdf.py
index 9308704..7889a22 100644 (file)
@@ -173,14 +173,16 @@ def package_available(package, args='', verbose=False):
     return p == 0
 
 
     return p == 0
 
 
+# not used
 def load_including_children(wldoc=None, provider=None, uri=None):
     """ Makes one big xml file with children inserted at end.
 def load_including_children(wldoc=None, provider=None, uri=None):
     """ Makes one big xml file with children inserted at end.
-    
+
     Either wldoc or provider and URI must be provided.
     """
 
     if uri and provider:
         f = provider.by_uri(uri)
     Either wldoc or provider and URI must be provided.
     """
 
     if uri and provider:
         f = provider.by_uri(uri)
+        # WTF DocProvider.by_uri() returns IOFile, so no .read() there
         text = f.read().decode('utf-8')
         f.close()
     elif wldoc is not None:
         text = f.read().decode('utf-8')
         f.close()
     elif wldoc is not None:
@@ -203,7 +205,7 @@ def load_including_children(wldoc=None, provider=None, uri=None):
 
 class PDFFormat(Format):
     """ Base PDF format.
 
 class PDFFormat(Format):
     """ Base PDF format.
-    
+
     Available customization:
         nofootnotes: Doesn't do footnotes.
         nothemes: Doesn't do themes.
     Available customization:
         nofootnotes: Doesn't do footnotes.
         nothemes: Doesn't do themes.
@@ -229,29 +231,8 @@ class PDFFormat(Format):
         """ For use in XSLT. """
         return u','.join(k for k, v in self.customization.items() if v)
 
         """ For use in XSLT. """
         return u','.join(k for k, v in self.customization.items() if v)
 
-    def get_document(self):
-        document = load_including_children(self.wldoc)
-        root = document.edoc.getroot()
-        root.set('editors', u', '.join(sorted(
-            editor.readable() for editor in document.editors())))
-
-        # hack the tree
-        move_motifs_inside(document.edoc)
-        hack_motifs(document.edoc)
-        parse_creator(document.edoc)
-        substitute_hyphens(document.edoc)
-        fix_hanging(document.edoc)
-        return document
-
     def get_texml(self):
     def get_texml(self):
-        style_filename = get_stylesheet("wl2tex")
-        functions.reg_get(self)
-        try:
-            style = etree.parse(style_filename)
-            texml = self.get_document().transform(style)
-            return texml
-        except (XMLSyntaxError, XSLTApplyError), e:
-            raise ParseError(e)
+        raise NotImplementedError
 
     def get_tex_dir(self):
         texml = self.get_texml()
 
     def get_tex_dir(self):
         texml = self.get_texml()
@@ -265,6 +246,9 @@ class PDFFormat(Format):
         # Copy style
         shutil.copy(get_resource('pdf/wl.cls'), temp)
         shutil.copy(self.style, os.path.join(temp, 'style.sty'))
         # Copy style
         shutil.copy(get_resource('pdf/wl.cls'), temp)
         shutil.copy(self.style, os.path.join(temp, 'style.sty'))
+        #for sfile in ['wasysym.sty', 'uwasyvar.fd', 'uwasy.fd']:
+        #    shutil.copy(get_resource(os.path.join('res/wasysym', sfile)), temp)
+
         # Save attachments
         if self.cover:
             self.cover.for_pdf().dump_to(os.path.join(temp, 'makecover.sty'))
         # Save attachments
         if self.cover:
             self.cover.for_pdf().dump_to(os.path.join(temp, 'makecover.sty'))
@@ -287,7 +271,7 @@ class PDFFormat(Format):
                 p = call(['xelatex', '-interaction=batchmode', tex_path],
                             stdout=PIPE, stderr=PIPE)
         if p:
                 p = call(['xelatex', '-interaction=batchmode', tex_path],
                             stdout=PIPE, stderr=PIPE)
         if p:
-            raise ParseError("Error parsing .tex file")
+            raise ParseError("Error parsing .tex file: %s" % tex_path)
 
         if cwd is not None:
             os.chdir(cwd)
 
         if cwd is not None:
             os.chdir(cwd)
@@ -303,7 +287,7 @@ class PDFFormat(Format):
         """
         self.verbose = verbose
         self.save_tex = save_tex
         """
         self.verbose = verbose
         self.save_tex = save_tex
-        
+
         if morefloats is None and package_available('morefloats', 'maxfloats=19'):
             morefloats = 'new'
         self.morefloats = morefloats
         if morefloats is None and package_available('morefloats', 'maxfloats=19'):
             morefloats = 'new'
         self.morefloats = morefloats