simple command-line parser of GitHub Linguist Ruby program.
Simple Python command-line wrapper of Ruby-based Github Linguist.
(and hence this Python wrapper) detect the language of a Git repo, based on the
is used to configure Linguist to not get distracted by
docs or archive files, etc. using several straightforward rules.
This Python wrapper attempts to make Linguist a little more careful by warning users of uncommitted changes or additions that could make Linguist silently give very skewed (inaccurate) results, since Linguist only works on files/changes after
- Install Linguist as usual:
gem install github-linguist
- Install Python wrapper:
pip install -e .
Or import as a Python module.
import ghlinguist as ghl langs = ghl.linguist('~/mypath')
The functions return a list of tuples like:
[('Python'), (97.)] [('Fortran'), (3.)]
where the second number is the percentage of code detected for that language.
If the directory is not a Git repo,
None is returned
The 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. Thus to get the repo language from the command line, as GitHub would:
or as a Python module:
import ghlinguist as ghl lang = ghl.linguist('~/mypath', rpath=True)
Both cases simply return the string
ghLinguist parses text output from
which is a Ruby program.
github-linguist executable since
linguist overlaps with QT Lingiust.
If you don't already have RubyGems setup on Linux:
- setup RubyGems:
apt install ruby-dev libssl-dev libicu-dev zlib1g-dev libcurl4-openssl-dev gem update --system
- be sure Gems are installed to home directory, NOT system (no sudo) by adding to
# Install Ruby Gems to ~/gems export GEM_HOME=$HOME/gems export PATH=$HOME/gems/bin:$PATH
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size ghlinguist-1.0.0.tar.gz (5.1 kB)||File type Source||Python version None||Upload date||Hashes View hashes|