platypush/plugins/file/__init__.py
def list(self, path: str = os.path.abspath(os.sep)) -> List[Dict[str, str]]:
        """
        List a file or all the files in a directory.

        :param path: File or directory (default: root directory).
        :return: List of files in the specified path, or absolute path of the specified path if ``path`` is a file and
            it exists. Each item will contain the fields ``type`` (``file`` or ``directory``) and ``path``.
        """
        path = self._get_path(path)
        assert os.path.exists(path), 'No such file or directory: {}'.format(path)

        if not os.path.isdir(path):
            return [{
                'type': 'file',
                'path': path,
                'name': os.path.basename(path),
            }]

        return sorted(
            [
                {
                    'type': 'directory' if os.path.isdir(os.path.join(path, f)) else 'file',
                    'path': os.path.join(path, f),
                    'name': os.path.basename(f),
                }
                for f in sorted(os.listdir(path))
            ],
            key=lambda f: (f.get('type'), f.get('name'))
        )

        List a file or all the files in a directory.

        :param path: File or directory (default: root directory).
        :return: List of files in the specified path, or absolute path of the specified path if ``path`` is a file and
            it exists. Each item will contain the fields ``type`` (``file`` or ``directory``) and ``path``.
        
List a file or all the files in a directory.
List a file or all the files in a directory .
def list(self, path: str = os.path.abspath(os.sep)) -> List[Dict[str, str]]:
        path = self._get_path(path)
        assert os.path.exists(path), 'No such file or directory: {}'.format(path)
        if not os.path.isdir(path):
            return [{
                'type': 'file',
                'path': path,
                'name': os.path.basename(path),
            }]
        return sorted(
            [
                {
                    'type': 'directory' if os.path.isdir(os.path.join(path, f)) else 'file',
                    'path': os.path.join(path, f),
                    'name': os.path.basename(f),
                }
                for f in sorted(os.listdir(path))
            ],
            key=lambda f: (f.get('type'), f.get('name'))
        )
def list ( self , path : str = os . path . abspath ( os . sep ) ) -> List [ Dict [ str , str ] ] : path = self . _get_path ( path ) assert os . path . exists ( path ) , 'No such file or directory: {}' . format ( path ) if not os . path . isdir ( path ) : return [ { 'type' : 'file' , 'path' : path , 'name' : os . path . basename ( path ) , } ] return sorted ( [ { 'type' : 'directory' if os . path . isdir ( os . path . join ( path , f ) ) else 'file' , 'path' : os . path . join ( path , f ) , 'name' : os . path . basename ( f ) , } for f in sorted ( os . listdir ( path ) ) ] , key = lambda f : ( f . get ( 'type' ) , f . get ( 'name' ) ) )
List a file or all the files in a directory.
List a file or all the files in a directory .
"""
        List a file or all the files in a directory.

        :param path: File or directory (default: root directory).
        :return: List of files in the specified path, or absolute path of the specified path if ``path`` is a file and
            it exists. Each item will contain the fields ``type`` (``file`` or ``directory``) and ``path``.
        """
List of files in the specified path, or absolute path of the specified path if ``path`` is a file and
it exists. Each item will contain the fields ``type`` (``file`` or ``directory``) and ``path``.
List of files in the specified path or absolute path of the specified path if ` ` path ` ` is a file and it exists . Each item will contain the fields ` ` type ` ` ( ` ` file ` ` or ` ` directory ` ` ) and ` ` path ` ` .
self
path
str
File or directory (default: root directory).
File or directory ( default : root directory ) .