PyReprism is a Python framework for source-code preprocessing. It lets you match, extract, count, and remove comments, strings, numbers, operators, keywords and other language-specific constructs across 145+ programming languages and file formats — through a small high-level API, a command-line tool, code metrics, ML-oriented normalization, and diff/pull-request analysis.
Highlights
One consistent API for every language: remove_* / extract_* / count_* / match_* for each construct, plus a lossless tokenize().
Code metrics (stats) and ML canonicalization (normalize) for clone/plagiarism detection and code-embedding pipelines.
Optional high-accuracy Pygments backend — with zero required dependencies by default.
Batch/corpus analysis and unified/git diff processing.
A pyreprism command-line tool (also python -m PyReprism).
Requirements
Python 3.8 or newer
Install
pip install PyReprism
For the higher-accuracy tokenizer backend:
pip install "PyReprism[accurate]"
Quick start
import PyReprism as pr
source = """
# a comment
x = 5 + 6
print(x) # inline
"""
pr.remove_comments(source, lang="python") # code without comments
pr.extract_comments(source, lang="python") # ['# a comment', '# inline']
pr.count_comments(source, lang="python") # 2
lang accepts a language name ("python"), a file extension (".py"), or a language class. Canonicalize code for machine learning, or measure it:
pr.normalize("total = price * 42", lang="python") # 'VAR1 = VAR2 * 0'
pr.stats(source, lang="python").comment_to_code_ratio
Command line
pyreprism remove comments file.py
pyreprism scan myproject/ --csv # aggregate code metrics over a tree
git diff | pyreprism diff --cosmetic # flag comment/whitespace-only changes
Documentation
Full documentation, including the API reference and the list of supported languages, is available at https://pyreprism.readthedocs.io.
Source code
PyReprism is developed on GitHub at https://github.com/unlv-evol/PyReprism. To work on it locally:
git clone https://github.com/unlv-evol/PyReprism.git
cd PyReprism
python3 -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest
See CONTRIBUTING.md for contribution guidelines.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyreprism-0.2.0.tar.gz.
File metadata
- Download URL: pyreprism-0.2.0.tar.gz
- Upload date:
- Size: 95.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c51d777231685125ed444579836b8ea91d86fb388afb06c215205e9a67925aa
|
|
| MD5 |
19b339af9ee589c4f57a8d31e6530bb7
|
|
| BLAKE2b-256 |
50e41c4b68184dc9e0dd624e31d89781024d6a04401f6522f8fecc3c0169d682
|
Provenance
The following attestation bundles were made for pyreprism-0.2.0.tar.gz:
Publisher:
publish.yml on unlv-evol/PyReprism
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyreprism-0.2.0.tar.gz -
Subject digest:
4c51d777231685125ed444579836b8ea91d86fb388afb06c215205e9a67925aa - Sigstore transparency entry: 2147866578
- Sigstore integration time:
-
Permalink:
unlv-evol/PyReprism@170b0f4d832b2b668faf53f0a556c75992003c99 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/unlv-evol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@170b0f4d832b2b668faf53f0a556c75992003c99 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyreprism-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyreprism-0.2.0-py3-none-any.whl
- Upload date:
- Size: 172.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63c9f93bd3e8ccbbb85919fad80e789381daa37dfdd1a214fb4c0d3808b2eb83
|
|
| MD5 |
d835c8835d5fe1b08d239cb157afd2dd
|
|
| BLAKE2b-256 |
8f41a37937296663dd116e91c35813d2eba4dadd91ddbc285f53220b2e625f07
|
Provenance
The following attestation bundles were made for pyreprism-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on unlv-evol/PyReprism
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyreprism-0.2.0-py3-none-any.whl -
Subject digest:
63c9f93bd3e8ccbbb85919fad80e789381daa37dfdd1a214fb4c0d3808b2eb83 - Sigstore transparency entry: 2147866633
- Sigstore integration time:
-
Permalink:
unlv-evol/PyReprism@170b0f4d832b2b668faf53f0a556c75992003c99 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/unlv-evol
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@170b0f4d832b2b668faf53f0a556c75992003c99 -
Trigger Event:
push
-
Statement type: