Skip to main content

Parses the contents of a source code directory and determines the programming languages in use.

Project description

WhoDis

Parses the contents of a source code directory and determines the programming languages in use.

Languages Supported:

  • Go
  • Java
  • JavaScript
  • Python
  • Ruby

Usage

Install from PyPI:

pip install whodis

Import the module and create a new instance of WhoDis:

from whodis import WhoDis
blah = WhoDis()

WhoDis objects have a single method, parse(), which takes a single filepath (string) parameter:

blah.parse("/some/valid/path/with/source/code")

After parsing a valid path with at least one file in a supported language, the object will have four attributes:

# language - The dominant programming language in the source path.
# String.
# Possible string values are "go", "java", "js", "py", "rb".
blah.language
>>> "py"

 # all_languages - All languages present in the source path.
 # List of strings.
 # Possible list values are "go", "java", "js", "py", "rb".
blah.all_languages
>>> ["rb", "js"]

# files - All non-filtered files in the source path.
# List of strings.
blah.files
>>> ["__init__.py", "main.py", "README.md", "LICENSE.md", "requirements.txt"]

# files_by_language - All non-filtered files in the source path broken down by language.
# Dictionary with strings for keys and lists of strings for values.
# Possible key names are "go", "java", "js", "py", "rb".
blah.files_by_language
>>> {"rb": ["application_controller.rb", "model.rb"], "js": ["app.js"]}

FAQs

1. How does WhoDis work?

WhoDis is very naive. It will recursively find all files in a path, filter out certain directories (e.g. .git, build/packaging, virtual environments, etc.), look at the file extensions of the files returned, and group them by extension (e.g. .py). WhoDis then looks at which language has the most files and considers it the dominant language for the source code in the path.

2. What gets filtered out? Why filter?

Please look at the *_filters.py files, which should be quite easy to understand. The files getting filtered are in directories that are commonly associated with things like version control, building/packaging, and virtual environments. The reason for filtering is 1) to speed up WhoDis (e.g. a big .git can slow us down a lot), and 2) these directories usually contain files that are irrelevant/redundant to determining the programming languages being used. In short, filtered files shouldn't influence WhoDis' parsing.

3. Why only support Go, Java, JavaScript, Python, and Ruby?

I wrote WhoDis for use with another project that interacts with AWS Lambda. These languages are all natively supported by Lambda. Feel free to open a PR if you'd like additional language support!

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

whodis-1.0.2.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

whodis-1.0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file whodis-1.0.2.tar.gz.

File metadata

  • Download URL: whodis-1.0.2.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for whodis-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e1a377f2c6c07552ee691d9be44826af8a73fb543a1aafb80baf1dbfa8ef477a
MD5 423316a4c90d19e0c889b65b805c491f
BLAKE2b-256 2abd13cbe1512c96c7490bb43559bbae8582516569420b25a1198b8d46e78d45

See more details on using hashes here.

File details

Details for the file whodis-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: whodis-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7

File hashes

Hashes for whodis-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c441d85b25b60ab22774921aa06a2c619bcb83c39feef47f754e96a2b7fb2951
MD5 0bcc1b2752935b6344194310a25fbed8
BLAKE2b-256 d426cffff9bf47faad9dbdae781751744720f022b03a99a19c9e492ef2964b3c

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