Skip to main content

A Python tool for concatenating code.

Project description

Catenator

Catenator is a Python tool for concatenating code files in a directory into a single output string.

Features

  • Concatenate code files from a specified directory
  • Include or exclude specific file extensions
  • Include a directory tree structure
  • Include README files in the output
  • Output to file, clipboard, or stdout
  • gitignore-style .catignore files

Installation

Install using pip

pip install catenator

Usage

As a Command-Line Tool

Basic usage:

catenator /path/to/your/project

Options:

  • --output FILE: Write output to a file instead of stdout
  • --clipboard: Copy output to clipboard
  • --no-tree: Disable directory tree generation
  • --no-readme: Exclude README files from the output
  • --include EXTENSIONS: Comma-separated list of file extensions to include (replaces defaults)
  • --ignore EXTENSIONS: Comma-separated list of file extensions to ignore
  • --count-tokens: Output approximation of how many tokens in output (tiktoken cl100k_base)
  • --watch: Watch for changes and update output file automatically (requires --output)
  • --ignore-tests: Leave out tests from the concatenated output

Example:

python catenator.py /path/to/your/project --output concatenated.md --include py,js,ts

As a Python Module

You can also use Catenator in your Python scripts:

from catenator import Catenator

catenator = Catenator(
    directory='/path/to/your/project',
    include_extensions=['py', 'js', 'ts'],
)
result = catenator.catenate()
print(result)

.catignore File

The .catignore file allows you to specify files and directories that should be excluded from the concatenation process. The syntax is like .gitignore files.

Syntax

Lines starting with # are treated as comments. Blank lines are ignored. Patterns can include filenames, directories, or wildcard characters.

Examples

# Ignore all JavaScript files
*.js

# Ignore specific file
ignored_file.txt

# Ignore entire directory
ignored_dir/

License

This project is licensed under the Creative Commons Zero v1.0 Universal (CC0-1.0) License.

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

catenator-0.2.5.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

catenator-0.2.5-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file catenator-0.2.5.tar.gz.

File metadata

  • Download URL: catenator-0.2.5.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for catenator-0.2.5.tar.gz
Algorithm Hash digest
SHA256 f1a0fb28debb5acf6b4e23d71deada7a552b41579abfaf43c58a17f0272afb41
MD5 f308baa100606664032d53ce2651e5fa
BLAKE2b-256 ba77c7c299a9ec35b4d42673e84903c8d370f16eac5b5f86b4d430d17132f2ba

See more details on using hashes here.

File details

Details for the file catenator-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: catenator-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for catenator-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5b37a4fbc9ec6d58a938ae899e8a05d4854ff297c1ddc04879615fa72182df67
MD5 2c8f3b788b15a96a3bb2f61804b184ad
BLAKE2b-256 525c0ca4747a768e56cef1124097c6bd9dec9852b5b4ad802177e46edf44b289

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