PyReprism 0.0.3__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyreprism-0.0.3 → pyreprism-0.0.4}/CONTRIBUTING.md +1 -1
- pyreprism-0.0.4/PKG-INFO +98 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/README.md +7 -2
- pyreprism-0.0.3/requirements.txt → pyreprism-0.0.4/dev-requirements.txt +3 -1
- pyreprism-0.0.4/docs/intro.rst +53 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/pyproject.toml +4 -3
- pyreprism-0.0.4/requirements.txt +3 -0
- pyreprism-0.0.4/src/PyReprism/__init__.py +1 -0
- pyreprism-0.0.4/src/PyReprism/languages/c.py +113 -0
- pyreprism-0.0.4/src/PyReprism/languages/cpp.py +113 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/csharp.py +33 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/dart.py +25 -0
- pyreprism-0.0.4/src/PyReprism/languages/django.py +124 -0
- pyreprism-0.0.4/src/PyReprism/languages/go.py +82 -0
- pyreprism-0.0.4/src/PyReprism/languages/java.py +113 -0
- pyreprism-0.0.4/src/PyReprism/languages/javascript.py +122 -0
- pyreprism-0.0.4/src/PyReprism/languages/jsx.py +115 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/kotlin.py +37 -5
- pyreprism-0.0.4/src/PyReprism/languages/php.py +124 -0
- pyreprism-0.0.4/src/PyReprism/languages/python.py +124 -0
- pyreprism-0.0.4/src/PyReprism/languages/rust.py +81 -0
- pyreprism-0.0.4/src/PyReprism/languages/scala.py +81 -0
- pyreprism-0.0.4/src/PyReprism/languages/swift.py +81 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/typescript.py +30 -0
- pyreprism-0.0.4/src/PyReprism/languages/vbnet.py +74 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/utils/normalizer.py +2 -2
- pyreprism-0.0.3/PKG-INFO +0 -135
- pyreprism-0.0.3/src/PyReprism/languages/c.py +0 -43
- pyreprism-0.0.3/src/PyReprism/languages/cpp.py +0 -43
- pyreprism-0.0.3/src/PyReprism/languages/django.py +0 -48
- pyreprism-0.0.3/src/PyReprism/languages/go.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/java.py +0 -43
- pyreprism-0.0.3/src/PyReprism/languages/javascript.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/jsx.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/php.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/python.py +0 -50
- pyreprism-0.0.3/src/PyReprism/languages/rust.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/scala.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/swift.py +0 -49
- pyreprism-0.0.3/src/PyReprism/languages/vbnet.py +0 -49
- pyreprism-0.0.3/src/PyReprism/utils/__init__.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.flake8 +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/FUNDING.yaml +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/workflows/ci.yml +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.github/workflows/publish.yml +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.gitignore +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/.readthedocs.yaml +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/LICENSE +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/codecov.yml +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/pytest.ini +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/__init__.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/abap.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/actionscript.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/ada.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/apacheconf.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/apl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/applescript.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/arduino.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/arff.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/asciidoc.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/asm6502.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/aspnet.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/autohotkey.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/autoit.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/bash.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/basic.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/batch.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/bison.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/brainfuck.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/bro.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/clike.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/clojure.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/coffeescript.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/crystal.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/csp.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/css.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/css_extras.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/d.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/diff.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/docker.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/eiffel.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/elixir.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/erb.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/erlang.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/flow.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/fortran.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/fsharp.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/gedcom.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/gherkin.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/git.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/glsl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/graphql.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/groovy.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/haml.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/handlebars.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/haskell.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/haxe.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/hpkp.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/hsts.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/html.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/ichigojam.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/icon.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/inform7.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/ini.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/io.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/j.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/jolie.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/json.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/julia.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/keyman.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/latex.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/less.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/liquid.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/livescript.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/lolcode.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/lua.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/makefile.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/markdown.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/markup.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/markup_templating.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/matlab.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/mel.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/mizar.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/monkey.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/n4js.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/nasm.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/nginx.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/nim.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/nix.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/nsis.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/objectivec.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/ocaml.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/opencl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/oz.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/parigp.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/parser.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/pascal.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/perl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/php_extras.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/plsql.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/powershell.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/processing.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/prolog.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/properties.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/protobuf.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/pug.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/puppet.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/pure.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/q.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/qore.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/r.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/reason.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/renpy.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/rest.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/rip.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/roboconf.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/ruby.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/sas.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/sass.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/scheme.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/scss.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/smalltalk.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/smarty.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/soy.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/stylus.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/tcl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/textile.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/tsx.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/twig.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/velocity.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/verilog.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/vhdl.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/vim.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/visual_basic.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/wasam.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/xeora.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/xojo.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/languages/yaml.py +0 -0
- {pyreprism-0.0.3/src/PyReprism → pyreprism-0.0.4/src/PyReprism/utils}/__init__.py +0 -0
- {pyreprism-0.0.3 → pyreprism-0.0.4}/src/PyReprism/utils/extension.py +0 -0
pyreprism-0.0.4/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: PyReprism
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Framework for Source Code Preprocessing
|
|
5
|
+
Project-URL: Homepage, https://github.com/unlv-evol/PyReprism
|
|
6
|
+
Project-URL: Documentation, https://pyreprism.readthedocs.io
|
|
7
|
+
Project-URL: Issues, https://github.com/unlv-evol/PyReprism/issues
|
|
8
|
+
Author-email: UNLV EVOL LAB <ogenrwot@unlv.nevada.edu>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2024 UNLV EVOL
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
32
|
+
Classifier: Environment :: Console
|
|
33
|
+
Classifier: Intended Audience :: Developers
|
|
34
|
+
Classifier: Intended Audience :: Science/Research
|
|
35
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
+
Classifier: Operating System :: OS Independent
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Requires-Python: >=3.6
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: flake8; extra == 'dev'
|
|
42
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
43
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
44
|
+
Description-Content-Type: text/x-rst
|
|
45
|
+
|
|
46
|
+
.. _intro_toplevel:
|
|
47
|
+
|
|
48
|
+
==================
|
|
49
|
+
Overview / Install
|
|
50
|
+
==================
|
|
51
|
+
|
|
52
|
+
PyReprism is a Python framework that helps researchers and developers the task of source code preprocessing. With PyReprism, you can easily match, extract, count, and remove comments, whitespaces, operators, numbers and other language specific constructs from over 150 programming languages and file extensions.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Requirements
|
|
56
|
+
============
|
|
57
|
+
|
|
58
|
+
* `Python`_ 3.6 or newer
|
|
59
|
+
* `Git`_
|
|
60
|
+
|
|
61
|
+
.. _Python: https://www.python.org
|
|
62
|
+
.. _Git: https://git-scm.com/
|
|
63
|
+
|
|
64
|
+
Installing PyReprism
|
|
65
|
+
====================
|
|
66
|
+
|
|
67
|
+
Installing PyReprism is easily done using `pip`_. Assuming it is installed, just run the following from the command-line:
|
|
68
|
+
|
|
69
|
+
.. _pip: https://pip.pypa.io/en/latest/installing.html
|
|
70
|
+
|
|
71
|
+
.. sourcecode:: none
|
|
72
|
+
|
|
73
|
+
$ pip install PyReprism
|
|
74
|
+
|
|
75
|
+
Source Code
|
|
76
|
+
===========
|
|
77
|
+
|
|
78
|
+
PyReprism's git repo is available on GitHub, which can be browsed at:
|
|
79
|
+
|
|
80
|
+
* https://github.com/unlv-evol/PyReprism.git
|
|
81
|
+
|
|
82
|
+
and cloned using::
|
|
83
|
+
|
|
84
|
+
$ git clone https://github.com/unlv-evol/PyReprism.git
|
|
85
|
+
$ cd PyReprism
|
|
86
|
+
|
|
87
|
+
Optionally (but suggested), make use of virtual environment. Therefore, before installing the requirements run::
|
|
88
|
+
|
|
89
|
+
$ python3 -m venv venv
|
|
90
|
+
$ source venv/bin/activate
|
|
91
|
+
|
|
92
|
+
Install the requirements::
|
|
93
|
+
|
|
94
|
+
$ pip install -r requirements.txt
|
|
95
|
+
|
|
96
|
+
and run the tests using pytest::
|
|
97
|
+
|
|
98
|
+
$ pytest
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
[](https://app.fossa.com/projects/custom%2B46484%2Fgithub.com%2Funlv-evol%2FPyReprism?ref=badge_shield&issueType=security)
|
|
5
5
|
[](https://pyreprism.readthedocs.io/en/latest/?badge=latest)
|
|
6
6
|

|
|
7
|
-
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[](https://codecov.io/gh/unlv-evol/PyReprism)
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
[](https://archive.softwareheritage.org/browse/origin/?origin_url=https://pypi.org/project/PyReprism/)
|
|
8
13
|
|
|
9
14
|
# PyReprism
|
|
10
15
|
|
|
11
|
-
PyReprism is a
|
|
16
|
+
PyReprism is a Python framework that helps researchers and developers the task of source code preprocessing. With PyReprism, you can easily match, extract, count, and remove comments, whitespaces, operators, numbers and other language specific constructs from over **150 programming languages and file extensions**.
|
|
12
17
|
|
|
13
18
|
## Install
|
|
14
19
|
```shell
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.. _intro_toplevel:
|
|
2
|
+
|
|
3
|
+
==================
|
|
4
|
+
Overview / Install
|
|
5
|
+
==================
|
|
6
|
+
|
|
7
|
+
PyReprism is a Python framework that helps researchers and developers the task of source code preprocessing. With PyReprism, you can easily match, extract, count, and remove comments, whitespaces, operators, numbers and other language specific constructs from over 150 programming languages and file extensions.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Requirements
|
|
11
|
+
============
|
|
12
|
+
|
|
13
|
+
* `Python`_ 3.6 or newer
|
|
14
|
+
* `Git`_
|
|
15
|
+
|
|
16
|
+
.. _Python: https://www.python.org
|
|
17
|
+
.. _Git: https://git-scm.com/
|
|
18
|
+
|
|
19
|
+
Installing PyReprism
|
|
20
|
+
====================
|
|
21
|
+
|
|
22
|
+
Installing PyReprism is easily done using `pip`_. Assuming it is installed, just run the following from the command-line:
|
|
23
|
+
|
|
24
|
+
.. _pip: https://pip.pypa.io/en/latest/installing.html
|
|
25
|
+
|
|
26
|
+
.. sourcecode:: none
|
|
27
|
+
|
|
28
|
+
$ pip install PyReprism
|
|
29
|
+
|
|
30
|
+
Source Code
|
|
31
|
+
===========
|
|
32
|
+
|
|
33
|
+
PyReprism's git repo is available on GitHub, which can be browsed at:
|
|
34
|
+
|
|
35
|
+
* https://github.com/unlv-evol/PyReprism.git
|
|
36
|
+
|
|
37
|
+
and cloned using::
|
|
38
|
+
|
|
39
|
+
$ git clone https://github.com/unlv-evol/PyReprism.git
|
|
40
|
+
$ cd PyReprism
|
|
41
|
+
|
|
42
|
+
Optionally (but suggested), make use of virtual environment. Therefore, before installing the requirements run::
|
|
43
|
+
|
|
44
|
+
$ python3 -m venv venv
|
|
45
|
+
$ source venv/bin/activate
|
|
46
|
+
|
|
47
|
+
Install the requirements::
|
|
48
|
+
|
|
49
|
+
$ pip install -r requirements.txt
|
|
50
|
+
|
|
51
|
+
and run the tests using pytest::
|
|
52
|
+
|
|
53
|
+
$ pytest
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PyReprism"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.4"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name= "UNLV EVOL LAB", email="ogenrwot@unlv.nevada.edu" },
|
|
10
10
|
]
|
|
@@ -12,11 +12,11 @@ authors = [
|
|
|
12
12
|
license={file="LICENSE" }
|
|
13
13
|
python_requires = ">=3.5"
|
|
14
14
|
description = "Framework for Source Code Preprocessing"
|
|
15
|
-
readme = "
|
|
15
|
+
readme = "docs/intro.rst"
|
|
16
16
|
requires-python = ">=3.6"
|
|
17
17
|
classifiers = [
|
|
18
18
|
"Environment :: Console",
|
|
19
|
-
"Development Status ::
|
|
19
|
+
"Development Status :: 5 - Production/Stable",
|
|
20
20
|
"Intended Audience :: Developers",
|
|
21
21
|
"Intended Audience :: Science/Research",
|
|
22
22
|
"Programming Language :: Python :: 3",
|
|
@@ -43,4 +43,5 @@ dev = [
|
|
|
43
43
|
|
|
44
44
|
[project.urls]
|
|
45
45
|
Homepage = "https://github.com/unlv-evol/PyReprism"
|
|
46
|
+
Documentation = "https://pyreprism.readthedocs.io"
|
|
46
47
|
Issues = "https://github.com/unlv-evol/PyReprism/issues"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.4"
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class C:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
"""
|
|
12
|
+
Return the file extension used for C files.
|
|
13
|
+
|
|
14
|
+
:return: The file extension for C files.
|
|
15
|
+
:rtype: str
|
|
16
|
+
"""
|
|
17
|
+
return extension.c
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def keywords() -> list:
|
|
21
|
+
"""
|
|
22
|
+
Return a list of C keywords and built-in functions.
|
|
23
|
+
|
|
24
|
+
:return: A list of C keywords and built-in function names.
|
|
25
|
+
:rtype: list
|
|
26
|
+
"""
|
|
27
|
+
keyword = '_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while|define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using|__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr'.split('|')
|
|
28
|
+
return keyword
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def comment_regex() -> re.Pattern:
|
|
32
|
+
"""
|
|
33
|
+
Compile and return a regular expression pattern to identify different types of comments and non-comment code in C source files.
|
|
34
|
+
|
|
35
|
+
:return: A compiled regex pattern with named groups to match single-line comments, multiline comments, and non-comment code elements.
|
|
36
|
+
:rtype: re.Pattern
|
|
37
|
+
"""
|
|
38
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*[^*]*\*+(?:[^/*][^*]*\*+)*?/)|(?P<noncomment>[^/]+)', re.DOTALL | re.MULTILINE)
|
|
39
|
+
return pattern
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def number_regex() -> re.Pattern:
|
|
43
|
+
"""
|
|
44
|
+
Compile and return a regular expression pattern to identify numeric literals in C code.
|
|
45
|
+
|
|
46
|
+
:return: A compiled regex pattern to match C numeric literals, including integers, floats, and complex numbers.
|
|
47
|
+
:rtype: re.Pattern
|
|
48
|
+
"""
|
|
49
|
+
pattern = re.compile(r'(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*')
|
|
50
|
+
return pattern
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def operator_regex() -> re.Pattern:
|
|
54
|
+
"""
|
|
55
|
+
Compile and return a regular expression pattern to identify C operators.
|
|
56
|
+
|
|
57
|
+
:return: A compiled regex pattern to match various C operators and logical keywords.
|
|
58
|
+
:rtype: re.Pattern
|
|
59
|
+
"""
|
|
60
|
+
pattern = re.compile(r'-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]')
|
|
61
|
+
return pattern
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def keywords_regex() -> re.Pattern:
|
|
65
|
+
"""
|
|
66
|
+
Compile and return a regular expression pattern to identify C keywords.
|
|
67
|
+
|
|
68
|
+
:return: A compiled regex pattern to match C keywords.
|
|
69
|
+
:rtype: re.Pattern
|
|
70
|
+
"""
|
|
71
|
+
return re.compile(r'\b(' + '|'.join(C.keywords()) + r')\b')
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def boolean_regex() -> re.Pattern:
|
|
75
|
+
"""
|
|
76
|
+
Compile and return a regular expression pattern to identify C boolean literals.
|
|
77
|
+
|
|
78
|
+
:return: A compiled regex pattern to match C boolean literals.
|
|
79
|
+
:rtype: re.Pattern
|
|
80
|
+
"""
|
|
81
|
+
return re.compile(r'\b(?:true|false)\b')
|
|
82
|
+
|
|
83
|
+
@staticmethod
|
|
84
|
+
def delimiters_regex() -> re.Pattern:
|
|
85
|
+
"""
|
|
86
|
+
Compile and return a regular expression pattern to identify C and C++ delimiters.
|
|
87
|
+
|
|
88
|
+
:return: A compiled regex pattern to match C and C++ delimiters.
|
|
89
|
+
:rtype: re.Pattern
|
|
90
|
+
"""
|
|
91
|
+
return re.compile(r'[()\[\]{}.,:;@<>*&]')
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def remove_comments(source_code: str) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Remove comments from the provided C source code string.
|
|
97
|
+
|
|
98
|
+
:param str source_code: The C source code from which to remove comments.
|
|
99
|
+
:return: The source code with all comments removed.
|
|
100
|
+
:rtype: str
|
|
101
|
+
"""
|
|
102
|
+
return C.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def remove_keywords(source: str) -> str:
|
|
106
|
+
"""
|
|
107
|
+
Remove all C keywords from the provided source code string.
|
|
108
|
+
|
|
109
|
+
:param str source: The source code string from which to remove C keywords.
|
|
110
|
+
:return: The source code string with all C keywords removed.
|
|
111
|
+
:rtype: str
|
|
112
|
+
"""
|
|
113
|
+
return re.sub(re.compile(C.keywords_regex()), '', source)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class CPP:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
"""
|
|
12
|
+
Return the file extension used for C++ files.
|
|
13
|
+
|
|
14
|
+
:return: The file extension for C++ files.
|
|
15
|
+
:rtype: str
|
|
16
|
+
"""
|
|
17
|
+
return extension.cpp
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def keywords() -> list:
|
|
21
|
+
"""
|
|
22
|
+
Return a list of C++ keywords and built-in functions.
|
|
23
|
+
|
|
24
|
+
:return: A list of C++ keywords and built-in function names.
|
|
25
|
+
:rtype: list
|
|
26
|
+
"""
|
|
27
|
+
keyword = 'alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|class|compl|const|constexpr|const_cast|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|float|for|friend|goto|if|inline|int|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t|long|mutable|namespace|new|noexcept|nullptr|operator|private|protected|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|union|unsigned|using|virtual|void|volatile|wchar_t|while|true|false'.split('|')
|
|
28
|
+
return keyword
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def comment_regex() -> re.Pattern:
|
|
32
|
+
"""
|
|
33
|
+
Compile and return a regular expression pattern to identify different types of comments and non-comment code in C source files.
|
|
34
|
+
|
|
35
|
+
:return: A compiled regex pattern with named groups to match single-line comments, multiline comments, and non-comment code elements.
|
|
36
|
+
:rtype: re.Pattern
|
|
37
|
+
"""
|
|
38
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*[^*]*\*+(?:[^/*][^*]*\*+)*?/)|(?P<noncomment>[^/]+)', re.DOTALL | re.MULTILINE)
|
|
39
|
+
return pattern
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def number_regex() -> re.Pattern:
|
|
43
|
+
"""
|
|
44
|
+
Compile and return a regular expression pattern to identify numeric literals in C++ code.
|
|
45
|
+
|
|
46
|
+
:return: A compiled regex pattern to match C++ numeric literals, including integers, floats, and complex numbers.
|
|
47
|
+
:rtype: re.Pattern
|
|
48
|
+
"""
|
|
49
|
+
pattern = re.compile(r'(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*')
|
|
50
|
+
return pattern
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def operator_regex() -> re.Pattern:
|
|
54
|
+
"""
|
|
55
|
+
Compile and return a regular expression pattern to identify C++ operators.
|
|
56
|
+
|
|
57
|
+
:return: A compiled regex pattern to match various C++ operators and logical keywords.
|
|
58
|
+
:rtype: re.Pattern
|
|
59
|
+
"""
|
|
60
|
+
pattern = re.compile(r'--?|\+\+?|!=?|<{1,2}=?|>{1,2}=?|->|:{1,2}|={1,2}|\^|~|%|&{1,2}|\|\|?|\?|\*|\/|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b')
|
|
61
|
+
return pattern
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def keywords_regex() -> re.Pattern:
|
|
65
|
+
"""
|
|
66
|
+
Return a list of C++ keywords and built-in functions.
|
|
67
|
+
|
|
68
|
+
:return: A list of C++ keywords and built-in function names.
|
|
69
|
+
:rtype: list
|
|
70
|
+
"""
|
|
71
|
+
return re.compile(r'\b(' + '|'.join(CPP.keywords()) + r')\b')
|
|
72
|
+
|
|
73
|
+
@staticmethod
|
|
74
|
+
def boolean_regex() -> re.Pattern:
|
|
75
|
+
"""
|
|
76
|
+
Compile and return a regular expression pattern to identify C++ boolean literals.
|
|
77
|
+
|
|
78
|
+
:return: A compiled regex pattern to match C++ boolean literals.
|
|
79
|
+
:rtype: re.Pattern
|
|
80
|
+
"""
|
|
81
|
+
return re.compile(r'\b(?:true|false)\b')
|
|
82
|
+
|
|
83
|
+
@staticmethod
|
|
84
|
+
def delimiters_regex() -> re.Pattern:
|
|
85
|
+
"""
|
|
86
|
+
Compile and return a regular expression pattern to identify C and C++ delimiters.
|
|
87
|
+
|
|
88
|
+
:return: A compiled regex pattern to match C and C++ delimiters.
|
|
89
|
+
:rtype: re.Pattern
|
|
90
|
+
"""
|
|
91
|
+
return re.compile(r'[()\[\]{}.,:;@<>*&]')
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def remove_comments(source_code: str) -> str:
|
|
95
|
+
"""
|
|
96
|
+
Remove comments from the provided C++ source code string.
|
|
97
|
+
|
|
98
|
+
:param str source_code: The C++ source code from which to remove comments.
|
|
99
|
+
:return: The source code with all comments removed.
|
|
100
|
+
:rtype: str
|
|
101
|
+
"""
|
|
102
|
+
return CPP.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def remove_keywords(source: str) -> str:
|
|
106
|
+
"""
|
|
107
|
+
Remove all C++ keywords from the provided source code string.
|
|
108
|
+
|
|
109
|
+
:param str source: The source code string from which to remove C++ keywords.
|
|
110
|
+
:return: The source code string with all C++ keywords removed.
|
|
111
|
+
:rtype: str
|
|
112
|
+
"""
|
|
113
|
+
return re.sub(re.compile(CPP.keywords_regex()), '', source)
|
|
@@ -34,8 +34,41 @@ class CSharp:
|
|
|
34
34
|
def keywords_regex():
|
|
35
35
|
return re.compile(r'\b(' + '|'.join(CSharp.keywords()) + r')\b')
|
|
36
36
|
|
|
37
|
+
@staticmethod
|
|
38
|
+
def boolean_regex() -> re.Pattern:
|
|
39
|
+
"""
|
|
40
|
+
Compile and return a regular expression pattern to identify C# boolean literals.
|
|
41
|
+
|
|
42
|
+
This function generates a regular expression that matches the C# boolean literals `true`, `false`, and the special constant `null`.
|
|
43
|
+
|
|
44
|
+
:return: A compiled regex pattern to match C# boolean literals and `null`.
|
|
45
|
+
:rtype: re.Pattern
|
|
46
|
+
"""
|
|
47
|
+
return re.compile(r'\b(?:true|false|null)\b', re.IGNORECASE)
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def delimiters_regex() -> re.Pattern:
|
|
51
|
+
"""
|
|
52
|
+
Compile and return a regular expression pattern to identify C# delimiters.
|
|
53
|
+
|
|
54
|
+
This function generates a regular expression that matches C# language delimiters, which include parentheses `()`, brackets `[]`, braces `{}`, commas `,`, colons `:`, periods `.`, semicolons `;`, at symbols `@`, angle brackets `<`, `>`, and the question mark `?`.
|
|
55
|
+
|
|
56
|
+
:return: A compiled regex pattern to match C# delimiters.
|
|
57
|
+
:rtype: re.Pattern
|
|
58
|
+
"""
|
|
59
|
+
return re.compile(r'[()\[\]{}.,:;@<>?]')
|
|
60
|
+
|
|
37
61
|
@staticmethod
|
|
38
62
|
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
63
|
+
"""
|
|
64
|
+
Remove comments from the provided Python source code string.
|
|
65
|
+
|
|
66
|
+
:param str source_code: The Python source code from which to remove comments.
|
|
67
|
+
:param bool isList: (Optional) A flag indicating if the input is a list of source code lines. This parameter is not used in the function logic.
|
|
68
|
+
:return: The source code with all comments removed.
|
|
69
|
+
:rtype: str
|
|
70
|
+
"""
|
|
71
|
+
return CSharp.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
39
72
|
result = []
|
|
40
73
|
for match in CSharp.comment_regex().finditer(source_code):
|
|
41
74
|
if match.group('noncomment'):
|
|
@@ -34,8 +34,33 @@ class Dart:
|
|
|
34
34
|
def keywords_regex():
|
|
35
35
|
return re.compile(r'\b(' + '|'.join(Dart.keywords()) + r')\b')
|
|
36
36
|
|
|
37
|
+
@staticmethod
|
|
38
|
+
def delimiters_regex() -> re.Pattern:
|
|
39
|
+
"""
|
|
40
|
+
Compile and return a regular expression pattern to identify Dart language delimiters.
|
|
41
|
+
|
|
42
|
+
This function generates a regular expression that matches Dart language delimiters, which include parentheses `()`, brackets `[]`, braces `{}`, commas `,`, colons `:`, periods `.`, semicolons `;`, and angle brackets `<`, `>`.
|
|
43
|
+
|
|
44
|
+
:return: A compiled regex pattern to match Dart delimiters.
|
|
45
|
+
:rtype: re.Pattern
|
|
46
|
+
"""
|
|
47
|
+
return re.compile(r'[()\[\]{}.,:;<>]')
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def boolean_regex() -> re.Pattern:
|
|
51
|
+
"""
|
|
52
|
+
Compile and return a regular expression pattern to identify Dart boolean literals.
|
|
53
|
+
|
|
54
|
+
This function generates a regular expression that matches the Dart boolean literals `true`, `false`, and the special constant `null`.
|
|
55
|
+
|
|
56
|
+
:return: A compiled regex pattern to match Dart boolean literals and `null`.
|
|
57
|
+
:rtype: re.Pattern
|
|
58
|
+
"""
|
|
59
|
+
return re.compile(r'\b(?:true|false|null)\b')
|
|
60
|
+
|
|
37
61
|
@staticmethod
|
|
38
62
|
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
63
|
+
return Dart.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
39
64
|
result = []
|
|
40
65
|
for match in Dart.comment_regex().finditer(source_code):
|
|
41
66
|
if match.group('noncomment'):
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Django:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
"""
|
|
12
|
+
Return the file extension used for Python files.
|
|
13
|
+
|
|
14
|
+
:return: The file extension for Python files.
|
|
15
|
+
:rtype: str
|
|
16
|
+
"""
|
|
17
|
+
return extension.django
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def keywords() -> list:
|
|
21
|
+
"""
|
|
22
|
+
Return a list of Python keywords and built-in functions.
|
|
23
|
+
|
|
24
|
+
:return: A list of Python keywords and built-in function names.
|
|
25
|
+
:rtype: list
|
|
26
|
+
"""
|
|
27
|
+
keyword = 'load|verbatim|widthratio|ssi|firstof|for|url|ifchanged|csrf_token|lorem|ifnotequal|autoescape|now|templatetag|debug|cycle|ifequal|regroup|comment|filter|endfilter|if|spaceless|with|extends|block|include|else|empty|endif|endfor|as|endblock|endautoescape|endverbatim|trans|endtrans|[Tt]rue|[Ff]alse|[Nn]one|in|is|static|macro|endmacro|call|endcall|set|endset|raw|endraw'.split('|')
|
|
28
|
+
return keyword
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def functions() -> list:
|
|
32
|
+
"""
|
|
33
|
+
Return a list of Python keywords and built-in functions.
|
|
34
|
+
|
|
35
|
+
:return: A list of Python keywords and built-in function names.
|
|
36
|
+
:rtype: list
|
|
37
|
+
"""
|
|
38
|
+
func = 'abs|add|addslashes|attr|batch|callable|capfirst|capitalize|center|count|cut|d|date|default|default_if_none|defined|dictsort|dictsortreversed|divisibleby|e|equalto|escape|escaped|escapejs|even|filesizeformat|first|float|floatformat|force_escape|forceescape|format|get_digit|groupby|indent|int|iriencode|iterable|join|last|length|length_is|linebreaks|linebreaksbr|linenumbers|list|ljust|lower|make_list|map|mapping|number|odd|phone2numeric|pluralize|pprint|random|reject|rejectattr|removetags|replace|reverse|rjust|round|safe|safeseq|sameas|select|selectattr|sequence|slice|slugify|sort|string|stringformat|striptags|sum|time|timesince|timeuntil|title|trim|truncate|truncatechars|truncatechars_html|truncatewords|truncatewords_html|undefined|unordered_list|upper|urlencode|urlize|urlizetrunc|wordcount|wordwrap|xmlattr|yesno'.split('|')
|
|
39
|
+
return func
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def comment_regex() -> re.Pattern:
|
|
43
|
+
"""
|
|
44
|
+
Compile and return a regular expression pattern to identify different types of comments and non-comment code in Python source files.
|
|
45
|
+
|
|
46
|
+
:return: A compiled regex pattern with named groups to match single-line comments, multiline comments, and non-comment code elements.
|
|
47
|
+
:rtype: re.Pattern
|
|
48
|
+
"""
|
|
49
|
+
pattern = re.compile(r'(?P<comment>#.*?$)|'r'(?P<multilinecomment1>""".*?""")|'r'(?P<multilinecomment2>\'\'\'.*?\'\'\')|'r'(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#\'"]*)', re.DOTALL | re.MULTILINE)
|
|
50
|
+
return pattern
|
|
51
|
+
|
|
52
|
+
@staticmethod
|
|
53
|
+
def number_regex() -> re.Pattern:
|
|
54
|
+
"""
|
|
55
|
+
Compile and return a regular expression pattern to identify numeric literals in Python code.
|
|
56
|
+
|
|
57
|
+
:return: A compiled regex pattern to match Python numeric literals, including integers, floats, and complex numbers.
|
|
58
|
+
:rtype: re.Pattern
|
|
59
|
+
"""
|
|
60
|
+
pattern = re.compile(r'')
|
|
61
|
+
return pattern
|
|
62
|
+
|
|
63
|
+
@staticmethod
|
|
64
|
+
def operator_regex() -> re.Pattern:
|
|
65
|
+
"""
|
|
66
|
+
Compile and return a regular expression pattern to identify Python operators.
|
|
67
|
+
|
|
68
|
+
:return: Regex pattern to match various Python operators and logical keywords.
|
|
69
|
+
:rtype: re.Pattern
|
|
70
|
+
"""
|
|
71
|
+
pattern = re.compile(r'')
|
|
72
|
+
return pattern
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def keywords_regex() -> re.Pattern:
|
|
76
|
+
"""
|
|
77
|
+
Compile and return a regular expression pattern to identify Python keywords.
|
|
78
|
+
|
|
79
|
+
:return: A compiled regex pattern to match Python keywords.
|
|
80
|
+
:rtype: re.Pattern
|
|
81
|
+
"""
|
|
82
|
+
return re.compile(r'\b(' + '|'.join(Django.keywords()) + r')\b')
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def boolean_regex() -> re.Pattern:
|
|
86
|
+
"""
|
|
87
|
+
Compile and return a regular expression pattern to identify Python boolean literals.
|
|
88
|
+
|
|
89
|
+
:return: A compiled regex pattern to match Python boolean literals and `None`.
|
|
90
|
+
:rtype: re.Pattern
|
|
91
|
+
"""
|
|
92
|
+
return re.compile(r'\b(?:True|False|None)\b')
|
|
93
|
+
|
|
94
|
+
@staticmethod
|
|
95
|
+
def delimiters_regex() -> re.Pattern:
|
|
96
|
+
"""
|
|
97
|
+
Compile and return a regular expression pattern to identify Python delimiters.
|
|
98
|
+
|
|
99
|
+
:return: A compiled regex pattern to match Python delimiters.
|
|
100
|
+
:rtype: re.Pattern
|
|
101
|
+
"""
|
|
102
|
+
return re.compile(r'[()\[\]{}.,:;@]')
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def remove_comments(source_code: str) -> str:
|
|
106
|
+
"""
|
|
107
|
+
Remove comments from the provided Python source code string.
|
|
108
|
+
|
|
109
|
+
:param str source_code: The Python source code from which to remove comments.
|
|
110
|
+
:return: The source code with all comments removed.
|
|
111
|
+
:rtype: str
|
|
112
|
+
"""
|
|
113
|
+
return Django.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
114
|
+
|
|
115
|
+
@staticmethod
|
|
116
|
+
def remove_keywords(source: str) -> str:
|
|
117
|
+
"""
|
|
118
|
+
Remove all Python keywords from the provided source code string.
|
|
119
|
+
|
|
120
|
+
:param str source: The source code string from which to remove Python keywords.
|
|
121
|
+
:return: The source code string with all Python keywords removed.
|
|
122
|
+
:rtype: str
|
|
123
|
+
"""
|
|
124
|
+
return re.sub(re.compile(Django.keywords_regex()), '', source)
|