Files in torrent.

        List of namedtuples (filepath, size).

        :rtype: list[TorrentFile]
190817
def files(self):
        
        files = []
        info = self._struct.get('info')

        if not info:
            return files

        if 'files' in info:
            base = info['name']

            for f in info['files']:
                files.append(TorrentFile(join(base, *f['path']), f['length']))

        else:
            files.append(TorrentFile(info['name'], info['length']))

        return files
338858
def pages(self, page_from, page_to):
        
        if not all([page_from < self.url.max_page, page_from > 0,
                    page_to <= self.url.max_page, page_to > page_from]):
            raise IndexError("Invalid page numbers")

        size = (page_to + 1) - page_from
        threads = ret = []
        page_list = range(page_from, page_to+1)

        locks = [threading.Lock() for i in range(size)]

        for lock in locks[1:]:
            lock.acquire()

        def t_function(pos):
            """
            Thread function that fetch page for list of torrents
            """
            res = self.page(page_list[pos]).list()
            locks[pos].acquire()
            ret.extend(res)
            if pos != size-1:
                locks[pos+1].release()

        threads = [threading.Thread(target=t_function, args=(i,))
                   for i in range(size)]

        for thread in threads:
            thread.start()

        for thread in threads:
            thread.join()

        for torrent in ret:
            yield torrent
1191155
def loadedFilenames( self ):
        
        output = []
        for i in range(self.uiContentsTREE.topLevelItemCount()):
            item = self.uiContentsTREE.topLevelItem(i)
            output.append(nativestring(item.filepath()))
        return output
813654
def as_named_tuple(self):
        
        keys = list(self.entities.keys())
        replaced = []
        for i, k in enumerate(keys):
            if iskeyword(k):
                replaced.append(k)
                keys[i] = '%s_' % k
        if replaced:
            safe = ['%s_' % k for k in replaced]
            warnings.warn("Entity names cannot be reserved keywords when "
                          "representing a File as a namedtuple. Replacing "
                          "entities %s with safe versions %s." % (keys, safe))
        entities = dict(zip(keys, self.entities.values()))
        _File = namedtuple('File', 'filename ' + ' '.join(entities.keys()))
        return _File(filename=self.path, **entities)
604050
def local_list(timestamps=True):
    
    init_storage()
    lst = []
    for d in glob(os.path.join(DICTS_PATH, '*.txt')):
        name = d.split('/')[-1].replace('.txt', '')
        lst.append((name, os.path.getmtime(d)) if timestamps else name)

    return lst
775416
def parse_torrent_file(torrent):
    """"""
    link_re = re.compile(r'^(http?s|ftp)')
    if link_re.match(torrent):
        response = requests.get(torrent, headers=HEADERS, timeout=20)
        data = parse_torrent_buffer(response.content)
    elif os.path.isfile(torrent):
        with open(torrent, 'rb') as f:
            data = parse_torrent_buffer(f.read())
    else:
        data = None
    return data
1231295
def list(self, path=None, with_metadata=False, include_partitions=False):
        ''''''
        import json

        sub_path = self.prefix + '/' + path.strip('/') if path else self.prefix

        l = {}

        for e in self.bucket.list(sub_path):

            path = e.name.replace(self.prefix, '', 1).strip('/')
            if path.startswith('_') or path.startswith('meta'):
                continue

            # TODO 'include_partitions' doesn't make any sense outside of ambry
            if not include_partitions and path.count('/') > 1:
                continue  # partition files

            if with_metadata:
                d = self.metadata(path)
                if d and 'identity' in d:
                    d['identity'] = json.loads(d['identity'])
            else:
                d = {}

            d['caches'] = [self.repo_id]

            if path:
                l[path] = d

        return l
1061618
def _load_torrents_directory(self):
        
        r = self._req_lixian_get_id(torrent=True)
        self._downloads_directory = self._load_directory(r['cid'])
839446
def list(self, path=None, with_metadata=False):
        ''''''

        path = path.strip('/') if path else ''

        if self.upstream:
            return self.upstream.list(path, with_metadata=with_metadata)
        else:
            raise NotImplementedError()
783646
def load_file_to_list(self):
        
        lst = []
        try:
            with open(self.fullname, 'r') as f:
                for line in f:
                    lst.append(line) 
            return lst  
        except IOError:
            return lst
1136679
def buildlist(self, category=tpb.CATEGORIES.VIDEO.TV_SHOWS, limit=1000):
        

        try:
            s = self.source.search(self.title.lower(), limit)
        except Exception as e:
            logging.error("Can not send search request to the t411 server")
            logging.error(e.message)
            sys.exit(1)
        

        try:
            for t in s.items():
                pass
        except:
            logging.error("t411 server returned an invalid result")
            sys.exit(1)

        torrentlist = []
        for torrent in s['torrents']:
            if isinstance(torrent, dict):    
                #logging.debug("Compare regex to: %s" % t.title.lower())
                if (re.search(self.regexp, torrent['name'].lower()) and (int(torrent['seeders']) >= self.seeders_min)):
                    # logging.debug("Matched")
                    torrentlist.append((torrent['name'], torrent['seeders'], torrent['id']))

        logging.debug("Found %d matching items " % (len(torrentlist)))

        # Return the list
        return torrentlist
683852
public List<TorrentHandle> torrents() {
        torrent_handle_vector v = s.get_torrents();
        int size = (int) v.size();

        ArrayList<TorrentHandle> l = new ArrayList<>(size);

        for (int i = 0; i < size; i++) {
            l.add(new TorrentHandle(v.get(i)));
        }

        return l;
    }
939893
def listdir(self, path='.'):
        
        self._connect()

        if self.sftp:
            contents = self._sftp_listdir(path)
        else:
            contents = self._ftp_listdir(path)

        self._close()

        return contents
404123
def list(self, remote='.', extra=False, remove_relative_paths=False):
        
        if extra:
            self.tmp_output = []
            self.conn.dir(remote, self._collector)
            directory_list = split_file_info(self.tmp_output)
        else:
            directory_list = self.conn.nlst(remote)

        if remove_relative_paths:
            return list(filter(self.is_not_relative_path, directory_list))

        return directory_list
1021322
def filepaths(self):
        
        if self.path is not None:
            yield from utils.filepaths(self.path, exclude=self.exclude,
                                       hidden=False, empty=False)
474166
def pathNames(self) -> [str]:
        

        return [f.pathName for f in list(self._files.values())]
1061889
def make_file_list(upload_path):
   
   newlist = []
   for el in sorted(os.listdir(upload_path)):
      if ' ' in el:
         raise Exception('Error: Spaces are not allowed in file names!\n')
      newlist.append(os.path.normpath(upload_path+'/'+el))
   debug.log('InputFiles: %s\n'%newlist)
   return newlist