-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from kellyjonbrazil/dev
Dev v1.19.0
- Loading branch information
Showing
71 changed files
with
1,952 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
[Home](https://kellyjonbrazil.github.io/jc/) | ||
<a id="jc.parsers.chage"></a> | ||
|
||
# jc.parsers.chage | ||
|
||
jc - JSON Convert `chage --list` command output parser | ||
|
||
Supports `chage -l <username>` or `chage --list <username>` | ||
|
||
Usage (cli): | ||
|
||
$ chage -l johndoe | jc --chage | ||
|
||
or | ||
|
||
$ jc chage -l johndoe | ||
|
||
Usage (module): | ||
|
||
import jc | ||
result = jc.parse('chage', chage_command_output) | ||
|
||
Schema: | ||
|
||
{ | ||
"password_last_changed": string, | ||
"password_expires": string, | ||
"password_inactive": string, | ||
"account_expires": string, | ||
"min_days_between_password_change": integer, | ||
"max_days_between_password_change": integer, | ||
"warning_days_before_password_expires": integer | ||
} | ||
|
||
Examples: | ||
|
||
$ chage --list joeuser | jc --chage -p | ||
{ | ||
"password_last_changed": "never", | ||
"password_expires": "never", | ||
"password_inactive": "never", | ||
"account_expires": "never", | ||
"min_days_between_password_change": 0, | ||
"max_days_between_password_change": 99999, | ||
"warning_days_before_password_expires": 7 | ||
} | ||
|
||
$ chage --list joeuser | jc --chage -p -r | ||
{ | ||
"password_last_changed": "never", | ||
"password_expires": "never", | ||
"password_inactive": "never", | ||
"account_expires": "never", | ||
"min_days_between_password_change": "0", | ||
"max_days_between_password_change": "99999", | ||
"warning_days_before_password_expires": "7" | ||
} | ||
|
||
<a id="jc.parsers.chage.parse"></a> | ||
|
||
### parse | ||
|
||
```python | ||
def parse(data: str, raw: bool = False, quiet: bool = False) -> Dict | ||
``` | ||
|
||
Main text parsing function | ||
|
||
Parameters: | ||
|
||
data: (string) text data to parse | ||
raw: (boolean) unprocessed output if True | ||
quiet: (boolean) suppress warning messages if True | ||
|
||
Returns: | ||
|
||
Dictionary. Raw or processed structured data. | ||
|
||
### Parser Information | ||
Compatibility: linux | ||
|
||
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
[Home](https://kellyjonbrazil.github.io/jc/) | ||
<a id="jc.parsers.git_log_s"></a> | ||
|
||
# jc.parsers.git\_log\_s | ||
|
||
jc - JSON Convert `git log` command output streaming parser | ||
|
||
> This streaming parser outputs JSON Lines (cli) or returns an Iterable of | ||
Dictionaries (module) | ||
|
||
Can be used with the following format options: | ||
- `oneline` | ||
- `short` | ||
- `medium` | ||
- `full` | ||
- `fuller` | ||
|
||
Additional options supported: | ||
- `--stat` | ||
- `--shortstat` | ||
|
||
The `epoch` calculated timestamp field is naive. (i.e. based on the | ||
local time of the system the parser is run on) | ||
|
||
The `epoch_utc` calculated timestamp field is timezone-aware and is | ||
only available if the timezone field is UTC. | ||
|
||
Usage (cli): | ||
|
||
$ git log | jc --git-log-s | ||
|
||
Usage (module): | ||
|
||
import jc | ||
|
||
result = jc.parse('git_log_s', git_log_command_output.splitlines()) | ||
for item in result: | ||
# do something | ||
|
||
Schema: | ||
|
||
{ | ||
"commit": string, | ||
"author": string, | ||
"author_email": string, | ||
"date": string, | ||
"epoch": integer, [0] | ||
"epoch_utc": integer, [1] | ||
"commit_by": string, | ||
"commit_by_email": string, | ||
"commit_by_date": string, | ||
"message": string, | ||
"stats" : { | ||
"files_changed": integer, | ||
"insertions": integer, | ||
"deletions": integer, | ||
"files": [ | ||
string | ||
] | ||
} | ||
|
||
# below object only exists if using -qq or ignore_exceptions=True | ||
"_jc_meta": { | ||
"success": boolean, # false if error parsing | ||
"error": string, # exists if "success" is false | ||
"line": string # exists if "success" is false | ||
} | ||
} | ||
|
||
[0] naive timestamp if "date" field is parsable, else null | ||
[1] timezone aware timestamp availabe for UTC, else null | ||
|
||
Examples: | ||
|
||
$ git log | jc --git-log-s | ||
{"commit":"a730ae18c8e81c5261db132df73cd74f272a0a26","author":"Kelly...} | ||
{"commit":"930bf439c06c48a952baec05a9896c8d92b7693e","author":"Kelly...} | ||
... | ||
|
||
<a id="jc.parsers.git_log_s.parse"></a> | ||
|
||
### parse | ||
|
||
```python | ||
@add_jc_meta | ||
def parse(data: Iterable[str], | ||
raw: bool = False, | ||
quiet: bool = False, | ||
ignore_exceptions: bool = False) -> Union[Iterable[Dict], tuple] | ||
``` | ||
|
||
Main text parsing generator function. Returns an iterable object. | ||
|
||
Parameters: | ||
|
||
data: (iterable) line-based text data to parse | ||
(e.g. sys.stdin or str.splitlines()) | ||
|
||
raw: (boolean) unprocessed output if True | ||
quiet: (boolean) suppress warning messages if True | ||
ignore_exceptions: (boolean) ignore parsing exceptions if True | ||
|
||
|
||
Returns: | ||
|
||
Iterable of Dictionaries | ||
|
||
### Parser Information | ||
Compatibility: linux, darwin, cygwin, win32, aix, freebsd | ||
|
||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.