Skip to main content

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

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

pyreprism-0.2.0.tar.gz (95.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyreprism-0.2.0-py3-none-any.whl (172.7 kB view details)

Uploaded Python 3

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

Hashes for pyreprism-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4c51d777231685125ed444579836b8ea91d86fb388afb06c215205e9a67925aa
MD5 19b339af9ee589c4f57a8d31e6530bb7
BLAKE2b-256 50e41c4b68184dc9e0dd624e31d89781024d6a04401f6522f8fecc3c0169d682

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreprism-0.2.0.tar.gz:

Publisher: publish.yml on unlv-evol/PyReprism

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyreprism-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 63c9f93bd3e8ccbbb85919fad80e789381daa37dfdd1a214fb4c0d3808b2eb83
MD5 d835c8835d5fe1b08d239cb157afd2dd
BLAKE2b-256 8f41a37937296663dd116e91c35813d2eba4dadd91ddbc285f53220b2e625f07

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyreprism-0.2.0-py3-none-any.whl:

Publisher: publish.yml on unlv-evol/PyReprism

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

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