endswith can take a list as an argument ;)

This commit is contained in:
Alexis Métaireau 2013-03-06 11:46:17 -08:00
commit 964f7d96d6

View file

@ -94,8 +94,7 @@ class Generator(object):
if extensions is None:
extensions = self.markup
basename = os.path.basename(path)
if extensions is False or \
(True in [basename.endswith(ext) for ext in extensions]):
if extensions is False or basename.endswith(extensions):
return True
return False
@ -150,8 +149,8 @@ class _FileLoader(BaseLoader):
mtime = os.path.getmtime(self.fullpath)
with open(self.fullpath, 'r', encoding='utf-8') as f:
source = f.read()
return source, self.fullpath, \
lambda: mtime == os.path.getmtime(self.fullpath)
return (source, self.fullpath,
lambda: mtime == os.path.getmtime(self.fullpath))
class TemplatePagesGenerator(Generator):
@ -551,12 +550,14 @@ class PdfGenerator(Generator):
super(PdfGenerator, self).__init__(*args, **kwargs)
try:
from rst2pdf.createpdf import RstToPdf
pdf_style_path = os.path.join(self.settings['PDF_STYLE_PATH']) \
if 'PDF_STYLE_PATH' in self.settings.keys() \
else ''
pdf_style = self.settings['PDF_STYLE'] if 'PDF_STYLE' \
in self.settings.keys() \
else 'twelvepoint'
if 'PDF_STYLE_PATH' in self.settings.keys():
pdf_style_path = os.path.join(self.settings['PDF_STYLE_PATH'])
else:
pdf_style_path = ''
if 'PDF_STYLE' in self.settings.keys():
pdf_style = self.settings.get('PDF_STYLE', 'twelvepoint')
self.pdfcreator = RstToPdf(breakside=0,
stylesheets=[pdf_style],
style_path=[pdf_style_path])