Skip to main content

High-performance async GitHub repository analyzer with AI-optimized code extraction and smart .env file support

Project description

๐Ÿš€ py-github-analyzer

High-performance async GitHub repository analyzer with AI-optimized code extraction and smart .env file support

License: MIT Python 3.8+ PyPI version

โœจ Features

๐Ÿ” Advanced Authentication

  • โœ… Fine-grained Token Support: Latest GitHub token standard with Bearer authentication
  • โœ… Classic Token Support: Traditional ghp_ tokens with token authentication
  • ๐Ÿ”„ Auto Token Detection: Automatically detects token type and uses appropriate authentication
  • ๐Ÿ“ Multi-source Token Loading: Environment variables, .env files, CLI parameters
  • ๐Ÿ”’ Private Repository Access: Full access to private repositories with proper permissions

โšก High Performance

  • ๐ŸŽฏ ZIP-first Strategy: Optimal download method with intelligent API fallback
  • ๐Ÿ“Š Smart Rate Limit Management: Adaptive strategies for different token types
  • ๐Ÿš€ Pure Async Architecture: Built with modern async/await patterns for maximum performance
  • ๐Ÿ”„ Intelligent Fallback: Graceful degradation when ZIP access fails

๐Ÿ“‹ Smart Analysis

  • ๐Ÿ” Automatic Language Detection: Accurate detection and dependency mapping
  • ๐Ÿ“Š Intelligent File Filtering: Skip binaries, focus on source code with priority scoring
  • ๐Ÿ“ฆ Multiple Output Formats: JSON metadata and structured code extraction
  • ๐ŸŽฏ Framework Detection: Identifies popular frameworks and patterns

๐ŸŒ Cross-Platform

  • ๐Ÿ’ป Windows, macOS, and Linux: Full compatibility across all platforms
  • ๐Ÿ›ก๏ธ Smart Error Handling: Comprehensive error messages and recovery strategies
  • ๐Ÿ“ Smart .env Support: Automatically finds and loads tokens from .env files

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install py-github-analyzer
From Source
Bash

git clone [https://github.com/cruxhan/py-github-analyzer.git](https://github.com/cruxhan/py-github-analyzer.git)
cd py-github-analyzer
pip install -e .
๐Ÿ”‘ GitHub Token Setup (Recommended)
Supported Token Types
py-github-analyzer supports all GitHub token types with automatic detection:

๐Ÿ”‘ Fine-grained Personal Access Tokens (Latest)
Prefix: github_pat_

Authentication: Bearer header

Permissions: Repository-specific granular access

Security: โœ… Enhanced security with minimal required permissions

Performance: โš ๏ธ API-only access for private repos (ZIP may fail)

Setup: GitHub Settings โ†’ Developer settings โ†’ Personal access tokens โ†’ Fine-grained tokens

๐Ÿ”‘ Classic Personal Access Tokens (Traditional)
Prefix: ghp_

Authentication: token header

Permissions: Broad scope-based access

Security: โš ๏ธ Wide access permissions

Performance: โœ… Full ZIP and API access

Setup: GitHub Settings โ†’ Developer settings โ†’ Personal access tokens โ†’ Tokens (classic)

Creating Tokens
For Fine-grained Tokens (Recommended for Security):
Visit GitHub Settings โ†’ Personal Access Tokens โ†’ Fine-grained tokens

Select Repository access: Choose specific repositories or all repositories

Set Repository permissions:

Contents: Read (required for file access)

Actions: Read (required for ZIP downloads)

Metadata: Read (required for repository info)

Copy the token (starts with github_pat_)

For Classic Tokens (Faster for Bulk Analysis):
Visit GitHub Settings โ†’ Personal Access Tokens โ†’ Tokens (classic)

Click Generate new token (classic)

Select repo scope for private repository access

Copy the token (starts with ghp_)

Setting Up Your Token
Option 1: Environment Variable (Recommended)

Bash

# For Linux/macOS
export GITHUB_TOKEN=your_token_here

# For Windows (Command Prompt)
set GITHUB_TOKEN=your_token_here
Option 2: .env file in your project directory

Bash

echo "GITHUB_TOKEN=your_token_here" > .env
Option 3: CLI parameter

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --github-token your_token_here
๐Ÿ“‹ Usage Examples
Basic Usage
Analyze a public repository

Bash

py-github-analyzer [https://github.com/octocat/Hello-World](https://github.com/octocat/Hello-World)
Analyze with verbose output

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --verbose
Specify output directory and format

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --output-dir ./results --output-format json
Advanced Options
Force specific analysis method

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --method api
py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --method zip
Multiple output formats

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --output-format both
Dry run (test without processing)

Bash

py-github-analyzer [https://github.com/owner/repo](https://github.com/owner/repo) --dry-run
๐Ÿ“– Output Format
JSON Structure
JSON

{
  "metadata": {
    "repo": "owner/repository-name",
    "desc": "Repository description",
    "lang": ["Primary", "Secondary", "Languages"],
    "size": {
      "repo_size": "288KB",
      "source_size": "294.2KB",
      "display_size": "288KB"
    },
    "files": 117,
    "main": ["main.py", "app.py", "index.js"],
    "deps": ["dependency1", "dependency2"],
    "created": 1634567890,
    "version": "1.0.0"
  },
  "files": [
    {
      "path": "src/main.py",
      "content": "file content here",
      "size": 1234,
      "lines": 45,
      "language": "Python",
      "priority": 950
    }
  ]
}
๐Ÿค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup
Bash

git clone [https://github.com/cruxhan/py-github-analyzer.git](https://github.com/cruxhan/py-github-analyzer.git)
cd py-github-analyzer

# Create virtual environment
python -m venv venv
# On Windows: venv\Scripts\activate
# On Linux/macOS: source venv/bin/activate
source venv/bin/activate 

# Install development dependencies
pip install -e .[dev]

# Run tests
poe test
๐Ÿ“„ License
This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“ž Support
Issues: GitHub Issues

Discussions: GitHub Discussions

Made with โค๏ธ for developers who need fast, reliable GitHub repository analysis

py-github-analyzer v1.0.0

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

py_github_analyzer-1.0.1.tar.gz (58.1 kB view details)

Uploaded Source

Built Distribution

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

py_github_analyzer-1.0.1-py3-none-any.whl (60.3 kB view details)

Uploaded Python 3

File details

Details for the file py_github_analyzer-1.0.1.tar.gz.

File metadata

  • Download URL: py_github_analyzer-1.0.1.tar.gz
  • Upload date:
  • Size: 58.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for py_github_analyzer-1.0.1.tar.gz
Algorithm Hash digest
SHA256 ae58f9ff7b5b0c68a65c16d257bd274ff4786d4f5875c27af314ac1fc565709c
MD5 3fb7ed6bcb5aa6bf9a18b42b4062fe30
BLAKE2b-256 5663b20c034d2d19d97168abf62dddbc90992399085f19587ee3522e923ad37b

See more details on using hashes here.

File details

Details for the file py_github_analyzer-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_github_analyzer-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f65303a0d7f710d5e56cbc0bb661252c9910a0afae6121205bc35b39227548cf
MD5 ff3009129bcbff4d6e79ed96f047d84d
BLAKE2b-256 33321bc677d40ff1090dabe90276654cc2573af76618821ff7d6cf63f24330cd

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