nitpick.generic module
Generic functions and classes.
- nitpick.generic.filter_names(iterable: Iterable, *partial_names: str) list[str] [source]
Filter names and keep only the desired partial names.
Exclude the project name automatically.
>>> file_list = ['requirements.txt', 'tox.ini', 'setup.py', 'nitpick'] >>> filter_names(file_list) ['requirements.txt', 'tox.ini', 'setup.py'] >>> filter_names(file_list, 'ini', '.py') ['tox.ini', 'setup.py']
>>> mapping = {'requirements.txt': None, 'tox.ini': 1, 'setup.py': 2, 'nitpick': 3} >>> filter_names(mapping) ['requirements.txt', 'tox.ini', 'setup.py'] >>> filter_names(file_list, 'x') ['requirements.txt', 'tox.ini']
- nitpick.generic.get_global_gitignore_path() Path | None [source]
Get the path to the global Git ignore file.
- nitpick.generic.glob_files(dir_: Path, file_patterns: Iterable[str]) set[pathlib.Path] [source]
Search a directory looking for file patterns.
- nitpick.generic.glob_non_ignored_files(root_dir: Path, pattern: str = '**/*') Iterable[Path] [source]
Glob all files in the root dir that are not ignored by Git.
- nitpick.generic.relative_to_current_dir(path_or_str: PathOrStr | None) str [source]
Return a relative path to the current dir or an absolute path.
- nitpick.generic.url_to_python_path(url: furl) Path
Convert the segments of a file URL to a path.