1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

use dict constructor for xmltodict to suppress !!omap comments in YAML output

This commit is contained in:
Kelly Brazil
2022-11-02 12:00:45 -07:00
parent 2b060aae0d
commit 23e1dd3e35
2 changed files with 8 additions and 3 deletions

View File

@ -1,8 +1,13 @@
jc changelog
20221101 v1.22.2
20221102 v1.22.2
- add `sshd_conf` parser
- add `findmnt` parser
- enhance `xml` parser with optional `_` prefix for attributes instead of
`@` by using the `--raw` option. This can make it easier to filter the
JSON output in some tools.
- fix the `xml` parser to output a normal Dictionary instead of OrderdDict.
This cleans up YAML output. (No `!!omap` comments)
- fix `csv` and `csv-s` parsers for UTF-8 encoded CSV files with leading BOM bytes
- fix exit code to be non-zero on interrupt
- allow parser module objects to be used as arguments to `jc.get_help()` and `jc.parser_info()`

View File

@ -108,7 +108,7 @@ def _process(proc_data, has_data=False):
if has_data:
# standard output with @ prefix for attributes
raw_output = xmltodict.parse(proc_data)
raw_output = xmltodict.parse(proc_data, dict_constructor=dict)
return raw_output
@ -139,7 +139,7 @@ def parse(data, raw=False, quiet=False):
if raw:
if has_data:
# modified output with _ prefix for attributes
raw_output = xmltodict.parse(data, attr_prefix='_')
raw_output = xmltodict.parse(data, dict_constructor=dict, attr_prefix='_')
return raw_output