properties-tools
properties-tools is a collection of command line tools to work with properties files: comparing like wdiff, updating like patch...
The idea is to work with the content (key/value pairs) instead of the text, to ignore order or format and deal with the data.
properties-diffcan compare and print differences between 2 properties files, with fancy colors as if you were usingwdiffordifftools. It does not compare the text files.properties-patchcan update a properties file using values from others, you can choose to add new keys and/or update existing and/or remove others.
Install
Install the latest release from PyPI
$ pip3 install properties-diff
$ properties-diff --help
Install from the sources
$ pip3 install poetry
$ pip3 install git+https://github.com/essembeh/properties-tools
$ properties-diff --help
properties-diff
Usage
$ properties-diff --help
usage: properties-diff [-h] [--version] [-q] [--quote] [--color | --nocolor] [--sep SEP] [-m {simple,diff,wdiff} | --diff | --wdiff | --simple] [-A] [-D] [-U] left.properties right.properties
positional arguments:
left.properties left file to compare
right.properties right file to compare
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
-q, --quiet print less information
--quote use double quotes for values, example: foo="bar"
--color force colors
--nocolor disable colors
--sep SEP key/value separator, default is '='
-m {simple,diff,wdiff}, --mode {simple,diff,wdiff}
select a format to show differences: using colors only (simple), using diff-like format (diff) or wdiff-like (wdiff) format. Default is 'wdiff'
--diff use diff-like format to show differences
--wdiff use wdiff-like format to show differences
--simple use simple format to show differences
-A, --added print added properties
-D, --deleted print deleted properties
-U, --updated print updated properties
Examples
Comparing properties files like wdiff
$ properties-diff tests/sample1.properties tests/sample2.properties
--- tests/sample1.properties (left) 2022-04-07 12:48:44
+++ tests/sample2.properties (right) 2022-04-07 12:49:02
# Only in tests/sample1.properties (left)
[-database.host=localhost-]
# Only in tests/sample2.properties (right)
{+database.version=12+}
# Updated from tests/sample1.properties (left) to tests/sample2.properties (right)
database.type=[-postgresql-]{+mysql+}
database.user=[-test-]{+dbuser+}
Comparing properties files like diff
$ properties-diff tests/sample1.properties tests/sample2.properties --diff
--- tests/sample1.properties (left) 2022-04-07 12:48:44
+++ tests/sample2.properties (right) 2022-04-07 12:49:02
# Only in tests/sample1.properties (left)
- database.host=localhost
# Only in tests/sample2.properties (right)
+ database.version=12
# Updated from tests/sample1.properties (left) to tests/sample2.properties (right)
- database.type=postgresql
+ database.type=mysql
- database.user=test
+ database.user=dbuser
Compare files, but only show updateed and added values
$ properties-diff tests/sample1.properties tests/sample2.properties --add --update
--- tests/sample1.properties (left) 2022-04-07 12:48:44
+++ tests/sample2.properties (right) 2022-04-07 12:49:02
# Only in tests/sample2.properties (right)
{+database.version=12+}
# Updated from tests/sample1.properties (left) to tests/sample2.properties (right)
database.type=[-postgresql-]{+mysql+}
database.user=[-test-]{+dbuser+}
Viewing modes
You can see differences between the properties files using 3 modes using --mode <MODE> or -m <MODE>
wdiff, prints the changes likewdifftool would do (this is the default mode)diff, prints the changes likedifftool would dosimple, based on colors, red for removed lines, green for added lines
properties-patch
Usage
$ properties-patch --help
usage: properties-patch [-h] [--version] [--color | --nocolor] [-c] [-i] [--quote] [--sep SEP] [-A] [-D] [-U] -p patch.properties [-o output.properties | -w] [-f] source.properties
positional arguments:
source.properties file to modify
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
--color force colors
--nocolor disable colors
-c, --comments insert comment when property is added, updated or deleted
-i, --interactive ask for confirmation to add, update or delete a property
--quote use double quotes for values, example: foo="bar"
--sep SEP key/value separator, default is '='
-p patch.properties, --patch patch.properties
patch file
-o output.properties, --output output.properties
modified file
-w, --overwrite update input properties file in place
-f, --force force output file (--output) overwrite if it already exists
-A, --add add new properties from patches
-D, --delete delete properties not in patches
-U, --update update properties from patches
Examples
Build a properties file from tests/sample1.properties and add missing keys from tests/sample2.properties
$ properties-patch tests/sample1.properties --patch tests/sample2.properties --add
# just a comment
database.type=postgresql
database.host=localhost
database.port=5432
# and another comment
database.user=test
database.password=foobar
database.version=12
You can use multiple patch files, if a value is present in multiple patch files, the latest value will be used.
$ properties-patch tests/sample1.properties --patch tests/sample2.properties --patch tests/sample3.properties -A
# just a comment
database.type=postgresql
database.host=localhost
database.port=5432
# and another comment
database.user=test
database.password=foobar
database.version=42
You can choose to add missing values and update values that are different in the patch files
$ properties-patch tests/sample1.properties --patch tests/sample2.properties -AU
# just a comment
database.type=mysql
database.host=localhost
database.port=5432
# and another comment
database.user=dbuser
database.password=foobar
database.version=12
There is an interactive mode, which ask for confirmation before every change (usefull to take only some changes, equivalent to git add --interactive)
$ properties-patch tests/sample1.properties --patch tests/sample2.properties -AU --interactive
# just a comment
💬 Update database.type=postgresql,mysql ? [Y/n]
database.type=mysql
database.host=localhost
database.port=5432
# and another comment
💬 Update database.user=test,dbuser ? [Y/n]
database.user=dbuser
database.password=foobar
💬 Add database.version=12 ? [Y/n]
database.version=12
To track changes, you can add comments for every change applied
$ properties-patch tests/sample1.properties --patch tests/sample2.properties -ADU --comments
# just a comment
# 2022-04-07 23:12:11 update: database.type=postgresql
database.type=mysql
# 2022-04-07 23:12:11 remove: database.host=localhost
database.port=5432
# and another comment
# 2022-04-07 23:12:11 update: database.user=test
database.user=dbuser
database.password=foobar
# 2022-04-07 23:12:11 add: database.version
database.version=12
Metadata
Release files for properties-tools 0.7.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| properties_tools-0.7.2.tar.gz | 13.7 kB | Without provenance | Details for properties_tools-0.7.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| properties_tools-0.7.2-py3-none-any.whl | Python 3 | none | any | Details for properties_tools-0.7.2-py3-none-any.whl |
Total release size: 27.4 kB
Release files / properties_tools-0.7.2.tar.gz
| Download URL | properties_tools-0.7.2.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c2eea46f0b86dc3de5c7fcc4c80dab778e0f5f2e81ef0cc83255c310e153d7d
|
|
BLAKE2b-256 checksum How to use checksums |
43b3693da4159cdb012f7cf8fe790a5c586e0d72dc2098b4e1e979da675c4a76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1022-azure
|
Release files / properties_tools-0.7.2-py3-none-any.whl
| Download URL | properties_tools-0.7.2-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8619b4107e9c3626fc435672140326f812a509042e39a23143593660f6f627c
|
|
BLAKE2b-256 checksum How to use checksums |
e66fca89676a2c7b71bfcde137f401a6eb3d30e351e116a873e817be8cf84347
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.9.15 Linux/5.15.0-1022-azure
|
Security for properties-tools 0.7.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.