def setup(pelican): dest = os.path.join( pelican.output_path, 'static', 'jwidget', '' ) data_path = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'data' ) if not os.path.isdir(dest): try: log.info('copying {s} to {d}'.format( s=data_path, d=dest ) ) shutil.copytree(data_path, dest) except Exception, e: log.error('Cannot copy "{s}" to "{d}"'.format( s=data_path, d=dest ) ) log.error('The Jamendo plugin will be disabled...') return None
def is_valid_content(content, f): try: content.check_properties() return True except NameError, e: error(u"Skipping %s: impossible to find informations about '%s'"\ % (f, e)) return False
def generate_context(self): all_pages = [] for f in self.get_files(os.sep.join((self.path, 'pages'))): try: content, metadata = read_file(f) except Exception, e: error(u'Could not process %s\n%s' % (f, str(e))) continue page = Page(content, metadata, settings=self.settings, filename=f) if not is_valid_content(page, f): continue all_pages.append(page)
def generate_output(self, writer=None): # we don't use the writer passed as argument here # since we write our own files info(u' Generating PDF files...') pdf_path = os.path.join(self.output_path, 'pdf') if not os.path.exists(pdf_path): try: os.mkdir(pdf_path) except OSError: error("Couldn't create the pdf output folder in " + pdf_path) pass for article in self.context['articles']: self._create_pdf(article, pdf_path) for page in self.context['pages']: self._create_pdf(page, pdf_path)