From beb41997c9b3797e73a678ec1bcddcfb83b5ef0d Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 3 Feb 2020 21:28:11 -0800 Subject: [PATCH] doc update --- docgen.sh | 1 + docs/parsers/ini.md | 87 +++++++++++++++++++++++++++++++++++++++++++++ jc/parsers/ini.py | 5 +-- 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 docs/parsers/ini.md diff --git a/docgen.sh b/docgen.sh index 8d2c612f..f62d5f66 100755 --- a/docgen.sh +++ b/docgen.sh @@ -15,6 +15,7 @@ pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md pydocmd simple jc.parsers.ifconfig+ > ../docs/parsers/ifconfig.md +pydocmd simple jc.parsers.ini+ > ../docs/parsers/ini.md pydocmd simple jc.parsers.iptables+ > ../docs/parsers/iptables.md pydocmd simple jc.parsers.jobs+ > ../docs/parsers/jobs.md pydocmd simple jc.parsers.ls+ > ../docs/parsers/ls.md diff --git a/docs/parsers/ini.md b/docs/parsers/ini.md new file mode 100644 index 00000000..2272a318 --- /dev/null +++ b/docs/parsers/ini.md @@ -0,0 +1,87 @@ +# jc.parsers.ini +jc - JSON CLI output utility ini Parser + +Usage: + + specify --ini as the first argument if the piped input is coming from a ini file + +Compatibility: + + 'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd' + +Examples: + + $ cat example.ini + [DEFAULT] + ServerAliveInterval = 45 + Compression = yes + CompressionLevel = 9 + ForwardX11 = yes + + [bitbucket.org] + User = hg + + [topsecret.server.com] + Port = 50022 + ForwardX11 = no + + $ cat example.ini | jc --ini -p + { + "bitbucket.org": { + "serveraliveinterval": "45", + "compression": "yes", + "compressionlevel": "9", + "forwardx11": "yes", + "user": "hg" + }, + "topsecret.server.com": { + "serveraliveinterval": "45", + "compression": "yes", + "compressionlevel": "9", + "forwardx11": "no", + "port": "50022" + } + } + +## info +```python +info(self, /, *args, **kwargs) +``` + +## process +```python +process(proc_data) +``` + +Final processing to conform to the schema. + +Parameters: + + proc_data: (dictionary) raw structured data to process + +Returns: + + Dictionary representing an ini document: + + { + ini document converted to a dictionary + see configparser standard library documentation for more details + } + +## parse +```python +parse(data, raw=False, quiet=False) +``` + +Main text parsing function + +Parameters: + + data: (string) text data to parse + raw: (boolean) output preprocessed JSON if True + quiet: (boolean) suppress warning messages if True + +Returns: + + Dictionary representing the ini file + diff --git a/jc/parsers/ini.py b/jc/parsers/ini.py index 6d60c106..9034d573 100644 --- a/jc/parsers/ini.py +++ b/jc/parsers/ini.py @@ -9,7 +9,7 @@ Compatibility: 'linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd' Examples: - + $ cat example.ini [DEFAULT] ServerAliveInterval = 45 @@ -73,7 +73,8 @@ def process(proc_data): Dictionary representing an ini document: { - ini Document converted to a Dictionary + ini document converted to a dictionary + see configparser standard library documentation for more details } """