Skip to main content

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!

Metadata

Release files for whodis 1.0.2

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

Source distribution (sdist)

Source distribution for whodis 1.0.2
File Size Uploaded Provenance Actions
whodis-1.0.2.tar.gz 5.2 kB Without provenance Details for whodis-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whodis 1.0.2
File Interpreter ABI Platform Actions
whodis-1.0.2-py3-none-any.whl Python 3 none any Details for whodis-1.0.2-py3-none-any.whl

Total release size: 12.8 kB

Release files / whodis-1.0.2.tar.gz

Download URL whodis-1.0.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e1a377f2c6c07552ee691d9be44826af8a73fb543a1aafb80baf1dbfa8ef477a
BLAKE2b-256 checksum
How to use checksums
2abd13cbe1512c96c7490bb43559bbae8582516569420b25a1198b8d46e78d45
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / whodis-1.0.2-py3-none-any.whl

Download URL whodis-1.0.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c441d85b25b60ab22774921aa06a2c619bcb83c39feef47f754e96a2b7fb2951
BLAKE2b-256 checksum
How to use checksums
d426cffff9bf47faad9dbdae781751744720f022b03a99a19c9e492ef2964b3c
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for whodis 1.0.2

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