A utility for recursively listing and saving the content of source code files
Project description
[](https://codecov.io/gh/michalsi/lister)
[](https://github.com/michalsi/lister/actions/workflows/ci.yml)
Files Lister is a Python utility for recursively listing and saving the content of source code files in a directory structure.
It provides flexible options for including or excluding files based on various criteria.
## Features
- Recursively list files in a directory structure
- Include or exclude hidden files and directories
- Filter files by extension
- Skip specified directories and files
- Output full or relative file paths
- Save file contents to an output file
## Installation
To install Files Lister, ensure you have Python 3.9 or later installed.
This project uses UV (Python packaging in Rust) for dependency management.
If you don't have UV installed, you can install it following the instructions at [UV's official repository](https://github.com/astral-sh/uv).
## Usage
To use Files Lister, run the following command:
uv run list_files [OPTIONS]
Options:
- `-f, --files_and_dirs`: File/directory or list of them to process (required)
- `-i, --include_hidden`: Include hidden files and directories
- `-x, --include_extension`: Include only files with specified extensions (e.g., '.txt' '.py')
- `-d, --skip_dirs`: Additional directories to skip
- `-s, --skip_files`: Files or file patterns to skip
- `-q, --quiet`: Do not print output to console
- `--full_path`: Print full path instead of relative path
### Example:
uv run list_files -f "." -x ".py" -d "venv" "build" -s "init.py"
This command will list all Python files in the current directory, excluding the "venv" and "build" directories,
and skipping "init.py" files.
## Output
The script generates a file named `files_output` in the current directory, containing the list of files and their contents.
## Development
UV automatically manages the project environment. To set it up:
uv sync
This command will create a .venv directory (if it doesn't exist) and install all project dependencies specified in pyproject.toml.
### Running tests
To run the test suite:
uv run pytest --basetemp=test_tmp_dir
#### Why --basetemp=test_tmp_dir?
The `--basetemp` option is used to specify a custom directory for temporary test files.
This is particularly important for this project to avoid issues with the default .tmp folder created by `pytest`,
which is typically hidden and would otherwise be excluded by the script's logic.
By using `--basetemp=test_tmp_dir`, we ensure that temporary files do not interfere with the script's file listing and processing behavior.
### Code coverage
To generate a code coverage report:
uv run coverage run -m pytest --basetemp=test_tmp_dir uv run coverage html
### Adding Dependencies
To add a new dependency to the project:
```uv add [package_name]```
This will update both `pyproject.toml` and `uv.lock`.
This will create an HTML coverage report in the htmlcov directory.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
files_lister-0.1.0.tar.gz
(20.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file files_lister-0.1.0.tar.gz.
File metadata
- Download URL: files_lister-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c44ee2c94636ad17ef881fceff52414db29bd1b434a1ee78937b84753f4b0d58
|
|
| MD5 |
151e2767d29f235a7f1ce2904302d8ec
|
|
| BLAKE2b-256 |
cdeb8d208b14eed1bc9c8901e9c65e1780280d7c622234cfd4ffeb7e9ae80f01
|
File details
Details for the file files_lister-0.1.0-py3-none-any.whl.
File metadata
- Download URL: files_lister-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d99c5567e6e1521eef90909b8007cf1260fbc05302d649495e09dbf459541992
|
|
| MD5 |
709660e9cbcac47757806feec5b84990
|
|
| BLAKE2b-256 |
7275a9910c4062cfa987030c143769f2e545557150eaef3d5c2ab1e312075225
|