def __init__(self, msg): Error.__init__(self, msg) self.parser_file = _( '<Unknown>') # T: placeholder for unknown file name self.parser_text = '' self.parser_line_offset = (0, 0)
def __init__(self, path): '''Constructor @param path: an absolute file path, file URL, L{FilePath} object or a list of path elements. When a list is given, the first element is allowed to be an absolute path, URL or L{FilePath} object as well. ''' self._serialized = None if isinstance(path, FilePath): self.path = path.path return try: if isinstance(path, (list, tuple)): path = list(map(str, path)) # Flatten objects - strings should be unicode or ascii already path = SEP.join(path) # os.path.join is too intelligent for it's own good # just join with the path separator. else: path = str(path) # make sure we can decode except UnicodeDecodeError: raise Error( 'BUG: invalid input, file names should be in ascii, or given as unicode' ) if path.startswith('file:/'): path = self._parse_uri(path) elif path.startswith('~'): path = _os_expanduser(path) self._set_path(path) # overloaded in WindowsPath
def __init__(self, path): path = path.path if hasattr(path, 'path') else path Error.__init__(self, 'Folder not empty: %s' % path)
def __init__(self, path): self.file = path path = path.path if hasattr(path, 'path') else path Error.__init__(self, 'No permission to write file: %s' % path)
def __init__(self, path): self.file = path path = path.path if hasattr(path, 'path') else path Error.__init__(self, 'File changed on disk: %s' % path)
def __init__(self, path): self.file = path path = path.path if hasattr(path, 'path') else path Error.__init__(self, 'File or folder already exists: %s' % path)
def __init__(self, path): self.file = path path = path.path if hasattr(path, 'path') else path Error.__init__(self, 'No such file or folder: %s' % path)
def get_exporter(self, page): from zim.fs import File, Dir from zim.export import \ build_mhtml_file_exporter, \ build_single_file_exporter, \ build_page_exporter, \ build_notebook_exporter format = self.opts.get('format', 'html') if not 'output' in self.opts: raise UsageError(_('Output location needed for export') ) # T: error in export command output = Dir(self.opts['output']) if not output.isdir(): output = File(self.opts.get('output')) template = self.opts.get('template', 'Default') if output.exists() and not self.opts.get('overwrite'): if output.isdir(): if len(output.list()) > 0: raise Error( _('Output folder exists and not empty, specify "--overwrite" to force export' )) # T: error message for export else: pass else: raise Error( _('Output file exists, specify "--overwrite" to force export' )) # T: error message for export if format == 'mhtml': self.ignore_options('index-page') if output.isdir(): raise UsageError(_('Need output file to export MHTML') ) # T: error message for export exporter = build_mhtml_file_exporter( output, template, document_root_url=self.opts.get('root-url'), ) elif page: self.ignore_options('index-page') if output.exists() and output.isdir(): ext = 'html' output = output.file(page.basename) + '.' + ext if self.opts.get('singlefile'): exporter = build_single_file_exporter( output, format, template, namespace=page, document_root_url=self.opts.get('root-url'), ) else: exporter = build_page_exporter( output, format, template, page, document_root_url=self.opts.get('root-url'), ) else: if not output.exists(): output = Dir(output.path) elif not output.isdir(): raise UsageError( _('Need output folder to export full notebook') ) # T: error message for export exporter = build_notebook_exporter( output, format, template, index_page=self.opts.get('index-page'), document_root_url=self.opts.get('root-url'), ) return exporter
def __init__(self): Error.__init__(self, _('Please select more than one line of text'))
def __init__(self, path): Error.__init__(self, _('File path too long: %s') % path)
def __init__(self, basename): Error.__init__(self, _('File name too long: %s') % basename)
def __init__(self, msg): Error.__init__(self, msg) self.parser_file = _('<Unknown>') # T: placeholder for unknown file name self.parser_text = '' self.parser_line_offset = (0, 0)