Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

detect-languages

Latest PyPI version GitHub Actions status Python versions Code style License

This module discover the programming languages from a project/repository.

Usage

  • Module

    test.py

    from detect_languages.detect import DetectLanguages
    
    detect_languages = DetectLanguages(debug=False, path=".", language_types=["programming"], exclude_dirs=[".venv", ".tox", "samples"], exclude_dirs_recursively=False)
    
    print("Main language: ", detect_languages.main_language)
    print("All languages: ", detect_languages.all_languages)
    
    $ python test.py
    

    Output:

    Main language:  Python
    All languages:  {'Python': {'size': 50799, 'percentage': 100.0}}
    
  • CLI

    Help:

    $ detect-languages --help
    

    Output:

    Usage: detect-languages [OPTIONS] COMMAND [ARGS]...
    
    Options:
      --help  Show this message and exit.
    
    Commands:
      all
      main
    

    Main language help:

    detect-languages main --help
    

    Output:

    Usage: detect-languages main [OPTIONS]
    
    Options:
      -d, --debug / --no-debug        Debug  [default: no-debug]
      -p, --path PATH                 Path to project  [default: .]
      -lt, --language-types TEXT      Language types  [default: programming, 
                                      prose, data, markup]
      -ed, --exclude-dirs TEXT        Exclude dirs
      -edr, --exclude-dirs-recursively / --no-exclude-dirs-recursively       
                                      Exclude dirs recursively  [default: no-
                                      exclude-dirs-recursively]
      -o, --output [json|tabulate]    Output format  [default: tabulate]     
      --help                          Show this message and exit.
    

    All languages help:

    detect-languages all --help
    

    Output:

    Usage: detect-languages all [OPTIONS]
    
    Options:
      -d, --debug / --no-debug        Debug  [default: no-debug]
      -p, --path PATH                 Path to project  [default: .]
      -lt, --language-types TEXT      Language types  [default: programming, 
                                      prose, data, markup]
      -ed, --exclude-dirs TEXT        Exclude dirs
      -edr, --exclude-dirs-recursively / --no-exclude-dirs-recursively       
                                      Exclude dirs recursively  [default: no-
                                      exclude-dirs-recursively]
      -o, --output [json|tabulate]    Output format  [default: tabulate]     
      --help                          Show this message and exit.
    

    Main language example:

    detect-languages main -ed .venv -ed .tox -ed .github -ed .pytest_cache -ed .vscode -ed samples -p . -o json
    

    Output:

    {'Python': {'size': 52455, 'percentage': 63.51}}
    

    All languages example:

    detect-languages all -ed .venv -ed .tox -ed .github -ed .pytest_cache -ed .vscode -ed samples -p . -o json
    

    Output:

    {'Python': {'size': 52455, 'percentage': 63.46}, 'JSON': {'size': 24481, 'percentage': 29.62}, 'Markdown': {'size': 4728, 'percentage': 5.72}, 'INI': {'size': 725, 'percentage': 0.88}, 'TOML': {'size': 271, 'percentage': 0.33}}
    

    Debug:

    detect-languages all -ed .venv -ed .tox -ed .github -ed .pytest_cache -ed .vscode -ed samples -p . -o json -d
    

    Output:

    DEBUG: Detecting languages...
    DEBUG: Language types: ['programming', 'prose', 'data', 'markup']
    DEBUG: no lexer for filename '.gitignore' found
    DEBUG: file: './.gitignore', language: 'None', size: 111
    DEBUG: no lexer for filename 'LICENSE' found
    DEBUG: file: './LICENSE', language: 'None', size: 1074
    DEBUG: file: './README.md', language: 'Markdown', size: 7648
    DEBUG: file: './Pipfile.lock', language: 'JSON', size: 24481
    DEBUG: file: './setup.py', language: 'Python', size: 1166
    DEBUG: file: './tox.ini', language: 'INI', size: 160
    DEBUG: file: './requirements.txt', language: 'Text only', size: 426
    DEBUG: file: './.bumpversion.cfg', language: 'INI', size: 532
    DEBUG: file: './Pipfile', language: 'TOML', size: 271
    DEBUG: file: './detect_languages.egg-info/top_level.txt', language: 'Text only', size: 17
    DEBUG: file: './detect_languages.egg-info/dependency_links.txt', language: 'Text only', size: 1
    DEBUG: file: './detect_languages.egg-info/entry_points.txt', language: 'Text only', size: 63
    DEBUG: file: './detect_languages.egg-info/SOURCES.txt', language: 'Text only', size: 378
    DEBUG: file: './detect_languages.egg-info/requires.txt', language: 'Text only', size: 63
    DEBUG: no lexer for filename 'PKG-INFO' found
    DEBUG: file: './detect_languages.egg-info/PKG-INFO', language: 'None', size: 8378
    DEBUG: file: './tests/test_cli.py', language: 'Python', size: 726
    DEBUG: file: './tests/test_detect.py', language: 'Python', size: 1608
    DEBUG: file: './detect_languages/languages.py', language: 'Python', size: 37666
    DEBUG: file: './detect_languages/cli.py', language: 'Python', size: 3009
    DEBUG: file: './detect_languages/detect.py', language: 'Python', size: 6852
    DEBUG: Detected main language: Python
    DEBUG: Detected languages: ['Python', 'JSON', 'Markdown', 'INI', 'TOML']
    {'Python': {'size': 51027, 'percentage': 60.66}, 'JSON': {'size': 24481, 'percentage': 29.1}, 'Markdown': {'size': 7648, 'percentage': 9.09}, 'INI': {'size': 692, 'percentage': 0.82}, 'TOML': {'size': 271, 'percentage': 0.32}}
    

Installation

$ pip install detect-languages

Requirements

Credits/Inspirations

Licence

MIT

Author

Alex Graciano

Metadata

Release files for detect-languages 0.1.0b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for detect-languages 0.1.0b3
File Size Uploaded Provenance
detect-languages-0.1.0b3.tar.gz 14.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for detect-languages 0.1.0b3
File Interpreter ABI Platform
detect_languages-0.1.0b3-py3-none-any.whl Python 3 none any Details

Total release size: 28.0 kB

Release files / detect-languages-0.1.0b3.tar.gz

Download URL detect-languages-0.1.0b3.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
617dc0895391d6c7a9903ef0f4c603000930777134934e5d7a96a5ff3b165f6a
BLAKE2b-256 checksum
How to use checksums
9b62e5ba60a1027c9755dd1960fa0c00641ff8092125adcde5404cc4e0c9d0f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

Release files / detect_languages-0.1.0b3-py3-none-any.whl

Download URL detect_languages-0.1.0b3-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ea054b7d4fa02aed7c1a65c2291b11ed6796a9df2ff48aa5698f693a7cd0641
BLAKE2b-256 checksum
How to use checksums
68f29950262b43d01faa5a50c9fb8718ef14281784095216a98a24b93fe269d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9

Security for detect-languages 0.1.0b3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page