diff options
author | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:13:03 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:13:03 +0000 |
commit | da36de825816c19eee8bb0cd23543d0676753930 (patch) | |
tree | 54ca4ee9ce45d41da3e2de0924a4f9fc7408aef8 | |
parent | 040323e87090be5547c5f54c93ce91f58a7e771d (diff) |
automatic import of python-sdeopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-sde.spec | 515 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 517 insertions, 0 deletions
@@ -0,0 +1 @@ +/sde-1.1.9.tar.gz diff --git a/python-sde.spec b/python-sde.spec new file mode 100644 index 0000000..fdf4232 --- /dev/null +++ b/python-sde.spec @@ -0,0 +1,515 @@ +%global _empty_manifest_terminate_build 0 +Name: python-sde +Version: 1.1.9 +Release: 1 +Summary: A CLI tool to edit simple JSON and YAML data files +License: BSD +URL: https://github.com/dvershinin/sde +Source0: https://mirrors.aliyun.com/pypi/web/packages/0d/9a/e84d0251dbc44ea6878f632f555055b573d1947b6efda076a6fa6627debf/sde-1.1.9.tar.gz +BuildArch: noarch + +Requires: python3-six +Requires: python3-pyyaml +Requires: python3-six +Requires: python3-pyyaml +Requires: python3-pytest +Requires: python3-flake8 +Requires: python3-pytest-xdist +Requires: python3-mkdocs +Requires: python3-mkdocs-material +Requires: python3-mkdocstrings +Requires: python3-markdown-include +Requires: python3-mkdocs +Requires: python3-mkdocs-material +Requires: python3-mkdocstrings +Requires: python3-markdown-include +Requires: python3-six +Requires: python3-pyyaml +Requires: python3-pytest +Requires: python3-flake8 +Requires: python3-pytest-xdist + +%description +# sde + +[](https://badge.fury.io/py/sde) + +`sde` is not `sed`. It's a structured data editor for CLI. + +## Why? + +Many people asked for a simple JSON in-place editing and `jq` was the solution: + +* [Modify a key-value in a json using jq in-place](https://stackoverflow.com/questions/42716734/modify-a-key-value-in-a-json-using-jq-in-place) +* [How to modify a key's value in a JSON file from command line](https://stackoverflow.com/questions/43292243/how-to-modify-a-keys-value-in-a-json-file-from-command-line) + +```bash +jq '.address = "abcde"' test.json|sponge test.json +``` + +Does this seem readable or elegant to you? + +How about this instead: + +```bash +sde address abcde test.json +``` + +`sde` is not a substitute for `jq` or `sed`. + +It allows *simple* in-place JSON/YAML value changes, for *structured* data. + +### Sample JSON + +```json +{ + "name":"John", + "age":31, + "city":"New York", + "extra": { + "gender": null + } +} +``` + +### Sample YAML + +```yaml +database: + user: example + password: secret +``` + +### Modify data + +```bash +sde name Jack data.json +sde extra.gender male data.json +sde database.user john data.yml +``` + +It is possible to modify data in arrays using a dotted notation. Let's take another sample: + +```json +{ + "users": [ + { + "username": "foo", + "enabled": true + }, + { + "username": "bar", + "enabled": true + } + ], +} +``` + +We can set the first user's `enabled` property to `false`: + +```bash +sde users.0.enabled false data.json +``` + +## Installation for CentOS/RHEL 7, 8 or Amazon Linux 2, or Fedora Linux + +```bash +sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm +sudo yum -y install sde +``` + +## Installation for other systems + +Installing with `pip` is easiest: + +```bash +pip install sde +``` + +## Notes + +### Quoting in JSON + +Quoting is avoided for `null`, `true`, `false`, and numeric values. +To ensure that a given value is quoted, use `-s` (or `--string`) option: + +```bash +sde -s key null file.json +``` + +### Force-fail on missing keys + +If you must *edit* the file, by ensuring to update only the existing key, use `-e` (`--must-exist`) +option. The program will exit without adding the key which doesn't exist. + +```bash +sde -e key val file.json +``` + +### Force-fail on unchanged file + +If the data is unchanged after running `sde` (values already match), you can force +a failure exit code `2` by passing the `-m` option: + +```bash +sde -m key sameval file.json +# > exit code 0 +sde -m key sameval file.json +# > exit code 2 +``` + +## TODO + +### Work with stdin + +```bash +echo $json | sde name Jack +``` + +### Query simple data + +```bash +sdg name data.json +``` + + +%package -n python3-sde +Summary: A CLI tool to edit simple JSON and YAML data files +Provides: python-sde +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-sde +# sde + +[](https://badge.fury.io/py/sde) + +`sde` is not `sed`. It's a structured data editor for CLI. + +## Why? + +Many people asked for a simple JSON in-place editing and `jq` was the solution: + +* [Modify a key-value in a json using jq in-place](https://stackoverflow.com/questions/42716734/modify-a-key-value-in-a-json-using-jq-in-place) +* [How to modify a key's value in a JSON file from command line](https://stackoverflow.com/questions/43292243/how-to-modify-a-keys-value-in-a-json-file-from-command-line) + +```bash +jq '.address = "abcde"' test.json|sponge test.json +``` + +Does this seem readable or elegant to you? + +How about this instead: + +```bash +sde address abcde test.json +``` + +`sde` is not a substitute for `jq` or `sed`. + +It allows *simple* in-place JSON/YAML value changes, for *structured* data. + +### Sample JSON + +```json +{ + "name":"John", + "age":31, + "city":"New York", + "extra": { + "gender": null + } +} +``` + +### Sample YAML + +```yaml +database: + user: example + password: secret +``` + +### Modify data + +```bash +sde name Jack data.json +sde extra.gender male data.json +sde database.user john data.yml +``` + +It is possible to modify data in arrays using a dotted notation. Let's take another sample: + +```json +{ + "users": [ + { + "username": "foo", + "enabled": true + }, + { + "username": "bar", + "enabled": true + } + ], +} +``` + +We can set the first user's `enabled` property to `false`: + +```bash +sde users.0.enabled false data.json +``` + +## Installation for CentOS/RHEL 7, 8 or Amazon Linux 2, or Fedora Linux + +```bash +sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm +sudo yum -y install sde +``` + +## Installation for other systems + +Installing with `pip` is easiest: + +```bash +pip install sde +``` + +## Notes + +### Quoting in JSON + +Quoting is avoided for `null`, `true`, `false`, and numeric values. +To ensure that a given value is quoted, use `-s` (or `--string`) option: + +```bash +sde -s key null file.json +``` + +### Force-fail on missing keys + +If you must *edit* the file, by ensuring to update only the existing key, use `-e` (`--must-exist`) +option. The program will exit without adding the key which doesn't exist. + +```bash +sde -e key val file.json +``` + +### Force-fail on unchanged file + +If the data is unchanged after running `sde` (values already match), you can force +a failure exit code `2` by passing the `-m` option: + +```bash +sde -m key sameval file.json +# > exit code 0 +sde -m key sameval file.json +# > exit code 2 +``` + +## TODO + +### Work with stdin + +```bash +echo $json | sde name Jack +``` + +### Query simple data + +```bash +sdg name data.json +``` + + +%package help +Summary: Development documents and examples for sde +Provides: python3-sde-doc +%description help +# sde + +[](https://badge.fury.io/py/sde) + +`sde` is not `sed`. It's a structured data editor for CLI. + +## Why? + +Many people asked for a simple JSON in-place editing and `jq` was the solution: + +* [Modify a key-value in a json using jq in-place](https://stackoverflow.com/questions/42716734/modify-a-key-value-in-a-json-using-jq-in-place) +* [How to modify a key's value in a JSON file from command line](https://stackoverflow.com/questions/43292243/how-to-modify-a-keys-value-in-a-json-file-from-command-line) + +```bash +jq '.address = "abcde"' test.json|sponge test.json +``` + +Does this seem readable or elegant to you? + +How about this instead: + +```bash +sde address abcde test.json +``` + +`sde` is not a substitute for `jq` or `sed`. + +It allows *simple* in-place JSON/YAML value changes, for *structured* data. + +### Sample JSON + +```json +{ + "name":"John", + "age":31, + "city":"New York", + "extra": { + "gender": null + } +} +``` + +### Sample YAML + +```yaml +database: + user: example + password: secret +``` + +### Modify data + +```bash +sde name Jack data.json +sde extra.gender male data.json +sde database.user john data.yml +``` + +It is possible to modify data in arrays using a dotted notation. Let's take another sample: + +```json +{ + "users": [ + { + "username": "foo", + "enabled": true + }, + { + "username": "bar", + "enabled": true + } + ], +} +``` + +We can set the first user's `enabled` property to `false`: + +```bash +sde users.0.enabled false data.json +``` + +## Installation for CentOS/RHEL 7, 8 or Amazon Linux 2, or Fedora Linux + +```bash +sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm +sudo yum -y install sde +``` + +## Installation for other systems + +Installing with `pip` is easiest: + +```bash +pip install sde +``` + +## Notes + +### Quoting in JSON + +Quoting is avoided for `null`, `true`, `false`, and numeric values. +To ensure that a given value is quoted, use `-s` (or `--string`) option: + +```bash +sde -s key null file.json +``` + +### Force-fail on missing keys + +If you must *edit* the file, by ensuring to update only the existing key, use `-e` (`--must-exist`) +option. The program will exit without adding the key which doesn't exist. + +```bash +sde -e key val file.json +``` + +### Force-fail on unchanged file + +If the data is unchanged after running `sde` (values already match), you can force +a failure exit code `2` by passing the `-m` option: + +```bash +sde -m key sameval file.json +# > exit code 0 +sde -m key sameval file.json +# > exit code 2 +``` + +## TODO + +### Work with stdin + +```bash +echo $json | sde name Jack +``` + +### Query simple data + +```bash +sdg name data.json +``` + + +%prep +%autosetup -n sde-1.1.9 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-sde -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 1.1.9-1 +- Package Spec generated @@ -0,0 +1 @@ +4c58b1abeb181925189fc0a59bcd1ae5 sde-1.1.9.tar.gz |