Example #1
0
    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
Example #3
0
def join(*args):
    fsargs = [efs2(arg) for arg in args]
    os.path.join(*fsargs)
Example #4
0
def commonprefx(pathlist):
    fslist = [efs2(path) for path in pathlist]
    return decode_from_filesystem(os.path.commonprefix(fslist))
Example #5
0
def realpath(path):
    fspath = efs2(path)
    return decode_from_filesystem(os.path.realpath(fspath))
Example #6
0
def normpath(path):
    fspath = efs2(path)
    return decode_from_filesystem(os.path.normpath(fspath))
Example #7
0
def basename(path):
    fspath = efs2(path)
    return decode_from_filesystem(os.path.basename(fspath))
Example #8
0
def isfile(path):
    fspath = efs2(path)
    return os.path.isfile(fspath)
Example #9
0
def isdir(path):
    fspath = efs2(path)
    return os.path.isdir(fspath)
Example #10
0
def getsize(path):
    fspath = efs2(path)
    return os.path.getsize(fspath)
Example #11
0
def getmtime(path):
    fspath = efs2(path)
    return os.path.getmtime(fspath)
Example #12
0
def exists(path):
    fspath = efs2(path)
    return os.path.exists(fspath)