def determine_filename(self, infohash): # THIS FUNCTION IS PARTICULARLY CONVOLUTED. BLECH! --Dave path, metainfo = self.torrent_cache[infohash] path = efs2(path) name = metainfo.name_fs savein = efs2(self.config['save_in']) isdir = metainfo.is_batch style = self.config['saveas_style'] if style == 4: torrentname = os.path.split(path[:-8])[1] suggestedname = name if torrentname == suggestedname: style = 1 else: style = 3 if style == 1 or style == 3: if savein: file = os.path.basename(path) saveas= \ os.path.join(savein, file[:-8]) #strip '.torrent' else: saveas = path[:-8] # strip '.torrent' if style == 3 and not isdir: saveas = os.path.join(saveas, name) else: if savein: saveas = os.path.join(savein, name) else: saveas = os.path.join(os.path.split(path)[0], name) return saveas
def determine_filename(self, infohash): path, metainfo = self.torrent_cache[infohash] # path already fs encoded name = metainfo.name_fs savein = efs2(self.config['save_in']) # From here save_in is /home/dave/Desktop/... # rather than /home/dave/testlaunch isdir = metainfo.is_batch style = self.config['saveas_style'] if style == 4: torrentname = os.path.split(path[:-8])[1] suggestedname = name if torrentname == suggestedname: style = 1 else: style = 3 if style == 1 or style == 3: if savein: file = os.path.basename(path) saveas= \ os.path.join(savein,efs2(file[:-8])) #strip '.torrent' else: saveas = path[:-8] # strip '.torrent' if style == 3 and not isdir: saveas = os.path.join(saveas, name) else: if savein: saveas = os.path.join(savein, name) else: saveas = os.path.join(os.path.split(path)[0], name) return saveas
def join(*args): fsargs = [efs2(arg) for arg in args] os.path.join(*fsargs)
def commonprefx(pathlist): fslist = [efs2(path) for path in pathlist] return decode_from_filesystem(os.path.commonprefix(fslist))
def realpath(path): fspath = efs2(path) return decode_from_filesystem(os.path.realpath(fspath))
def normpath(path): fspath = efs2(path) return decode_from_filesystem(os.path.normpath(fspath))
def basename(path): fspath = efs2(path) return decode_from_filesystem(os.path.basename(fspath))
def isfile(path): fspath = efs2(path) return os.path.isfile(fspath)
def isdir(path): fspath = efs2(path) return os.path.isdir(fspath)
def getsize(path): fspath = efs2(path) return os.path.getsize(fspath)
def getmtime(path): fspath = efs2(path) return os.path.getmtime(fspath)
def exists(path): fspath = efs2(path) return os.path.exists(fspath)