Skip to content

Commit

Permalink
Merge pull request #91 from kellyjonbrazil/dev
Browse files Browse the repository at this point in the history
Dev v1.14.0
  • Loading branch information
kellyjonbrazil committed Jan 1, 2021
2 parents 439871e + b122174 commit 9e3b887
Show file tree
Hide file tree
Showing 47 changed files with 2,222 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
jc changelog

20201231 v1.14.0
- Add hashsum parser tested on linux, macos
- Add hash parser tested on linux, macos
- Add cksum parser tested on linux, macos
- Add wc parser tested on linux, macos
- Add printenv support under env parser
- Add vdir support under ls parser
- Add python 3.9 to github automation tests

20200805 v1.13.4
- Update crontab and crontab-u parsers to tighten up variable detection
- Update ping parser to tighten linux/bsd detection
Expand Down
97 changes: 97 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ blkid -o udev -ip /dev/sda2 | jc --blkid -p # or: jc -p blkid -o udev
}
]
```
### cksum
```bash
cksum * | jc --cksum -p # or: jc -p cksum *
```
```json
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
}
]
```
### crontab
```bash
cat /etc/crontab | jc --crontab -p # or: jc -p crontab -l
Expand Down Expand Up @@ -843,6 +866,54 @@ cat /etc/gshadow | jc --gshadow -p
}
]
```
### hash
```bash
hash | jc --hash -p
```
```json
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]
```
### hashsum
```bash
md5sum * | jc --hashsum -p # or: jc -p md5sum *
```
```json
[
{
"filename": "devtoolset-3-gcc-4.9.2-6.el7.x86_64.rpm",
"hash": "65fc958c1add637ec23c4b137aecf3d3"
},
{
"filename": "digout",
"hash": "5b9312ee5aff080927753c63a347707d"
},
{
"filename": "dmidecode.out",
"hash": "716fd11c2ac00db109281f7110b8fb9d"
},
{
"filename": "file with spaces in the name",
"hash": "d41d8cd98f00b204e9800998ecf8427e"
},
{
"filename": "id-centos.out",
"hash": "4295be239a14ad77ef3253103de976d2"
},
{
"filename": "ifcfg.json",
"hash": "01fda0d9ba9a75618b072e64ff512b43"
}
]
```
### history
```bash
history | jc --history -p
Expand Down Expand Up @@ -2469,6 +2540,32 @@ w | jc --w -p # or: jc -p w
}
]
```
### wc
```bash
wc * | jc --wc -p # or: jc -p wc *
```
```json
[
{
"filename": "airport-I.json",
"lines": 1,
"words": 30,
"characters": 307
},
{
"filename": "airport-I.out",
"lines": 15,
"words": 33,
"characters": 348
},
{
"filename": "airport-s.json",
"lines": 1,
"words": 202,
"characters": 2152
}
]
```
### who
```bash
who | jc --who -p # or: jc -p who
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--airport-s` enables the `airport -s` command parser (OSX)
- `--arp` enables the `arp` command parser
- `--blkid` enables the `blkid` command parser
- `--cksum` enables the `cksum` and `sum` command parser
- `--crontab` enables the `crontab` command and file parser
- `--crontab-u` enables the `crontab` file parser with user support
- `--csv` enables the `CSV` file parser
Expand All @@ -130,12 +131,14 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--dig` enables the `dig` command parser
- `--dmidecode` enables the `dmidecode` command parser
- `--du` enables the `du` command parser
- `--env` enables the `env` command parser
- `--env` enables the `env` and `printenv` command parser
- `--file` enables the `file` command parser
- `--free` enables the `free` command parser
- `--fstab` enables the `/etc/fstab` file parser
- `--group` enables the `/etc/group` file parser
- `--gshadow` enables the `/etc/gshadow` file parser
- `--hash` enables the `hash` command parser
- `--hashsum` enables the `hashsum` command parser (`md5sum`, `shasum`, etc.)
- `--history` enables the `history` command parser
- `--hosts` enables the `/etc/hosts` file parser
- `--id` enables the `id` command parser
Expand All @@ -145,7 +148,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--jobs` enables the `jobs` command parser
- `--kv` enables the `Key/Value` file parser
- `--last` enables the `last` and `lastb` command parser
- `--ls` enables the `ls` command parser
- `--ls` enables the `ls` and `vdir` command parser
- `--lsblk` enables the `lsblk` command parser
- `--lsmod` enables the `lsmod` command parser
- `--lsof` enables the `lsof` command parser
Expand All @@ -172,6 +175,7 @@ The JSON output can be compact (default) or pretty formatted with the `-p` optio
- `--uname` enables the `uname -a` command parser
- `--uptime` enables the `uptime` command parser
- `--w` enables the `w` command parser
- `--wc` enables the `wc` command parser
- `--who` enables the `who` command parser
- `--xml` enables the `XML` file parser
- `--yaml` enables the `YAML` file parser
Expand Down
3 changes: 3 additions & 0 deletions docgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pydocmd simple jc.parsers.airport+ > ../docs/parsers/airport.md
pydocmd simple jc.parsers.airport_s+ > ../docs/parsers/airport_s.md
pydocmd simple jc.parsers.arp+ > ../docs/parsers/arp.md
pydocmd simple jc.parsers.blkid+ > ../docs/parsers/blkid.md
pydocmd simple jc.parsers.cksum+ > ../docs/parsers/cksum.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.csv+ > ../docs/parsers/csv.md
Expand All @@ -23,6 +24,8 @@ pydocmd simple jc.parsers.free+ > ../docs/parsers/free.md
pydocmd simple jc.parsers.fstab+ > ../docs/parsers/fstab.md
pydocmd simple jc.parsers.group+ > ../docs/parsers/group.md
pydocmd simple jc.parsers.gshadow+ > ../docs/parsers/gshadow.md
pydocmd simple jc.parsers.hash+ > ../docs/parsers/hash.md
pydocmd simple jc.parsers.hashsum+ > ../docs/parsers/hashsum.md
pydocmd simple jc.parsers.history+ > ../docs/parsers/history.md
pydocmd simple jc.parsers.hosts+ > ../docs/parsers/hosts.md
pydocmd simple jc.parsers.id+ > ../docs/parsers/id.md
Expand Down
95 changes: 95 additions & 0 deletions docs/parsers/cksum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@

# jc.parsers.cksum
jc - JSON CLI output utility `cksum` command output parser

This parser works with the following checksum calculation utilities:
- `sum`
- `cksum`

Usage (cli):

$ cksum file.txt | jc --cksum

or

$ jc cksum file.txt

Usage (module):

import jc.parsers.cksum
result = jc.parsers.cksum.parse(cksum_command_output)

Compatibility:

'linux', 'darwin', 'cygwin', 'aix', 'freebsd'

Examples:

$ cksum * | jc --cksum -p
[
{
"filename": "__init__.py",
"checksum": 4294967295,
"blocks": 0
},
{
"filename": "airport.py",
"checksum": 2208551092,
"blocks": 3745
},
{
"filename": "airport_s.py",
"checksum": 1113817598,
"blocks": 4572
},
...
]


## info
```python
info()
```


## process
```python
process(proc_data)
```

Final processing to conform to the schema.

Parameters:

proc_data: (dictionary) raw structured data to process

Returns:

List of dictionaries. Structured data with the following schema:

[
{
"filename": string,
"checksum": integer,
"blocks": integer
}
]


## 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:

List of dictionaries. Raw or processed structured data.

2 changes: 1 addition & 1 deletion docs/parsers/env.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# jc.parsers.env
jc - JSON CLI output utility `env` command output parser
jc - JSON CLI output utility `env` and `printenv` command output parser

This parser will output a list of dictionaries each containing `name` and `value` keys. If you would like a simple dictionary output, then use the `-r` command-line option or the `raw=True` argument in the `parse()` function.

Expand Down
78 changes: 78 additions & 0 deletions docs/parsers/hash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

# jc.parsers.hash
jc - JSON CLI output utility `hash` command output parser

Usage (cli):

$ hash | jc --hash

Usage (module):

import jc.parsers.hash
result = jc.parsers.hash.parse(hash_command_output)

Compatibility:

'linux', 'darwin', 'cygwin', 'aix', 'freebsd'

Examples:

$ hash | jc --hash -p
[
{
"hits": 2,
"command": "/bin/cat"
},
{
"hits": 1,
"command": "/bin/ls"
}
]


## info
```python
info()
```


## process
```python
process(proc_data)
```

Final processing to conform to the schema.

Parameters:

proc_data: (dictionary) raw structured data to process

Returns:

List of dictionaries. Structured data with the following schema:

[
{
"command": string,
"hits": integer
}
]


## 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:

List of dictionaries. Raw or processed structured data.

0 comments on commit 9e3b887

Please sign in to comment.