Skip to main content

simple command-line parser of GitHub Linguist Ruby program.

Project description

Build Status Coverage Status Build status

linguist-python

Simple command-line wrapper of Ruby-based Github Linguist. Linguist (and hence this Python wrapper) detect the language of a Git repo, based on the commited files .gitattributes is used to configure Linguist to not get distracted by docs or archive files, etc. using several straightforward rules.

Install

  1. Install Linguist as usual:
    gem install github-linguist
    
  2. Install Python wrapper:
    pip install -e .
    

Usage

From Terminal:

ghlinguist

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

Examples

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:

ghlinguist -t

or as a Python module:

import ghlinguist as ghl

lang = ghl.linguist('~/mypath', rpath=True)

Both cases simply return the string Python or Fortran etc.

Notes

ghLinguist parses text output from GitHub Linguist, which is a Ruby program.

Linux prereqs

If you don't already have RubyGems setup on Linux:

  1. setup RubyGems:
    apt install ruby-dev libssl-dev libicu-dev zlib1g-dev libcurl4-openssl-dev
    
    gem update --system
    
  2. be sure Gems are installed to home directory, NOT system (no sudo) by adding to ~/.bashrc:
    # Install Ruby Gems to ~/gems
    export GEM_HOME=$HOME/gems
    export PATH=$HOME/gems/bin:$PATH
    

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

ghlinguist-0.9.1.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file ghlinguist-0.9.1.tar.gz.

File metadata

  • Download URL: ghlinguist-0.9.1.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.3 CPython/3.7.0

File hashes

Hashes for ghlinguist-0.9.1.tar.gz
Algorithm Hash digest
SHA256 aea11831da77158ccda07a30288d5fd995f1cd4dc102f27bff8ecbd98c60e90c
MD5 27453956ab4439938044b0b6762f01c7
BLAKE2b-256 f7c5f97d5abdca043de30955cc2e5ad837e2cac64c2f638268104353748f7797

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page