Skip to main content

A tool to scrape code from GitHub or local repositories for LLM analysis.

Project description

Below is the updated README with the new –xt option, along with all the other available CLI options:

GitHub Scrap

A tool to scrape code from Git repositories for LLM or other analysis. This tool reads the repository, filters files based on extension and ignore rules, and outputs a formatted version of the code. For example, if your repository contains a file named hello.py with a simple function, running the tool might produce:

File: hello.py

def greet(): print("Hello, world!")

Installation

You can install the package using PyPI:

pip install github-scrap

Or, if you use Poetry:

poetry add github-scrap

Or directly from GitHub:

pip install git+https://github.com/Pioannid/GitHubScrap.git

Usage

Python Script

You can use the tool as a module in your Python scripts:

from github_scrap import GitHubCodeScraper

repo_url = "https://github.com/Pioannid/GitHubScrapper" scraper = GitHubCodeScraper(repo_path=repo_url, branch="main") code_contents = scraper.scrape_repository() formatted_output = scraper.format_for_llm(code_contents) print(formatted_output)

CLI

After installation, the CLI tool is available as github-scrap. The basic usage is:

github-scrap [OPTIONS] REPO_PATH

Where REPO_PATH is the path to the Git repository or its URL.

Available CLI Options • –output, -o Description: Specify a file path to save the formatted output. Example: --output output.txt • –ignore-dirs, -id Description: Additional directories to ignore. Accepts one or more directory names. Example: --ignore-dirs venv node_modules • –ignore-files, -if Description: Specific files to ignore. Accepts one or more filenames. Example: --ignore-files README.md LICENSE • –ignore-file, -c Description: Path to a configuration file with ignore rules (for both files and directories). Example: --ignore-file .gitignore • –token, -t Description: GitHub token for private repositories (if REPO_PATH is a URL). Example: --token YOUR_GITHUB_TOKEN • –branch, -b Description: The branch to scrape from. Default is main. Example: --branch develop • –xt Description: Modify file extensions to process. This option accepts an operation and one or more file extensions. • Operation: Specify add to include additional extensions or remove to exclude extensions from the default set. • Usage Examples: • To add extensions:

github-scrap REPO_PATH --xt add .js .txt

•	To remove extensions:

github-scrap REPO_PATH --xt remove .cpp .hpp

Example Command

To scrape the repository on the main branch, save the output to output.txt, and add .json and .md to the default file extensions, run:

github-scrap https://github.com/Pioannid/GitHubScrap --branch main --output output.txt --xt add .json .md

License

This project is licensed under the MIT License.

Feel free to adjust the wording or examples as needed. This README now reflects the updated CLI option for modifying file extensions.

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

github_scrap-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

github_scrap-0.1.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file github_scrap-0.1.2.tar.gz.

File metadata

  • Download URL: github_scrap-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for github_scrap-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7c89d3540c13711781a18cc21254ea7c1893fa9fe63e839b1a5d4819c16b7bfa
MD5 4c8047fcdd0d2ba1079831b6ceb2b278
BLAKE2b-256 90aee16f7ff7e6ca8b236538c7c806f4daca34cd4eb8df36d975a383e9e2124e

See more details on using hashes here.

File details

Details for the file github_scrap-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: github_scrap-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for github_scrap-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e97467ce832af67f5a5e35063da720b57506bdf2b7c2fa17a259ef4f10233f64
MD5 43db09ac27f983ae713392f6d9bfafd0
BLAKE2b-256 2c3a15ae11aae020fa89962ffc620b948291acd9051bbca54c8e1e67990fa026

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