Selaa lähdekoodia

do not break compilation if pdf options aren't provided. Refs #77

The previous code was fetching settings from the configuration file without
checking first whether those settings existed.

Since rst2pdf *can* work without one having to provide them, the right thing to
do is to just accept their absence.
Renato Cunha 9 vuotta sitten
vanhempi
commit
b1ccac54b2
1 muutettua tiedostoa jossa 12 lisäystä ja 4 poistoa
  1. 12 4
      pdf/pdf.py

+ 12 - 4
pdf/pdf.py

@@ -24,11 +24,19 @@ class PdfGenerator(Generator):
     def __init__(self, *args, **kwargs):
         super(PdfGenerator, self).__init__(*args, **kwargs)
 
-        pdf_style_path = os.path.join(self.settings['PDF_STYLE_PATH'])
-        pdf_style = self.settings['PDF_STYLE']
+        if 'PDF_STYLE_PATH' in self.settings:
+            pdf_style_path = [self.settings['PDF_STYLE_PATH']]
+        else:
+            pdf_style_path = []
+
+        if 'PDF_STYLE' in self.settings:
+            pdf_style = [self.settings['PDF_STYLE']]
+        else:
+            pdf_style = []
+
         self.pdfcreator = RstToPdf(breakside=0,
-                                   stylesheets=[pdf_style],
-                                   style_path=[pdf_style_path])
+                                   stylesheets=pdf_style,
+                                   style_path=pdf_style_path)
 
     def _create_pdf(self, obj, output_path):
         if obj.source_path.endswith('.rst'):