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.3.tar.gz (6.2 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.3-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for github_scrap-0.1.3.tar.gz
Algorithm Hash digest
SHA256 04cb09a127072f614f363bf752292b1bb69551eb15b30ad95bc968196c8b8c81
MD5 c15a0167f340a148a3584f2014c1ef7d
BLAKE2b-256 060e734e28d3ae671c049db38aec752bf621d70ae214dc3473e891d24376f602

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for github_scrap-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d87f6af1104775225c992a8bb378a51c75c06e78366ab7ffef5613d1efd76a05
MD5 9dd11eb7f43043271d18cad178d53e17
BLAKE2b-256 db1243b76906b069457a42acb31597759fa42b750cce39f73db06e8227f830f0

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