def list(self, count=30, order='user_ptime', asc=False, show_dir=True,
             natsort=True):
        """
        List directory contents

        :param int count: number of entries to be listed
        :param str order: order of entries, originally named `o`. This value
            may be one of `user_ptime` (default), `file_size` and `file_name`
        :param bool asc: whether in ascending order
        :param bool show_dir: whether to show directories
        :param bool natsort: whether to use natural sort

        Return a list of :class:`.File` or :class:`.Directory` objects
        """
        if self.cid is None:
            return False
        self.reload()
        kwargs = {}
        # `cid` is the only required argument
        kwargs['cid'] = self.cid
        kwargs['asc'] = 1 if asc is True else 0
        kwargs['show_dir'] = 1 if show_dir is True else 0
        kwargs['natsort'] = 1 if natsort is True else 0
        kwargs['o'] = order

        # When the downloads directory exists along with its parent directory,
        # the receiver directory, its parent's count (receiver directory's
        # count) does not include the downloads directory. This behavior is
        # similar to its parent's parent (root), the count of which does not
        # include the receiver directory.
        # The following code fixed this behavior so that a directory's
        # count correctly reflects the actual number of entries in it
        # The side-effect that this code may ensure that downloads directory
        # exists, causing the system to create the receiver directory and
        # downloads directory, if they do not exist.

        if self.is_root or self == self.api.receiver_directory:
            self._count += 1

        if self.count <= count:
            # count should never be greater than self.count
            count = self.count
        try:
            entries = self._load_entries(func=self.api._req_files,
                                         count=count, page=1, **kwargs)
        # When natsort=1 and order='file_name', API access will fail
        except RequestFailure as e:
            if natsort is True and order == 'file_name':
                entries = \
                    self._load_entries(func=self.api._req_aps_natsort_files,
                                       count=count, page=1, **kwargs)
            else:
                raise e
        res = []
        for entry in entries:
            if 'pid' in entry:
                res.append(_instantiate_directory(self.api, entry))
            else:
                res.append(_instantiate_file(self.api, entry))
        return res
dataset/ETHPy150Open shichao-an/115wangpan/u115/api.py/Directory.list/original