1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00
Files
jc/docs/parsers/hashsum.md

114 lines
1.9 KiB
Markdown
Raw Normal View History

[Home](https://kellyjonbrazil.github.io/jc/)
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.hashsum"></a>
2020-12-29 13:05:04 -08:00
# jc.parsers.hashsum
2022-01-25 17:07:47 -08:00
2020-12-29 13:05:04 -08:00
jc - JSON CLI output utility `hash sum` command output parser
2020-12-30 11:02:02 -08:00
This parser works with the following hash calculation utilities:
2020-12-29 13:09:03 -08:00
- `md5`
- `md5sum`
- `shasum`
- `sha1sum`
- `sha224sum`
- `sha256sum`
- `sha384sum`
- `sha512sum`
2020-12-29 13:05:04 -08:00
Usage (cli):
2022-01-25 17:07:47 -08:00
$ md5sum file.txt | jc --hashsum
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
or
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
$ jc md5sum file.txt
2020-12-29 13:05:04 -08:00
Usage (module):
2022-01-25 17:07:47 -08:00
import jc
result = jc.parse('hashsum', md5sum_command_output)
2022-01-18 15:38:03 -08:00
2022-01-25 17:07:47 -08:00
or
2022-01-18 15:38:03 -08:00
2022-01-25 17:07:47 -08:00
import jc.parsers.hashsum
result = jc.parsers.hashsum.parse(md5sum_command_output)
2020-12-29 13:05:04 -08:00
2021-04-08 12:42:01 -07:00
Schema:
2022-01-25 17:07:47 -08:00
[
{
"filename": string,
"hash": string,
}
]
**Examples**:
$ md5sum * | jc --hashsum -p
[
{
- `"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"
},
...
]
<a id="jc.parsers.hashsum.info"></a>
## info Objects
2020-12-29 13:05:04 -08:00
```python
2022-01-25 17:07:47 -08:00
class info()
2020-12-29 13:05:04 -08:00
```
2022-01-25 17:07:47 -08:00
2021-04-08 12:42:01 -07:00
Provides parser metadata (version, author, etc.)
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
<a id="jc.parsers.hashsum.parse"></a>
#### parse
2020-12-29 13:05:04 -08:00
```python
2022-01-25 17:07:47 -08:00
def parse(data, raw=False, quiet=False)
2020-12-29 13:05:04 -08:00
```
Main text parsing function
2022-01-25 17:07:47 -08:00
**Arguments**:
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
- `data` - (string) text data to parse
- `raw` - (boolean) unprocessed output if True
- `quiet` - (boolean) suppress warning messages if True
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
**Returns**:
2020-12-29 13:05:04 -08:00
2022-01-25 17:07:47 -08:00
List of Dictionaries. Raw or processed structured data.
2020-12-29 13:05:04 -08:00
## Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
2021-12-01 16:12:51 -08:00
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)