def do_response_ok(self): self.uistate['format'] = self.inputs['format'].get_active_text() self.uistate['template'] = self.inputs['template'].get_active_text() self.uistate['template_file'] = self.inputs['template_file'].get_filename() self.uistate['output_folder'] = self.inputs['output_folder'].get_filename() self.uistate['index_page'] = self.inputs['index_page'].get_text() self.uistate['document_root_url'] = self.inputs['document_root_url'].get_text() self.uistate['use_document_root_url'] = self.use_document_root_url.get_active() for k in ('format', 'template', 'output_folder'): if not self.uistate[k]: # ignore empty string as well logger.warn('Option %s not set', k) return False dir = Dir(self.uistate['output_folder']) if dir.exists() and len(dir.list()) > 0: ok = QuestionDialog(self, ( _('Folder exists'), # T: message heading _('Folder already exists and has content, ' 'exporting to this folder may overwrite ' 'exisitng files. ' 'Do you want to continue?' ) # T: detailed message, answers are Yes and No ) ).run() if not ok: return False options = {} for k in ('format', 'template', 'index_page'): if self.uistate[k] and not self.uistate[k].isspace(): options[k] = self.uistate[k] if options['template'] == _('Other...'): options['template'] = self.uistate['template_file'] if not options['template'] or options['template'].isspace(): ErrorDialog(self, _('Please specify a template')).run() # T: error message when input for export dialog not OK return False if self.uistate['use_document_root_url']: options['document_root_url'] = self.uistate['document_root_url'] if not options['document_root_url'] or options['document_root_url'].isspace(): ErrorDialog(self, _('Please specify a URL for the document root')).run() # T: error message when input for export dialog not OK return False exporter = Exporter(self.ui.notebook, **options) dialog = ProgressBarDialog(self, _('Exporting notebook')) # T: Title for progressbar window dialog.show_all() exporter.export_all(dir, callback=lambda p: dialog.pulse(p.name)) dialog.destroy() return True
def do_response_ok(self): #~ import pprint #~ pprint.pprint(self.uistate) #~ return True options = {} for k in ('format', 'template', 'index_page'): if self.uistate[k] and not self.uistate[k].isspace(): options[k] = self.uistate[k] options['format'] = \ zim.formats.canonical_name(options['format']) if options['template'] == '__file__': options['template'] = self.uistate['template_file'] if self.uistate['document_root_url'] == 'url': options['document_root_url'] = self.uistate['document_root_url'] try: exporter = Exporter(self.ui.notebook, **options) except Exception, error: ErrorDialog(self, error).run() return False
def export(self): notebook = get_test_notebook() notebook.get_store(Path(':')).dir = Dir('/foo/bar') # fake source dir notebook.index.update() exporter = Exporter(notebook, **self.options) exporter.export_all(self.dir)
def export(self): notebook = tests.new_notebook(fakedir='/foo/bar') exporter = Exporter(notebook, **self.options) exporter.export_all(self.dir)