Check configuration files.
Project description
Check Config
It can be cumbersome when you have multiple projects and environments with configuration files which need to be
upgraded and keep in sync regulary. Check-config will help you with i.e. making sure that the configuration
file (pyroject.toml
, packages.json
, ...) have the (upgraded) settings.
Installation
The preferred installation is via pip(x), indifferent whether you are Windows, Linux or Mac:
pip install check_config
or
pipx install check_config
Alternatively you can use:
cargo install check_config
Usage
With the next command you can check your configuration files
check_config
This will use the checkers as defined in checkers.toml
, but you can specify another path:
check_config -p <path>
Optionally you can not just check your files, but also try to fix them:
check_config --fix
Checkers
Check Config uses checkers
which define the desired state of the configuration files. There are several
checker types (and more to come):
name | description | fixable |
---|---|---|
file_absent | the file must be absent | yes |
file_present | the file must be present, indifferent the content | yes |
key_absent | a specified key must be absent in a toml / yaml / json file | yes |
key_value_present | a specified key with a specified value must be present in a toml / yaml / json file | yes |
key_value_regex_match | the value of a specified key must be match the specified regex in a toml / yaml / json file | no |
lines_absent | the specified lines must be absent | yes |
lines_present | the specified lines must be present | yes |
Checker.toml
The checkers.toml
consist of zero or one check-config
tables with configuration for check-config itself:
[check-config]
additional_checks = [] # optional list of toml files with additional checks
And one or more checkers
["<file_path>".<checker_name>.<checker_keys>]
key = value
The syntax is slightly different per check type. See the next sections for help about the checker definitions.
File Absent
file_absent
will check if the file is absent.
The next example will check that test/absent_file
will be absent.
["test/absent_file".file_absent]
File Present
file_present
will check if the file is present.
The next example will check that test/present_file
will be present. It will
not check the contents.
["test/present_file".file_present]
Key Absent
key_absent
will check if the key is not present in the file.
The next example will check that test/present_file
has no key named key
.
["test/present.toml".key_absent.key]
The key can be nested. In the next case it is sufficient that key
is not present.
super_key
may be present or absent.
["test/present.toml".key_absent.super_key.key]
This checker type can handle different kind of mapping file types
Key Value Present
key_value_present
will check that the keys specified are present with the specified values.
Keys may be nested. Intermediate keys has to have mappings as values. When intermediate values
are not present, they will be added.
["test/present.toml".key_value_present]
key1 = 1
key2 = "value"
["test/present.toml".key_value_present.super_key]
key1 = 1
key2 = "value"
This checker type can handle different kind of mapping file types
Key Value Regex Match
key_value_regex_match
will check that the keys specified are present and the value matches the specified regex.
Of course, the regex can only match string values.
Keys may be nested. Intermediate keys has to have mappings as values. When intermediate values
are not present, they will be added.
["test/present.toml".key_value_regex_match]
key = 'v.*'
["test/present.toml".key_value_regex_match.super_key]
key = '[0-9]*'
Note: specify the regex as a raw string (single quotes) to be prevent escaping.
This checker type can handle different kind of mapping file types
Lines Absent
lines_absent
will check that the file does not contain the lines as specified.
["test/present.txt".lines_absent]
__lines__ = """\
multi
line"""
["test/present.txt".lines_absent]
__lines__ = """single line"""
Lines Present
lines_present
will check that the file does not contain the lines as specified.
["test/present.txt".lines_present]
__lines__ = """\
multi
line"""
["test/present.txt".lines_present]
__lines__ = """single line"""
Mapping File Types
The checker types with a key (key_absent, key_value_present, key_value_regex_match) can we used on several file types which contains mappings:
type | extension |
---|---|
toml | toml |
yaml | yaml, yml |
json | json |
The filetype will be determined by the extension. You can override this by specifying the filetype:
["test/present.toml".key_value_present]
__filetype__ = "json"
key1 = 1
key2 = "value"
Suggestions? Questions?
Let us known!
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 Distributions
Hashes for check_config-0.1.0-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d474d87b00aac108e96ca0d31b4c5c8b311117ad1ea6e820cf312f819c9ef09 |
|
MD5 | cb66842bb13de881179da8f3f82677cb |
|
BLAKE2b-256 | 0c0a9927418d7b6416924fbbb028858dc8c95fcc60177c6ed7aad971b6a84edf |
Hashes for check_config-0.1.0-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81aa43aa58dbb3fb34cbd4ff9bde7cd279015a9424ea9f751f6310dd8c6682d5 |
|
MD5 | 283450901de3bb5358cbcc3221cecf07 |
|
BLAKE2b-256 | 1b80fd9e2a1fc8e49fd7c97c60a2204d2de19526269402a7853ad6f9494e5116 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51ffd2b63d1e98a27e1d67ce3bfa33446ebbd743157ad44789293da9fc386264 |
|
MD5 | a416d01301e9feba465f64d965683501 |
|
BLAKE2b-256 | 6a8ffd46a065be8b816cab0c067e4d10cd8790ad5156ee9c85567fa7a55c7540 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0b3b21283f5b8af7f16562ae3dc360b3869823765af0766e1781798562dbb8d |
|
MD5 | 7f0a9cf5938fde407b6c3837e1a97846 |
|
BLAKE2b-256 | ba1ce4a1369a8b3508deb988432c25e29afbccd523f3c3753be32a87be924ae4 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbbef9d6f5935ca0b7be3f4690c2a654582efaac335f721a6f481df645595b30 |
|
MD5 | 01c3b5e0b238c4b088e954b8587fa47e |
|
BLAKE2b-256 | 983266892412dfe242e7538ee90a9e47b4a96835fbc9220be8a1c83de67d8cc4 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52fa8b59e9d988e61a00a4aa6d43170a181389a8c3e14d6beab51f4e44f6753f |
|
MD5 | 8ed0ce1a84e58e4e63c00d3c4269d117 |
|
BLAKE2b-256 | a41d81e8485bd6850e9c72c41425fff91baf8d9d334453a00011528ed899bbd3 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41b215cecf19f7f1ff52ec02f8f4bbda3d4b6583257a8e7181647e88f3d458c1 |
|
MD5 | e8cc96909e26b441260394f0a27ca25b |
|
BLAKE2b-256 | be7dd88a09218de987e193be0d11ad57cc506f264276b3de4dc1c1fe076c4c58 |
Hashes for check_config-0.1.0-py3-none-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 416fb71edbbeac8e0371d114a7372675d39e9de2bd504aa975ea9eb14ca2861c |
|
MD5 | 8b6577552c1484631ac2778e25abb042 |
|
BLAKE2b-256 | 44ae9157599e8335a21cac4ebd0f0ef2fa138af0a47ec009883a45bdd2855b73 |
Hashes for check_config-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee5b1b6aa30ac912352e8142fa7958a887fdd46e3cf551aba787933920e43af2 |
|
MD5 | a4d6d3abcc2f98b33fa0562d6f39e695 |
|
BLAKE2b-256 | 34f520e8bb6267aed2d405e716eb6aedb02db2e2b67f35413a04885db093c2ef |
Hashes for check_config-0.1.0-py3-none-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb78e2888fe58cea52bea24d62d3eb0a47f1b36a90522cb891786c83c35f5d7a |
|
MD5 | c4f124804b33b96753c5ba501d1cc9d3 |
|
BLAKE2b-256 | 75671b2a5bb3a7285c623bd34200e0149608d09be51bdc240c7c06edb14c184a |