Skip to content

Commit e01b79f

Browse files
Add files via upload
1 parent 5d7f732 commit e01b79f

18 files changed

+4931
-8
lines changed

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 JavaScriptDude
3+
Copyright (c) 2022 Timothy C. Quinn <javascriptdude [at] protonmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

MANIFEST.in

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include README.md
2+
include LICENSE
3+
include pyproject.toml

README.md

+30-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ python3 -m pip install commstrip
1212
* emacs 28.1+
1313
* language files for languages that need processing
1414

15-
Note: This code is presently written for Linux and shoudl work out of the box on MacOS and Cygwin. Windows support is planned.
15+
Note: This code is presently written for Linux and should work out of the box on MacOS and Cygwin but has not been tested there yet. Windows support is planned.
1616

17-
### Create Alias - Add to ~/.bashrc
17+
### Create Alias
18+
Add to `~/.bashrc`:
1819
```
1920
function __comstrip {
2021
python3 /dpool/vcmain/dev/lisp/comstrip/src/comstrip/comstrip.py "$@"
@@ -24,13 +25,13 @@ alias comstrip='__comstrip'
2425

2526
### CLI Usage:
2627

27-
#### 3-way meld compare
28+
#### CLI - 3-way meld compare
2829
Compare /r1/src1.py to /r2/src2.py and /r2/src3.py, strip comments, blank lines and trailing spaces and launch in meld
2930
```
3031
comstrip --basedir /dpool/vcmain/dev/lisp/comstrip/test/data --noblank --notrail --meld --file /r1/src1.py /r2/src2.py /r3/src3.py
3132
```
3233

33-
## Stats only
34+
#### CLI - Stats only
3435
Compare /r1/src1.py to /r3/src1.py, strip comments, blank lines and trailing spaces and show stats
3536
```
3637
comstrip --basedir /dpool/vcmain/dev/lisp/comstrip/test/data --noblank --notrail --stats --file /r1/src1.py /r3/src2.py
@@ -47,13 +48,36 @@ Stats: /r1/src1.py <-> /r3/src1.py (/dpool/vcmain/dev/lisp/comstrip/test/data):
4748
/r3/vtscan.py | /tmp/cs_zz_cs_220420-211346.452998_vtscan_211347429.py | True | -
4849
```
4950

51+
#### CLI - Use Meld to troubleshoot stripping of comments etc.
52+
Call with --meld option and pass only one file Meld will be launched showing the before and after of comment stripping
53+
This can be used as you tweak your emacs packages to ensure that the Language processsing is working as expected
54+
```
55+
comstrip --meld --noblank --notrail --file /dpool/vcmain/dev/lisp/comstrip/test/data/r3/src1.py
56+
```
57+
5058
### Python API Usage:
51-
See `test/comstrip_test.py` for API examples
59+
* ComStrip - Main API Object
60+
* DiffStats - Object containging diff information including stats
61+
* Diff - Representation of two files and contains a `stats:DiffStats` after processing
62+
* DiffSet - Collection of Diffs for batch processing
63+
* CSStat - Contains info about Comment Strip Processing: ok, file_in, file_out, message
64+
65+
Because of overhead of invoking sub-processes, it is best to use API that can process mulitple files in one batch, it is strongly recommended to use `<ComStrip>.process(diffset:DiffSet)` or `<ComStrip>.process(files:list)` to leverage the optimizations in those APIs.
66+
67+
See `test/hand_tests.py` for implementation of the four API call types: `diffset:DiffSet`, `diff:Diff`, `files:list` and `file:str`.
5268

5369

70+
### Debug using VSCode after git checkout
71+
If you want to play around without having to install, just do a git checkout of the repo and add to your `.vscode/settings.json`:
72+
```
73+
{
74+
"python.envFile": "${workspaceFolder}/dev.env"
75+
}
76+
```
77+
5478
### TODO:
5579
[.] Make proper installer for system to get comstrip command working without alias
5680
[.] Port to Windows
5781
[.] Verify in Cygwin and MacOs
5882
[.] Build out proper testing
59-
[.] Implement leading tab handling
83+
[.] Implement leading tab handling

dev.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PYTHONPATH=./src:${PYTHONPATH}

examples/example_emacs.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ELISP="(load \"/dpool/vcmain/dev/lisp/comstrip/comstrip.lisp\")"
2+
emacs --file=/dpool/vcmain/dev/py/ffr/ffr.py --quick --batch --eval "$ELISP"
3+
emacs --file=/dpool/vcmain/dev/py/ffrc/ffrc.py --quick --batch --eval "$ELISP"
4+
emacs --file=/dpool/vcmain/dev/py/qcorelite/qcorelite.py --quick --batch --eval "$ELISP"

pyproject.toml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[tool.poetry]
2+
name = "comstrip"
3+
version = "0.0.1"
4+
description = "Universal Code Comment Stripper and Diff Analysis tools leveraging Emacs Language support"
5+
license = "MIT"
6+
authors = ["Timothy C. Quinn"]
7+
readme = "README.md"
8+
homepage = "https://pypi.org/project/comstrip"
9+
repository = "https://github.com/JavaScriptDude/comstrip"
10+
classifiers = [
11+
'Development Status :: 4 - Beta',
12+
'Environment :: Console',
13+
'Intended Audience :: Developers',
14+
'Operating System :: POSIX :: Linux',
15+
'Operating System :: POSIX :: BSD',
16+
'Operating System :: POSIX :: SunOS/Solaris',
17+
'Operating System :: MacOS :: MacOS X',
18+
'Programming Language :: Python :: 3 :: Only',
19+
'Programming Language :: Python :: 3.7',
20+
'Programming Language :: Python :: 3.8',
21+
'Programming Language :: Python :: 3.9',
22+
'Programming Language :: Python :: 3.10',
23+
'Topic :: Software Development',
24+
]
25+
26+
[tool.poetry.dependencies]
27+
python = "^3.7.9"
28+
thefuzz = ">=0.19.0"
29+
python-Levenshtein = ">=0.12.2"
30+
texttable = ">=1.6.3"
31+
tiotrap = ">=0.3"
32+
33+
[tool.poetry.dev-dependencies]
34+
35+
[build-system]
36+
requires = ["poetry-core>=1.0.0"]
37+
build-backend = "poetry.core.masonry.api"

requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
thefuzz
2+
python-Levenshtein
3+
tiotrap
4+
texttable

src/comstrip/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Main objects
2+
from .comstrip import ComStrip, DiffSet, Diff, CSStat
3+
# Helpful utilities
4+
from .comstrip import util as csutil

0 commit comments

Comments
 (0)