Metadata-Version: 2.4
Name: PyReprism
Version: 0.2.0
Summary: Framework for Source Code Preprocessing
Project-URL: Homepage, https://github.com/unlv-evol/PyReprism
Project-URL: Documentation, https://pyreprism.readthedocs.io
Project-URL: Issues, https://github.com/unlv-evol/PyReprism/issues
Author-email: UNLV EVOL LAB <ogenrwot@unlv.nevada.edu>
License: MIT License
        
        Copyright (c) 2024 UNLV EVOL
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.8
Provides-Extra: accurate
Requires-Dist: pygments; extra == 'accurate'
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: flake8; extra == 'dev'
Requires-Dist: pygments; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx; extra == 'docs'
Requires-Dist: sphinx-rtd-theme; extra == 'docs'
Description-Content-Type: text/x-rst

.. _intro_toplevel:

========
Overview
========

**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
=======

.. code-block:: shell

    pip install PyReprism

For the higher-accuracy tokenizer backend:

.. code-block:: shell

    pip install "PyReprism[accurate]"

Quick start
===========

.. code-block:: python

    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:

.. code-block:: python

    pr.normalize("total = price * 42", lang="python")   # 'VAR1 = VAR2 * 0'
    pr.stats(source, lang="python").comment_to_code_ratio

Command line
============

.. code-block:: shell

    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:

.. code-block:: shell

    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.

.. _Python: https://www.python.org
.. _Pygments: https://pygments.org
