def load_hashfile(self, uri): # load hashfile files_to_add = [] self.format = self.get_hashfile_format(uri) if not self.format: log("unknown format") return log("Detected format: " + self.format.name) # load content uri = vfs_clean_uri(uri) content = gnomevfs.read_entire_file(uri) lines = content.split("\n") list = self.format.read_file(lines) root = os.path.dirname(uri) for hash, file in list: absfile = os.path.join(root, file) u = gnomevfs.escape_host_and_path_string(absfile) files_to_add.append((u, file, hash)) # reset hashfile #self.new_hashfile() # do add the files to list for f in files_to_add: self.files.append(File(f[0], f[1], f[2])) self.filename = uri self.update_hashfile() self.update_ui() self.update_and_check_file_list() return True
def load_hashfile(self, uri): # load hashfile files_to_add=[] self.format=self.get_hashfile_format(uri) if not self.format: log("unknown format") return log("Detected format: " + self.format.name) # load content uri = vfs_clean_uri(uri) content = gnomevfs.read_entire_file(uri) lines = content.split("\n") list = self.format.read_file(lines) root = os.path.dirname(uri) for hash, file in list: absfile = os.path.join(root, file) u = gnomevfs.escape_host_and_path_string(absfile) files_to_add.append( (u, file, hash) ) # reset hashfile #self.new_hashfile() # do add the files to list for f in files_to_add: self.files.append(File(f[0], f[1], f[2])) self.filename=uri self.update_hashfile() self.update_ui() self.update_and_check_file_list() return True
def vfs_clean_uri(uri): """return an uri from an uri or a local path""" try: gnomevfs.URI(uri) gnomevfs.Handle(uri) except : #gnomevfs.InvalidURIError: # maybe a local path ? local = os.path.abspath(uri) if os.path.exists(local): uri = gnomevfs.get_uri_from_local_path(local) uri = gnomevfs.escape_host_and_path_string(uri) return uri
def vfs_clean_uri(uri): """return an uri from an uri or a local path""" try: gnomevfs.URI(uri) gnomevfs.Handle(uri) except: #gnomevfs.InvalidURIError: # maybe a local path ? local = os.path.abspath(uri) if os.path.exists(local): uri = gnomevfs.get_uri_from_local_path(local) uri = gnomevfs.escape_host_and_path_string(uri) return uri
def vfs_clean_uri(uri): """return an uri from an uri or a local path""" try: gnomevfs.URI(uri) gnomevfs.Handle(uri) except: #gnomevfs.InvalidURIError: try: uri_ = uri.replace('%5C', '/') # convert backslashes gnomevfs.URI(uri_) gnomevfs.Handle(uri_) uri = uri_ except: #gnomevfs.InvalidURIError: # maybe a local path ? local = os.path.abspath(uri) if os.path.exists(local): uri = gnomevfs.get_uri_from_local_path(local) uri = gnomevfs.escape_host_and_path_string(uri) return uri
def vfs_clean_uri(uri): """return an uri from an uri or a local path""" try: gnomevfs.URI(uri) gnomevfs.Handle(uri) except : #gnomevfs.InvalidURIError: try: uri_ = uri.replace('%5C', '/') # convert backslashes gnomevfs.URI(uri_) gnomevfs.Handle(uri_) uri = uri_ except : #gnomevfs.InvalidURIError: # maybe a local path ? local = os.path.abspath(uri) if os.path.exists(local): uri = gnomevfs.get_uri_from_local_path(local) uri = gnomevfs.escape_host_and_path_string(uri) return uri
def escape_host_path(host_path): return gnomevfs.escape_host_and_path_string(host_path)