Example #1
0
    def cmd_export(self, format="html", template=None, page=None, output=None, root_url=None, index_page=None):
        """Convenience method hat wraps L{zim.exporter.Exporter} for
        commandline export

        @keyword format: the format name
        @keyword template: the template path or name
        @keyword page: the page name or C{None} to export the full notebook
        @keyword output: the output folder or C{None} to print to stdout
        @keyword root_url: the url to map the document root if any
        @keyword index_page: the index page name if any
        """
        import zim.exporter

        exporter = zim.exporter.Exporter(
            self.notebook, format, template, document_root_url=root_url, index_page=index_page
        )

        if page:
            path = self.notebook.resolve_path(page)
            page = self.notebook.get_page(path)

        if page and output is None:
            exporter.export_page_to_fh(sys.stdout, page)
        elif not output:
            logger.error("Need output directory to export notebook")
        else:
            dir = Dir(output)
            if page:
                exporter.export_page(dir, page)
            else:
                self.notebook.index.update()
                exporter.export_all(dir)
Example #2
0
File: main.py Project: gdw2/zim
	def run(self):
		import zim.exporter
		import zim.fs

		notebook, page = self.build_notebook()
		exporter = zim.exporter.Exporter(
			notebook,
			format=self.opts.get('format', 'html'),
			template=self.opts.get('template', 'Default'),
			document_root_url=self.opts.get('root-url'),
			index_page=self.opts.get('index-page'),
		)

		if page:
			page = notebook.get_page(page)

		if self.opts.get('output'):
			dir = zim.fs.Dir(self.opts.get('output'))
			if page:
				exporter.export_page(dir, page)
			else:
				notebook.index.update()
				exporter.export_all(dir)
		elif page:
			exporter.export_page_to_fh(sys.stdout, page)
		else:
			raise UsageError, 'Need output directory to export notebook'
Example #3
0
	def cmd_export(self, format='html', template=None, page=None, output=None, root_url=None):
		'''Method called when doing a commandline export'''
		import zim.exporter
		exporter = zim.exporter.Exporter(self.notebook, format, template, document_root_url=root_url)

		if page:
			path = self.notebook.resolve_path(page)
			page = self.notebook.get_page(path)

		if page and output is None:
			import sys
			exporter.export_page_to_fh(sys.stdout, page)
		elif not output:
			logger.error('Need output directory to export notebook')
		else:
			dir = Dir(output)
			if page:
				exporter.export_page(dir, page)
			else:
				self.notebook.index.update()
				exporter.export_all(dir)