{"id":18076202,"url":"https://github.com/scivision/linguist-python","last_synced_at":"2025-04-12T08:11:58.297Z","repository":{"id":57434224,"uuid":"143327089","full_name":"scivision/linguist-python","owner":"scivision","description":"Detect repo language(s) with thin Python wrapper of Github Linguist","archived":false,"fork":false,"pushed_at":"2022-11-15T17:02:42.000Z","size":47,"stargazers_count":14,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T03:21:56.694Z","etag":null,"topics":["github","linguist","python"],"latest_commit_sha":null,"homepage":"https://github.com/github/linguist","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scivision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-02T17:43:58.000Z","updated_at":"2024-12-14T05:38:24.000Z","dependencies_parsed_at":"2023-01-23T02:31:16.067Z","dependency_job_id":null,"html_url":"https://github.com/scivision/linguist-python","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Flinguist-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Flinguist-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Flinguist-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scivision%2Flinguist-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scivision","download_url":"https://codeload.github.com/scivision/linguist-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054218,"owners_count":21039951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","linguist","python"],"created_at":"2024-10-31T11:09:12.697Z","updated_at":"2025-04-12T08:11:58.262Z","avatar_url":"https://github.com/scivision.png","language":"Python","readme":"# linguist-python\n\n![ci](https://github.com/scivision/linguist-python/workflows/ci/badge.svg)\n[![pypi versions](https://img.shields.io/pypi/pyversions/ghlinguist.svg)](https://pypi.python.org/pypi/ghlinguist)\n[![PyPi Download stats](http://pepy.tech/badge/ghlinguist)](http://pepy.tech/project/ghlinguist)\n\nPure Python command-line wrapper of Ruby-based Github [Linguist](https://github.com/github/linguist).\nLinguist detects the language of a Git repo based on the `commit`ed files.\nThe repo file\n[.gitattributes](https://github.com/github/linguist#using-gitattributes)\nis used to configure Linguist to not get distracted by `docs` or archive files, etc. using several straightforward rules.\n\nThis Python wrapper makes Linguist more intuitive by warning users of uncommitted changes or additions that could make Linguist silently give inaccurate results, since Linguist only works on files that have been `git commit`ed.\n\n## Install\n\nRuby is required for Linguist:\n\n* Windows: Windows Subsystem for Linux is recommended.\n* Linux: see Notes section at bottom of this README\n* MacOS / Linux Homebrew: `brew install ruby`\n\n1. Install Linguist as usual:\n\n   ```sh\n   gem install github-linguist\n   ```\n2. Install this Python wrapper:\n\n   ```sh\n   pip install ghlinguist\n   ```\n\n## Usage\n\nFrom Terminal:\n\n```sh\npython -m ghlinguist\n```\n\nOr import as a Python module.\n\n```python\nimport ghlinguist as ghl\n\nlangs = ghl.linguist('~/mypath')\n```\n\nThe functions return a list of tuples like:\n\n```\n[('Python'), (97.)]\n[('Fortran'), (3.)]\n```\n\nwhere the second number is the percentage of code detected for that language.\n\nIf the directory is not a Git repo, `None` is returned\n\n### Examples\n\nThe primary reason behind creating this Python Linguist wrapper is automatically detecting the repo type, so that appropriate templates can be applied *en masse* to a large number of repos.\nThus to get the repo language from the command line, as GitHub would:\n\n```sh\npython -m ghlinguist -t\n```\n\nor as a Python module:\n\n```python\nimport ghlinguist as ghl\n\nlang = ghl.linguist('~/mypath', rpath=True)\n```\n\nBoth cases simply return the string `Python` or `Fortran` etc.\n\n## Notes\n\nghLinguist parses text output from\n[GitHub Linguist](https://github.com/github/linguist#using-emacs-or-vim-modelines),\nwhich is a Ruby program.\nWe call `github-linguist` executable since `linguist` overlaps with QT Lingiust.\n\n### Linux prereqs\n\nIf you don't already have RubyGems setup on Linux:\n\n1. setup RubyGems:\n\n   ```sh\n   apt install --no-install-recommends ruby-dev libssl-dev libicu-dev zlib1g-dev libcurl4-openssl-dev\n\n   gem update --system\n   ```\n2. be sure Gems are installed to home directory, NOT system (no sudo) by adding to `~/.bashrc`:\n\n   ```sh\n   # Install Ruby Gems to ~/gems\n   export GEM_HOME=$HOME/gems\n   export PATH=$HOME/gems/bin:$PATH\n   ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Flinguist-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscivision%2Flinguist-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscivision%2Flinguist-python/lists"}