A package for reading GitHub repos and converting them for LLM processing
Project description
Repo Reader
Repo Reader is a Python package that allows you to read GitHub repositories and convert them into a format that can be easily processed by a long context Language Model (LLM). It provides functionality to count files, map directory structures, join files, and count tokens.
Installation
You can install Repo Reader using pip:
pip install repo_reader
Usage
Here's an example of how to use Repo Reader:
from repo_reader.file_counter import count_files
from repo_reader.directory_mapper import map_directory_structure
from repo_reader.file_joiner import join_files, join_text_files
from repo_reader.token_counter import count_tokens
# Count files in a directory
folder_path = '/path/to/github/repo/folder'
count_files(folder_path)
# Map directory structure
directory_path = '/path/to/directory'
output_file = 'repo_directory_structure.txt'
map_directory_structure(directory_path, file_handler=open(output_file, 'w'))
# Join files in a directory
directory_path = '/path/to/directory'
output_file = 'joined_files.txt'
excluded_extensions = ['.png', '.jpg', '.git']
ignored_folders = ['/path/to/ignored/folder']
encoding_name = 'cl100k_base'
join_files(directory_path, output_file, excluded_extensions, ignored_folders, encoding_name)
# Count tokens in a file
file_path = 'path/to/your/file.txt'
encoding_name = 'cl100k_base'
total_tokens = count_tokens(file_path, encoding_name)
# Join text files
input_files = ['file1.txt', 'file2.txt']
output_file = 'joined_files.txt'
join_text_files(input_files, output_file)
Functions count_files(folder_path) Counts the number of files and file types in a given folder.
map_directory_structure(directory, level=0, include_hidden=False, include_git=False, file_handler=None) Maps out the structure of folders and files in a directory. Optionally includes hidden files and the .git folder.
join_files(directory, output_file, excluded_extensions, ignored_folders, encoding_name) Joins the files in a directory into a single file, excluding specified file extensions and folders. Counts the number of tokens in each file.
count_tokens(file_path, encoding_name) Counts the number of tokens in a text file using the specified encoding.
join_text_files(input_files, output_file) Joins multiple text files into a single file.
Contributing Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue or submit a pull request on the GitHub repository.
License This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 repo_reader-0.0.1.tar.gz.
File metadata
- Download URL: repo_reader-0.0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
407211763f6ab404dda33db0202c44e50cd7e77141431243af1b76fba6ce7ad2
|
|
| MD5 |
efe1c04fcf1d1375664f9b4b4920a9da
|
|
| BLAKE2b-256 |
3d13cc02fb900338865c0a2cb7ae83377013bc7741ceb59e8dbff8ad31cd29ea
|
File details
Details for the file repo_reader-0.0.1-py3-none-any.whl.
File metadata
- Download URL: repo_reader-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c62ec02e89bc2d5d1df3a7a90c5f62be9cf4493b6430fc45c58fbac89ba9f18
|
|
| MD5 |
3c223eb43e8ffbfed19985cf9d217bc8
|
|
| BLAKE2b-256 |
3994d717d21831e52a6333df2ab415370faf95d6c000ff746078571c3d98acd5
|