From c56b83093ff05f55ef4643c1731cff61d4b9e8ce Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Tue, 4 Feb 2020 14:19:33 -0800 Subject: [PATCH] doc update --- docgen.sh | 1 + docs/parsers/crontab.md | 4 +- docs/parsers/crontab_u.md | 199 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 docs/parsers/crontab_u.md diff --git a/docgen.sh b/docgen.sh index 4d9becb5..e3bb0620 100755 --- a/docgen.sh +++ b/docgen.sh @@ -6,6 +6,7 @@ pydocmd simple jc+ > ../docs/readme.md pydocmd simple utils+ > ../docs/utils.md pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md pydocmd simple jc.parsers.crontab+ > ../docs/parsers/crontab.md +pydocmd simple jc.parsers.crontab_u+ > ../docs/parsers/crontab_u.md pydocmd simple jc.parsers.df+ > ../docs/parsers/df.md pydocmd simple jc.parsers.dig+ > ../docs/parsers/dig.md pydocmd simple jc.parsers.du+ > ../docs/parsers/du.md diff --git a/docs/parsers/crontab.md b/docs/parsers/crontab.md index a078ce5c..98eb08e4 100644 --- a/docs/parsers/crontab.md +++ b/docs/parsers/crontab.md @@ -150,8 +150,8 @@ Returns: { "variables": [ - "name": string, - "value": string + "name": string, + "value": string ], "schedule": [ { diff --git a/docs/parsers/crontab_u.md b/docs/parsers/crontab_u.md new file mode 100644 index 00000000..7966d714 --- /dev/null +++ b/docs/parsers/crontab_u.md @@ -0,0 +1,199 @@ +# jc.parsers.crontab_u +jc - JSON CLI output utility crontab file Parser + +Usage: + + specify --crontab-u as the first argument if the piped input is coming from a crontab file with User specified + +Compatibility: + + 'linux', 'darwin', 'aix', 'freebsd' + +Examples: + + $ cat /etc/crontab | jc --crontab -p + { + "variables": [ + { + "name": "PATH", + "value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" + }, + { + "name": "SHELL", + "value": "/bin/sh" + } + ], + "schedule": [ + { + "minute": [ + "25" + ], + "hour": [ + "6" + ], + "day_of_month": [ + "*" + ], + "month": [ + "*" + ], + "day_of_week": [ + "*" + ], + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )" + }, + { + "minute": [ + "47" + ], + "hour": [ + "6" + ], + "day_of_month": [ + "*" + ], + "month": [ + "*" + ], + "day_of_week": [ + "7" + ], + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )" + }, + { + "minute": [ + "52" + ], + "hour": [ + "6" + ], + "day_of_month": [ + "1" + ], + "month": [ + "*" + ], + "day_of_week": [ + "*" + ], + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )" + } + ] + } + + $ cat /etc/crontab | jc --crontab-u -p -r + { + "variables": [ + { + "name": "PATH", + "value": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" + }, + { + "name": "SHELL", + "value": "/bin/sh" + } + ], + "schedule": [ + { + "minute": "25", + "hour": "6", + "day_of_month": "*", + "month": "*", + "day_of_week": "*", + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )" + }, + { + "minute": "47", + "hour": "6", + "day_of_month": "*", + "month": "*", + "day_of_week": "7", + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )" + }, + { + "minute": "52", + "hour": "6", + "day_of_month": "1", + "month": "*", + "day_of_week": "*", + "user": "root", + "command": "test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )" + } + ] + } + + + +## 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. Structured data with the following schema: + + { + "variables": [ + "name": string, + "value": string + ], + "schedule": [ + { + "occurrence" string, + "minute": [ + string + ], + "hour": [ + string + ], + "day_of_month": [ + string + ], + "month": [ + string + ], + "day_of_week": [ + string + ], + "occurrence": string, + "user": string, + "command": string + } + ] + } + + +## 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. Raw or processed structured data. +