Check Python files for repeat use of strings
Project description
Check Python files for repeat use of strings
Defaults can be configured in your pyproject.toml file
Installation
$ pip install constcheck
Usage
Commandline
usage: constcheck [-h] [-p PATH] [-c INT] [-l INT] [-s STR] [-i LIST] [-I LIST] [-f] [-n] [-v]
- optional arguments:
- -h, --help
show this help message and exit
- -p PATH, --path PATH
path to check files for (default: .)
- -c INT, --count INT
minimum number of repeat strings (default: 3)
- -l INT, --len INT
minimum length of repeat strings (default: 3)
- -s STR, --string STR
parse a string instead of a file
- -i LIST, --ignore-strings LIST
comma separated list of strings to exclude
- -I LIST, --ignore-files LIST
comma separated list of files to exclude
- -f, --filter
filter out empty results
- -n, --no-color
disable color output
- -v, --version
show version and exit
API
>>> import constcheck
>>> EXAMPLE = """
... STRING_1 = "Hey"
... STRING_2 = "Hey"
... STRING_3 = "Hey"
... STRING_4 = "Hello"
... STRING_5 = "Hello"
... STRING_6 = "Hello"
... STRING_7 = "Hello"
... STRING_8 = "Hello, world"
... STRING_9 = "Hello, world"
... STRING_10 = "Hello, world"
... STRING_11 = "Hello, world"
... STRING_12 = "Hello, world"
... """
>>> constcheck.main(string=EXAMPLE)
3 | Hey
4 | Hello
5 | Hello, world
<BLANKLINE>
With the count argument
>>> constcheck.main(string=EXAMPLE, count=4)
4 | Hello
5 | Hello, world
<BLANKLINE>
With the len argument
>>> constcheck.main(string=EXAMPLE, len=6)
5 | Hello, world
<BLANKLINE>
With the ignore_strings argument which accepts a str iterable
>>> constcheck.main(string=EXAMPLE, ignore_strings=["Hello, world", "Hello"])
3 | Hey
<BLANKLINE>
>>> constcheck.main(string=EXAMPLE, ignore_strings="Hello, world")
3 | Hey
<BLANKLINE>
Config
All keyword arguments available to constcheck.main() can be configured in the pyproject.toml file
[tool.constcheck]
path = "."
count = 3
len = 3
ignore_strings = ["Hello", "Hello, world"]
ignore_files = ["tests/__init__.py"]
filter = false
no_color = false
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file constcheck-0.2.0.tar.gz
.
File metadata
- Download URL: constcheck-0.2.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.11+ Linux/5.16.18-200.fc35.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5931f8d70aa2b4ce73ccd5750b59c5ca7ff8f5e37d361b94d6f2341162b971ae |
|
MD5 | 47da432f3eeb864e3dd10f9abec8b69f |
|
BLAKE2b-256 | fc5acfa06f5c31ad5a8a8005df46d07d7fd73c5c7e0f39dd07bdb1027607a89a |
File details
Details for the file constcheck-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: constcheck-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.11+ Linux/5.16.18-200.fc35.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6dc16b766c4368c67b161ed7598342ceb5b5837ae1ac18e08d44d2cc9ad70a0 |
|
MD5 | b3bae177579ee3c5db6d06d7ec4e6b86 |
|
BLAKE2b-256 | 16965b5ba54d8354acb604667581cb9d44686b7481765b92a665a6f6d85413d0 |