mlnext.io.get_files#
- mlnext.io.get_files(path: str, *, name: str = '*', ext: str = '*', absolute: bool = False) List[str] [source]#
T.List all files in path with extension ext.
- Parameters:
path (str) – Path of the directory.
ext (str) – File extension (without dot).
name (str) – Pattern for the name of the files to appear in the result.
absolute (bool) – Whether to return the absolute path or only the filenames.
- Raises:
ValueError – Raised if path is not a directory.
- Returns:
Returns a list of files with extension ext in path.
- Return type:
T.List[str]
Example
>>> # lists all files in dir >>> get_files(path='./resources/tasks', ext='json') ['task.json']
>>> # get all files named task >>> get_files(path='./resources/tasks', name='task') ['task.json', 'task.yaml']
>>> # get the absolute path of the files >>> get_files(path='.resources/tasks', ext='json', ... absolute=True) ['.../resources/tasks/task.json']