Skip to main content

A utility for recursively listing and saving the content of source code files

Project description

Files Lister

codecov Worker CI

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

Using pipx

To install Files Lister using pipx, ensure you have Python 3.9 or later and pipx installed. You can install pipx with:

brew install pipx
pipx ensurepath

Then, install Files Lister:

pipx install files-lister

This will make the list_files command available globally on your system.

Usage

To use Files Lister, run the following command:

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:

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

For development purposes, if you are using UV (Python packaging in Rust) for dependency management, you can set up the environment with:

uv sync

Running tests

To run the test suite with UV:

uv run pytest --basetemp=test_tmp_dir

Why --basetemp=test_tmp_dir?

The --basetemp option specifies a custom directory for temporary test files. This prevents issues with the default .tmp folder created by pytest, ensuring temporary files do not interfere with the script's logic.

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 using UV:

uv add [package_name]

This will update both pyproject.toml and uv.lock.

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.1.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

files_lister-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file files_lister-0.1.1.tar.gz.

File metadata

  • Download URL: files_lister-0.1.1.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for files_lister-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3157e53a1f444ed4029cdc6a81d5298e08c9590e82cf819e66385079c2bd5373
MD5 43635d5aac41ae2f80d6fe5714c647c8
BLAKE2b-256 6887cd91f2b49f08f3eb5756234c1aaaa84e020ceb9ca875df91a6b9883b04ba

See more details on using hashes here.

File details

Details for the file files_lister-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: files_lister-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.18

File hashes

Hashes for files_lister-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d0cf4aa1c97692bf425aed52e45362520d6d44cfffcd1b0a6ae9c8f109170a0
MD5 e22f1f9c643e3996e8ef768801651a48
BLAKE2b-256 214c0a392a9ccb41d04b9670ad10336f9f2ff978244e2dbe565a61eee899ee0f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page