1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2026-04-24 20:56:11 +02:00

Merge pull request #266 from kellyjonbrazil/dev

Dev v1.20.3
This commit is contained in:
Kelly Brazil
2022-07-23 13:12:54 -07:00
committed by GitHub
168 changed files with 43663 additions and 415 deletions
+10
View File
@@ -1,5 +1,15 @@
jc changelog
20220723 v1.20.3
- Add URL string parser
- Add Email Address string parser
- Add JWT string parser
- Add ISO 8601 Datetime string parser
- Add UNIX Epoch Timestamp string parser
- Add M3U/M3U8 file parser
- Add pager functionality to help (parser documentation only)
- Minor parser performance optimizations
20220705 v1.20.2
- Add `gpg --with-colons` parser tested on linux
- Add DER and PEM encoded X.509 Certificate parser
+212 -34
View File
@@ -922,6 +922,18 @@ du /usr | jc --du -p # or: jc -p du /usr
}
]
```
### Email Address string
```bash
echo 'joe.user@gmail.com' | jc --email-address -p
```
```json
{
"username": "joe.user",
"domain": "gmail.com",
"local": "joe.user",
"local_plus_suffix": null
}
```
### env
```bash
env | jc --env -p # or: jc -p env
@@ -1715,6 +1727,31 @@ iptables --line-numbers -v -L -t nat | jc --iptables -p # or: jc -p ip
}
]
```
### ISO Datetime string
```bash
echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
```
```json
{
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 20,
"weekday": "Wed",
"weekday_num": 3,
"hour": 2,
"hour_24": 14,
"minute": 52,
"second": 45,
"microsecond": 0,
"period": "PM",
"utc_offset": "+0000",
"day_of_year": 201,
"week_of_year": 29,
"iso": "2022-07-20T14:52:45+00:00",
"timestamp": 1658328765
}
```
### iw dev `device` scan
```bash
iw dev wlan0 scan | jc --iw-scan -p # or: jc -p iw dev wlan0 scan
@@ -1861,6 +1898,24 @@ jobs -l | jc --jobs -p
}
]
```
### JWT string
```bash
echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
```
```json
{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
},
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
}
```
### Key/Value files
```bash
cat keyvalue.txt
@@ -2197,6 +2252,24 @@ lsusb -v | jc --lsusb -p # or: jc -p lsusb -v
}
]
```
### M3U and M3U8 files
```bash
cat playlist.m3u | jc --m3u -p
```
```json
[
{
"runtime": 105,
"display": "Example artist - Example title",
"path": "C:\\Files\\My Music\\Example.mp3"
},
{
"runtime": 321,
"display": "Example Artist2 - Example title2",
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
}
]
```
### mount
```bash
mount | jc --mount -p # or: jc -p mount
@@ -2509,40 +2582,40 @@ nmcli connection show ens33 | jc --nmcli -p # or jc -p nmcli connection
```
```json
[
{
"connection_id": "ens33",
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
"connection_stable_id": null,
"connection_type": "802-3-ethernet",
"connection_interface_name": "ens33",
"connection_autoconnect": "yes",
"ip4_address_1": "192.168.71.180/24",
"ip4_gateway": "192.168.71.2",
"ip4_route_1": {
"dst": "0.0.0.0/0",
"nh": "192.168.71.2",
"mt": 100
},
"ip4_route_2": {
"dst": "192.168.71.0/24",
"nh": "0.0.0.0",
"mt": 100
},
"ip4_dns_1": "192.168.71.2",
"ip4_domain_1": "localdomain",
"dhcp4_option_1": {
"name": "broadcast_address",
"value": "192.168.71.255"
},
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
"ip6_gateway": null,
"ip6_route_1": {
"dst": "fe80::/64",
"nh": "::",
"mt": 100
}
}
]
{
"connection_id": "ens33",
"connection_uuid": "d92ece08-9e02-47d5-b2d2-92c80e155744",
"connection_stable_id": null,
"connection_type": "802-3-ethernet",
"connection_interface_name": "ens33",
"connection_autoconnect": "yes",
"ip4_address_1": "192.168.71.180/24",
"ip4_gateway": "192.168.71.2",
"ip4_route_1": {
"dst": "0.0.0.0/0",
"nh": "192.168.71.2",
"mt": 100
},
"ip4_route_2": {
"dst": "192.168.71.0/24",
"nh": "0.0.0.0",
"mt": 100
},
"ip4_dns_1": "192.168.71.2",
"ip4_domain_1": "localdomain",
"dhcp4_option_1": {
"name": "broadcast_address",
"value": "192.168.71.255"
},
"ip6_address_1": "fe80::c1cb:715d:bc3e:b8a0/64",
"ip6_gateway": null,
"ip6_route_1": {
"dst": "fe80::/64",
"nh": "::",
"mt": 100
}
}
]
```
### ntpq
```bash
@@ -3526,6 +3599,47 @@ timedatectl | jc --timedatectl -p # or: jc -p timedatectl
"epoch_utc": 1583888001
}
```
### Timestamp strings (UNIX Epoch)
```bash
echo '1658599410' | jc --timestamp -p
```
```json
{
"naive": {
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 23,
"weekday": "Sat",
"weekday_num": 6,
"hour": 11,
"hour_24": 11,
"minute": 3,
"second": 30,
"period": "AM",
"day_of_year": 204,
"week_of_year": 29,
"iso": "2022-07-23T11:03:30"
},
"utc": {
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 23,
"weekday": "Sat",
"weekday_num": 6,
"hour": 6,
"hour_24": 18,
"minute": 3,
"second": 30,
"period": "PM",
"utc_offset": "+0000",
"day_of_year": 204,
"week_of_year": 29,
"iso": "2022-07-23T18:03:30+00:00"
}
}
```
### tob -b
```bash
top -b -n 1 | jc --top -p # or jc -p tob -b -n 1
@@ -4014,6 +4128,70 @@ uptime | jc --uptime -p # or: jc -p uptime
"uptime_total_seconds": 273780
}
```
### URL string
```bash
echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
| jc --url -p
```
```json
{
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"query_obj": {
"q1": [
"foo",
"bar"
],
"q2": [
"baz"
]
},
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null,
"encoded": {
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null
},
"decoded": {
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null
}
}
```
### w
```bash
w | jc --w -p # or: jc -p w
+6
View File
@@ -168,6 +168,7 @@ option.
| ` --dmidecode` | `dmidecode` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dmidecode) |
| ` --dpkg-l` | `dpkg -l` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dpkg_l) |
| ` --du` | `du` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/du) |
| `--email-address` | Email Address string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/email_address) |
| ` --env` | `env` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/env) |
| ` --file` | `file` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/file) |
| ` --finger` | `finger` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/finger) |
@@ -189,9 +190,11 @@ option.
| ` --iostat` | `iostat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat) |
| ` --iostat-s` | `iostat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iostat_s) |
| ` --iptables` | `iptables` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iptables) |
| ` --iso-datetime` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iso_datetime) |
| ` --iw-scan` | `iw dev [device] scan` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/iw_scan) |
| ` --jar-manifest` | MANIFEST.MF file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jar_manifest) |
| ` --jobs` | `jobs` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jobs) |
| ` --jwt` | JWT string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/jwt) |
| ` --kv` | Key/Value file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/kv) |
| ` --last` | `last` and `lastb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/last) |
| ` --ls` | `ls` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/ls) |
@@ -200,6 +203,7 @@ option.
| ` --lsmod` | `lsmod` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsmod) |
| ` --lsof` | `lsof` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsof) |
| ` --lsusb` | `lsusb` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/lsusb) |
| ` --m3u` | M3U and M3U8 file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/m3u) |
| ` --mount` | `mount` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mount) |
| ` --mpstat` | `mpstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat) |
| ` --mpstat-s` | `mpstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/mpstat_s) |
@@ -232,6 +236,7 @@ option.
| ` --systeminfo` | `systeminfo` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/systeminfo) |
| ` --time` | `/usr/bin/time` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/time) |
| ` --timedatectl` | `timedatectl status` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timedatectl) |
| ` --timestamp` | UNIX Epoch Timestamp string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/timestamp) |
| ` --top` | `top -b` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top) |
| ` --top-s` | `top -b` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/top_s) |
| ` --tracepath` | `tracepath` and `tracepath6` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/tracepath) |
@@ -243,6 +248,7 @@ option.
| ` --update-alt-q` | `update-alternatives --query` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/update_alt_q) |
| ` --upower` | `upower` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/upower) |
| ` --uptime` | `uptime` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/uptime) |
| ` --url` | URL string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/url) |
| ` --vmstat` | `vmstat` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat) |
| ` --vmstat-s` | `vmstat` command streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/vmstat_s) |
| ` --w` | `w` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/w) |
+1 -1
View File
@@ -4,7 +4,7 @@ _jc()
jc_about_options jc_about_mod_options jc_help_options jc_special_options
jc_commands=(acpi airport arp blkid chage cksum crontab date df dig dmidecode dpkg du env file finger free git gpg hciconfig id ifconfig iostat iptables iw jobs last lastb ls lsblk lsmod lsof lsusb md5 md5sum mount mpstat netstat nmcli ntpq pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss stat sum sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 ufw uname update-alternatives upower uptime vdir vmstat w wc who xrandr zipinfo)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iw-scan --jar-manifest --jobs --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
jc_options=(--force-color -C --debug -d --monochrome -m --pretty -p --quiet -q --raw -r --unbuffer -u --yaml-out -y)
jc_about_options=(--about -a)
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
+7 -1
View File
@@ -94,7 +94,7 @@ _jc() {
'xrandr:run "xrandr" command with magic syntax.'
'zipinfo:run "zipinfo" command with magic syntax.'
)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iw-scan --jar-manifest --jobs --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --chage --cksum --crontab --crontab-u --csv --csv-s --date --df --dig --dir --dmidecode --dpkg-l --du --email-address --env --file --finger --free --fstab --git-log --git-log-s --gpg --group --gshadow --hash --hashsum --hciconfig --history --hosts --id --ifconfig --ini --iostat --iostat-s --iptables --iso-datetime --iw-scan --jar-manifest --jobs --jwt --kv --last --ls --ls-s --lsblk --lsmod --lsof --lsusb --m3u --mount --mpstat --mpstat-s --netstat --nmcli --ntpq --passwd --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --postconf --ps --route --rpm-qi --rsync --rsync-s --sfdisk --shadow --ss --stat --stat-s --sysctl --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --top --top-s --tracepath --traceroute --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --vmstat --vmstat-s --w --wc --who --x509-cert --xml --xrandr --yaml --zipinfo)
jc_parsers_describe=(
'--acpi:`acpi` command parser'
'--airport:`airport -I` command parser'
@@ -116,6 +116,7 @@ _jc() {
'--dmidecode:`dmidecode` command parser'
'--dpkg-l:`dpkg -l` command parser'
'--du:`du` command parser'
'--email-address:Email Address string parser'
'--env:`env` command parser'
'--file:`file` command parser'
'--finger:`finger` command parser'
@@ -137,9 +138,11 @@ _jc() {
'--iostat:`iostat` command parser'
'--iostat-s:`iostat` command streaming parser'
'--iptables:`iptables` command parser'
'--iso-datetime:ISO 8601 Datetime string parser'
'--iw-scan:`iw dev [device] scan` command parser'
'--jar-manifest:MANIFEST.MF file parser'
'--jobs:`jobs` command parser'
'--jwt:JWT string parser'
'--kv:Key/Value file parser'
'--last:`last` and `lastb` command parser'
'--ls:`ls` command parser'
@@ -148,6 +151,7 @@ _jc() {
'--lsmod:`lsmod` command parser'
'--lsof:`lsof` command parser'
'--lsusb:`lsusb` command parser'
'--m3u:M3U and M3U8 file parser'
'--mount:`mount` command parser'
'--mpstat:`mpstat` command parser'
'--mpstat-s:`mpstat` command streaming parser'
@@ -180,6 +184,7 @@ _jc() {
'--systeminfo:`systeminfo` command parser'
'--time:`/usr/bin/time` command parser'
'--timedatectl:`timedatectl status` command parser'
'--timestamp:UNIX Epoch Timestamp string parser'
'--top:`top -b` command parser'
'--top-s:`top -b` command streaming parser'
'--tracepath:`tracepath` and `tracepath6` command parser'
@@ -191,6 +196,7 @@ _jc() {
'--update-alt-q:`update-alternatives --query` command parser'
'--upower:`upower` command parser'
'--uptime:`uptime` command parser'
'--url:URL string parser'
'--vmstat:`vmstat` command parser'
'--vmstat-s:`vmstat` command streaming parser'
'--w:`w` command parser'
+4 -4
View File
@@ -22,7 +22,7 @@ jc - JSON Convert lib module
```python
def parse(parser_mod_name: str,
data: Union[str, Iterable[str]],
data: Union[str, bytes, Iterable[str]],
quiet: bool = False,
raw: bool = False,
ignore_exceptions: bool = None,
@@ -67,9 +67,9 @@ Parameters:
cli-name, and --argument-name
variants of the module name.
data: (string or data to parse (string for normal
iterable) parsers, iterable of strings for
streaming parsers)
data: (string or data to parse (string or bytes for
bytes or standard parsers, iterable of
iterable) strings for streaming parsers)
raw: (boolean) output preprocessed JSON if True
+1 -1
View File
@@ -250,4 +250,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -103,4 +103,4 @@ Returns:
### Parser Information
Compatibility: darwin
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -131,4 +131,4 @@ Returns:
### Parser Information
Compatibility: darwin
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -140,4 +140,4 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -143,4 +143,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -79,4 +79,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -77,4 +77,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -100,4 +100,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 2.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -120,4 +120,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.10 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -345,4 +345,4 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin, win32, cygwin
Version 2.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 2.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -143,4 +143,4 @@ Returns:
### Parser Information
Compatibility: win32
Version 1.5 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
Version 1.6 by Rasheed Elsaleh (rasheed@rebelliondefense.com)
+1 -1
View File
@@ -148,4 +148,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -154,4 +154,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -110,4 +110,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+67
View File
@@ -0,0 +1,67 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.email_address"></a>
# jc.parsers.email\_address
jc - JSON Convert Email Address string parser
Usage (cli):
$ echo "username@example.com" | jc --email-address
Usage (module):
import jc
result = jc.parse('email_address', email_address_string)
Schema:
{
"username": string,
"domain": string,
"local": string,
"local_plus_suffix": string or null
}
Examples:
$ echo 'joe.user@gmail.com' | jc --email-address -p
{
"username": "joe.user",
"domain": "gmail.com",
"local": "joe.user",
"local_plus_suffix": null
}
$ echo 'joe.user+spam@gmail.com' | jc --email-address -p
{
"username": "joe.user",
"domain": "gmail.com",
"local": "joe.user+spam",
"local_plus_suffix": "spam"
}
<a id="jc.parsers.email_address.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, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -95,4 +95,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -108,4 +108,4 @@ Returns:
### Parser Information
Compatibility: linux, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -172,4 +172,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -108,4 +108,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -132,4 +132,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -60,4 +60,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -340,4 +340,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -209,4 +209,4 @@ Returns:
### Parser Information
Compatibility: linux, aix, freebsd, darwin
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -182,4 +182,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -130,4 +130,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+91
View File
@@ -0,0 +1,91 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.iso_datetime"></a>
# jc.parsers.iso\_datetime
jc - JSON Convert ISO 8601 Datetime string parser
This parser supports standard ISO 8601 strings that include both date and
time. If no timezone or offset information is available in the sring, then
UTC timezone is used.
Usage (cli):
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime
Usage (module):
import jc
result = jc.parse('iso_datetime', iso_8601_string)
Schema:
{
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
"microsecond": integer,
"period": string,
"utc_offset": string,
"day_of_year": integer,
"week_of_year": integer,
"iso": string,
"timestamp": integer # [0]
}
[0] timezone aware UNIX timestamp expressed in UTC
Examples:
$ echo "2022-07-20T14:52:45Z" | jc --iso-datetime -p
{
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 20,
"weekday": "Wed",
"weekday_num": 3,
"hour": 2,
"hour_24": 14,
"minute": 52,
"second": 45,
"microsecond": 0,
"period": "PM",
"utc_offset": "+0000",
"day_of_year": 201,
"week_of_year": 29,
"iso": "2022-07-20T14:52:45+00:00",
"timestamp": 1658328765
}
<a id="jc.parsers.iso_datetime.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
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, aix, freebsd, darwin, win32, cygwin
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -116,4 +116,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+73
View File
@@ -0,0 +1,73 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.jwt"></a>
# jc.parsers.jwt
jc - JSON Convert JWT string parser
> Note: `jc` will not check the integrity of the JWT payload.
Usage (cli):
$ echo "eyJhbGciOiJIUzI1N..." | jc --jwt
Usage (module):
import jc
result = jc.parse('jwt', jwt_string)
Schema:
{
"header": {
"alg": string,
"typ": string
},
"payload": {
<key name>: string/integer/float/boolean/null
},
"signature": string # [0]
}
[0] in colon-delimited hex notation
Examples:
% echo 'eyJhbGciOiJIUzI1N...' | jc --jwt -p
{
"header": {
"alg": "HS256",
"typ": "JWT"
},
"payload": {
"sub": "1234567890",
"name": "John Doe",
"iat": 1516239022
},
"signature": "49:f9:4a:c7:04:49:48:c7:8a:28:5d:90:4f:87:f0:a4:c7..."
}
<a id="jc.parsers.jwt.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, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -140,4 +140,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -99,4 +99,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -297,4 +297,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.9 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -148,4 +148,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -142,4 +142,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+90
View File
@@ -0,0 +1,90 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.m3u"></a>
# jc.parsers.m3u
jc - JSON Convert M3U and M3U8 file parser
This parser will make a best-effort to parse extended field information. If
the extended fields cannot be successfully parsed, then an `unparsed_info`
field will be added to the object. If not using `--quiet`, then a warning
message also will be printed to `STDERR`.
Usage (cli):
$ cat playlist.m3u | jc --m3u
Usage (module):
import jc
result = jc.parse('m3u', m3u_file_output)
Schema:
[
{
"runtime": integer,
"display": string,
"path": string,
<extended fields>: string, # [0]
"unparsed_info": string, # [1]
}
]
[0] Field names are pulled directly from the #EXTINF: line
[1] Only added if the extended information cannot be parsed
Examples:
$ cat playlist.m3u | jc --m3u -p
[
{
"runtime": 105,
"display": "Example artist - Example title",
"path": "C:\\Files\\My Music\\Example.mp3"
},
{
"runtime": 321,
"display": "Example Artist2 - Example title2",
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
}
]
$ cat playlist.m3u | jc --m3u -p -r
[
{
"runtime": "105",
"display": "Example artist - Example title",
"path": "C:\\Files\\My Music\\Example.mp3"
},
{
"runtime": "321",
"display": "Example Artist2 - Example title2",
"path": "C:\\Files\\My Music\\Favorites\\Example2.ogg"
}
]
<a id="jc.parsers.m3u.parse"></a>
### parse
```python
def parse(data: str, raw: bool = False, quiet: bool = False) -> List[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:
List of Dictionaries. Raw or processed structured data.
### Parser Information
Compatibility: linux, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -137,4 +137,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -125,4 +125,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -378,4 +378,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.13 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -229,4 +229,4 @@ Returns:
### Parser Information
Compatibility: linux, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -148,4 +148,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -107,4 +107,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -185,4 +185,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -106,4 +106,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -229,4 +229,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -131,4 +131,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -184,4 +184,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -157,4 +157,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -114,4 +114,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -225,4 +225,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -124,4 +124,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -303,4 +303,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -193,4 +193,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.11 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.12 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -104,4 +104,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -98,4 +98,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -234,4 +234,4 @@ Returns:
### Parser Information
Compatibility: win32
Version 1.2 by Jon Smith (jon@rebelliondefense.com)
Version 1.3 by Jon Smith (jon@rebelliondefense.com)
+1 -1
View File
@@ -155,4 +155,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -87,4 +87,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+122
View File
@@ -0,0 +1,122 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.timestamp"></a>
# jc.parsers.timestamp
jc - JSON Convert UNIX Epoch Timestamp string parser
The naive fields are based on the local time of the system the parser is
run on.
The utc fields are timezone-aware, based on the UTC timezone.
Usage (cli):
$ echo "2022-07-20T14:52:45Z" | jc --timestamp
Usage (module):
import jc
result = jc.parse('timestamp', timestamp_string)
Schema:
{
"naive": {
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
"period": string,
"day_of_year": integer,
"week_of_year": integer,
"iso": string
},
"utc": {
"year": integer,
"month": string,
"month_num": integer,
"day": integer,
"weekday": string,
"weekday_num": integer,
"hour": integer,
"hour_24": integer,
"minute": integer,
"second": integer,
"period": string,
"utc_offset": string,
"day_of_year": integer,
"week_of_year": integer,
"iso": string
}
}
Examples:
$ echo '1658599410' | jc --timestamp -p
{
"naive": {
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 23,
"weekday": "Sat",
"weekday_num": 6,
"hour": 11,
"hour_24": 11,
"minute": 3,
"second": 30,
"period": "AM",
"day_of_year": 204,
"week_of_year": 29,
"iso": "2022-07-23T11:03:30"
},
"utc": {
"year": 2022,
"month": "Jul",
"month_num": 7,
"day": 23,
"weekday": "Sat",
"weekday_num": 6,
"hour": 6,
"hour_24": 18,
"minute": 3,
"second": 30,
"period": "PM",
"utc_offset": "+0000",
"day_of_year": 204,
"week_of_year": 29,
"iso": "2022-07-23T18:03:30+00:00"
}
}
<a id="jc.parsers.timestamp.parse"></a>
### parse
```python
def parse(data, raw=False, quiet=False)
```
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, aix, freebsd, darwin, win32, cygwin
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -336,4 +336,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -177,4 +177,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -154,4 +154,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -143,4 +143,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -223,4 +223,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -161,4 +161,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -154,4 +154,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -88,4 +88,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+223
View File
@@ -0,0 +1,223 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.url"></a>
# jc.parsers.url
jc - JSON Convert URL string parser
Normalized, Encoded, and Decoded versions of the original URL and URL parts
are included in the output. Encoding and Decoding is best effort.
> Note: Do not use the Encoded fields for a URL that has already been
> Encoded. Similarly, do not use the Decoded fields for a URL that has
> already been Decoded.
This parser will work with naked and wrapped URL strings:
- `scheme://host/path`
- `URL:scheme://host/path`
- `<scheme://host/path>`
- `<URL:scheme://host/path>`
Usage (cli):
$ echo "http://example.com/test/path?q1=foo&q2=bar#frag" | jc --url
Usage (module):
import jc
result = jc.parse('url', url_string)
Schema:
{
"url": string,
"scheme": string or null,
"netloc": string or null,
"path": string or null,
"path_list": [ array or null
string
],
"query": string or null,
"query_obj": { object or null
<query-key>: [ array or null
<query-value> string # [0]
]
},
"fragment": string or null,
"username": string or null,
"password": string or null,
"hostname": string or null,
"port": integer or null, # [1]
"encoded": {
"url": string,
"scheme": string or null,
"netloc": string or null,
"path": string or null,
"path_list": [ array or null
string
],
"query": string or null,
"fragment": string or null,
"username": string or null,
"password": string or null,
"hostname": string or null,
"port": integer or null, # [1]
},
"decoded": {
"url": string,
"scheme": string or null,
"netloc": string or null,
"path": string or null,
"path_list": [ array or null
string
],
"query": string or null,
"fragment": string or null,
"username": string or null,
"password": string or null,
"hostname": string or null,
"port": integer or null, # [1]
}
}
[0] Duplicate query-keys will have their values consolidated into the
array of query-values
[1] Invalid port values will be converted to null/None and a warning
message will be printed to `STDERR` if quiet=False
Examples:
$ echo "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag" \\
| jc --url -p
{
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"query_obj": {
"q1": [
"foo",
"bar"
],
"q2": [
"baz"
]
},
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null,
"encoded": {
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null
},
"decoded": {
"url": "http://example.com/test/path?q1=foo&q1=bar&q2=baz#frag",
"scheme": "http",
"netloc": "example.com",
"path": "/test/path",
"path_list": [
"test",
"path"
],
"query": "q1=foo&q1=bar&q2=baz",
"fragment": "frag",
"username": null,
"password": null,
"hostname": "example.com",
"port": null
}
}
$ echo "ftp://localhost/filepath" | jc --url -p
{
"url": "ftp://localhost/filepath",
"scheme": "ftp",
"netloc": "localhost",
"path": "/filepath",
"path_list": [
"filepath"
],
"query": null,
"query_obj": null,
"fragment": null,
"username": null,
"password": null,
"hostname": "localhost",
"port": null,
"encoded": {
"url": "ftp://localhost/filepath",
"scheme": "ftp",
"netloc": "localhost",
"path": "/filepath",
"path_list": [
"filepath"
],
"query": null,
"fragment": null,
"username": null,
"password": null,
"hostname": "localhost",
"port": null
},
"decoded": {
"url": "ftp://localhost/filepath",
"scheme": "ftp",
"netloc": "localhost",
"path": "/filepath",
"path_list": [
"filepath"
],
"query": null,
"fragment": null,
"username": null,
"password": null,
"hostname": "localhost",
"port": null
}
}
<a id="jc.parsers.url.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, darwin, cygwin, win32, aix, freebsd
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -149,4 +149,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -123,4 +123,4 @@ Returns:
### Parser Information
Compatibility: linux
Version 1.0 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -126,4 +126,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.5 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -77,4 +77,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.3 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -158,4 +158,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin, cygwin, aix, freebsd
Version 1.6 by Kelly Brazil (kellyjonbrazil@gmail.com)
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
+1 -1
View File
@@ -99,4 +99,4 @@ Returns:
### Parser Information
Compatibility: linux, darwin
Version 1.0 by Matt J (https://github.com/listuser)
Version 1.1 by Matt J (https://github.com/listuser)
+1 -1
View File
@@ -64,7 +64,7 @@ Use `help(jc.lib)` for details.
parse(
parser_module_name: str,
data: str | Iterable
data: str | bytes | Iterable
) -> dict | list[dict] | Iterable[dict]
High-level API to easily access the parser. This API will find both
+1 -1
View File
@@ -60,7 +60,7 @@ Use `help(jc.lib)` for details.
parse(
parser_module_name: str,
data: str | Iterable
data: str | bytes | Iterable
) -> dict | list[dict] | Iterable[dict]
High-level API to easily access the parser. This API will find both
+5 -3
View File
@@ -225,9 +225,11 @@ def help_doc(options):
f'Compatibility: {compatible}\n\n'\
f'Version {version} by {author} ({author_email})\n'
return doc_text
utils._safe_pager(doc_text)
return
return helptext()
utils._safe_print(helptext())
return
def versiontext():
@@ -504,7 +506,7 @@ def main():
sys.exit(0)
if help_me:
utils._safe_print(help_doc(sys.argv))
help_doc(sys.argv)
sys.exit(0)
if version_info:
+11 -5
View File
@@ -6,7 +6,7 @@ import importlib
from typing import Dict, List, Iterable, Union, Iterator
from jc import appdirs
__version__ = '1.20.2'
__version__ = '1.20.3'
parsers = [
'acpi',
@@ -29,6 +29,7 @@ parsers = [
'dmidecode',
'dpkg-l',
'du',
'email-address',
'env',
'file',
'finger',
@@ -50,9 +51,11 @@ parsers = [
'iostat',
'iostat-s',
'iptables',
'iso-datetime',
'iw-scan',
'jar-manifest',
'jobs',
'jwt',
'kv',
'last',
'ls',
@@ -61,6 +64,7 @@ parsers = [
'lsmod',
'lsof',
'lsusb',
'm3u',
'mount',
'mpstat',
'mpstat-s',
@@ -93,6 +97,7 @@ parsers = [
'systeminfo',
'time',
'timedatectl',
'timestamp',
'top',
'top-s',
'tracepath',
@@ -104,6 +109,7 @@ parsers = [
'update-alt-q',
'upower',
'uptime',
'url',
'vmstat',
'vmstat-s',
'w',
@@ -170,7 +176,7 @@ def _parser_is_streaming(parser):
def parse(
parser_mod_name: str,
data: Union[str, Iterable[str]],
data: Union[str, bytes, Iterable[str]],
quiet: bool = False,
raw: bool = False,
ignore_exceptions: bool = None,
@@ -215,9 +221,9 @@ def parse(
cli-name, and --argument-name
variants of the module name.
data: (string or data to parse (string for normal
iterable) parsers, iterable of strings for
streaming parsers)
data: (string or data to parse (string or bytes for
bytes or standard parsers, iterable of
iterable) strings for streaming parsers)
raw: (boolean) output preprocessed JSON if True
+4 -4
View File
@@ -227,7 +227,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
version = '1.4'
description = '`acpi` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -250,9 +250,9 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = ['id', 'charge_percent', 'design_capacity_mah', 'last_full_capacity',
'last_full_capacity_percent']
float_list = ['temperature']
int_list = {'id', 'charge_percent', 'design_capacity_mah', 'last_full_capacity',
'last_full_capacity_percent'}
float_list = {'temperature'}
for entry in proc_data:
for key in entry:
+4 -4
View File
@@ -80,7 +80,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
version = '1.5'
description = '`airport -I` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -103,9 +103,9 @@ def _process(proc_data):
Dictionary. Structured data to conform to the schema.
"""
# integer changes
int_list = ['agrctlrssi', 'agrextrssi', 'agrctlnoise', 'agrextnoise',
'lasttxrate', 'maxrate', 'lastassocstatus', 'mcs']
int_list = {'agrctlrssi', 'agrextrssi', 'agrctlnoise', 'agrextnoise',
'lasttxrate', 'maxrate', 'lastassocstatus', 'mcs'}
for key in proc_data:
if key in int_list:
proc_data[key] = jc.utils.convert_to_int(proc_data[key])
+3 -3
View File
@@ -109,7 +109,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
version = '1.6'
description = '`airport -s` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -135,8 +135,8 @@ def _process(proc_data):
for entry in proc_data:
# convert integers and booleans
int_list = ['rssi']
bool_list = ['ht']
int_list = {'rssi'}
bool_list = {'ht'}
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+2 -2
View File
@@ -119,7 +119,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.9'
version = '1.10'
description = '`arp` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -142,13 +142,13 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
List of Dictionaries. Structured data to conform to the schema:
"""
int_list = {'expires'}
# in BSD style, change name to null if it is a question mark
for entry in proc_data:
if 'name' in entry and entry['name'] == '?':
entry['name'] = None
int_list = ['expires']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+8 -6
View File
@@ -121,7 +121,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
version = '1.6'
description = '`blkid` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -144,15 +144,17 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {
'part_entry_number', 'part_entry_offset', 'part_entry_size', 'id_part_entry_number',
'id_part_entry_offset', 'id_part_entry_size', 'minimum_io_size', 'physical_sector_size',
'logical_sector_size', 'id_iolimit_minimum_io_size', 'id_iolimit_physical_sector_size',
'id_iolimit_logical_sector_size'
}
for entry in proc_data:
if 'devname' in entry:
entry['device'] = entry.pop('devname')
int_list = ['part_entry_number', 'part_entry_offset', 'part_entry_size',
'id_part_entry_number', 'id_part_entry_offset', 'id_part_entry_size',
'minimum_io_size', 'physical_sector_size', 'logical_sector_size',
'id_iolimit_minimum_io_size', 'id_iolimit_physical_sector_size',
'id_iolimit_logical_sector_size']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -3
View File
@@ -57,7 +57,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.0'
version = '1.1'
description = '`chage --list` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -80,8 +80,8 @@ def _process(proc_data: Dict) -> Dict:
Dictionary. Structured to conform to the schema.
"""
int_list = ['min_days_between_password_change', 'max_days_between_password_change',
'warning_days_before_password_expires']
int_list = {'min_days_between_password_change', 'max_days_between_password_change',
'warning_days_before_password_expires'}
for key in proc_data:
if key in int_list:
+2 -2
View File
@@ -54,7 +54,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.3'
version = '1.4'
description = '`cksum` and `sum` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -77,9 +77,9 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'checksum', 'blocks'}
for entry in proc_data:
int_list = ['checksum', 'blocks']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -3
View File
@@ -78,7 +78,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '2.4'
version = '2.5'
description = '`date` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -128,7 +128,7 @@ def parse(data, raw=False, quiet=False):
# find the timezone no matter where it is in the string
# from https://www.timeanddate.com/time/zones/
tz_abbr = [
tz_abbr = {
'A', 'ACDT', 'ACST', 'ACT', 'ACWST', 'ADT', 'AEDT', 'AEST', 'AET', 'AFT', 'AKDT',
'AKST', 'ALMT', 'AMST', 'AMT', 'ANAST', 'ANAT', 'AQTT', 'ART', 'AST', 'AT', 'AWDT',
'AWST', 'AZOST', 'AZOT', 'AZST', 'AZT', 'AoE', 'B', 'BNT', 'BOT', 'BRST', 'BRT', 'BST',
@@ -154,7 +154,7 @@ def parse(data, raw=False, quiet=False):
'UTC+0400', 'UTC+0430', 'UTC+0500', 'UTC+0530', 'UTC+0545', 'UTC+0600', 'UTC+0630',
'UTC+0700', 'UTC+0800', 'UTC+0845', 'UTC+0900', 'UTC+1000', 'UTC+1030', 'UTC+1100',
'UTC+1200', 'UTC+1300', 'UTC+1345', 'UTC+1400'
]
}
tz = None
for term in data.replace('(', '').replace(')', '').split():
if term in tz_abbr:
+4 -4
View File
@@ -99,7 +99,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.10'
version = '1.11'
description = '`df` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -122,6 +122,8 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema:
"""
int_list = {'used', 'available', 'use_percent', 'capacity_percent', 'ifree',
'iused', 'iused_percent'}
for entry in proc_data:
# change 'avail' to 'available'
@@ -155,9 +157,7 @@ def _process(proc_data):
if 'iused_percent' in entry:
entry['iused_percent'] = entry['iused_percent'].rstrip('%')
# change used, available, use_percent, capacity_percent, ifree, iused, iused_percent to int
int_list = ['used', 'available', 'use_percent', 'capacity_percent', 'ifree',
'iused', 'iused_percent']
# convert integers
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+4 -3
View File
@@ -322,7 +322,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '2.3'
version = '2.4'
description = '`dig` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -345,9 +345,10 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'id', 'query_num', 'answer_num', 'authority_num', 'additional_num',
'rcvd', 'query_size', 'query_time'}
for entry in proc_data:
int_list = ['id', 'query_num', 'answer_num', 'authority_num', 'additional_num',
'rcvd', 'query_size', 'query_time']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -2
View File
@@ -121,7 +121,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
version = '1.6'
description = '`dir` command parser'
author = 'Rasheed Elsaleh'
author_email = 'rasheed@rebelliondefense.com'
@@ -143,6 +143,8 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'size'}
for entry in proc_data:
# add timestamps
if 'date' in entry and 'time' in entry:
@@ -151,7 +153,6 @@ def _process(proc_data):
entry['epoch'] = timestamp.naive
# add ints
int_list = ["size"]
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -2
View File
@@ -125,7 +125,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.4'
version = '1.5'
description = '`dmidecode` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -148,8 +148,9 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'type', 'bytes'}
for entry in proc_data:
int_list = ['type', 'bytes']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+31 -38
View File
@@ -132,7 +132,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.2'
version = '1.3'
description = '`dpkg -l` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -155,48 +155,41 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema:
"""
desired_map = {
'u': 'unknown',
'i': 'install',
'r': 'remove',
'p': 'purge',
'h': 'hold'
}
status_map = {
'n': 'not installed',
'i': 'installed',
'c': 'config-files',
'u': 'unpacked',
'f': 'failed config',
'h': 'half installed',
'w': 'trigger await',
't': 'trigger pending'
}
err_map = {
'r': 'reinstall required'
}
for entry in proc_data:
if 'codes' in entry:
desired, status, *err = list(entry['codes'])
desired, status, *err = list(entry['codes'].lower())
desired_map = {
'u': 'unknown',
'i': 'install',
'r': 'remove',
'p': 'purge',
'h': 'hold'
}
if desired in desired_map:
entry['desired'] = desired_map[desired]
for key, value in desired_map.items():
if desired.lower() == key:
entry['desired'] = value
break
if status in status_map:
entry['status'] = status_map[status]
status_map = {
'n': 'not installed',
'i': 'installed',
'c': 'config-files',
'u': 'unpacked',
'f': 'failed config',
'h': 'half installed',
'w': 'trigger await',
't': 'trigger pending'
}
for key, value in status_map.items():
if status.lower() == key:
entry['status'] = value
break
if err:
err_map = {
'r': 'reinstall required'
}
for key, value in err_map.items():
if err[0].lower() == key:
entry['error'] = value
break
if err and err[0] in err_map:
entry['error'] = err_map[err[0]]
return proc_data
+3 -2
View File
@@ -88,7 +88,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
version = '1.6'
description = '`du` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -111,7 +111,8 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = ['size']
int_list = {'size'}
for entry in proc_data:
for key in entry:
if key in int_list:
+113
View File
@@ -0,0 +1,113 @@
"""jc - JSON Convert Email Address string parser
Usage (cli):
$ echo "username@example.com" | jc --email-address
Usage (module):
import jc
result = jc.parse('email_address', email_address_string)
Schema:
{
"username": string,
"domain": string,
"local": string,
"local_plus_suffix": string or null
}
Examples:
$ echo 'joe.user@gmail.com' | jc --email-address -p
{
"username": "joe.user",
"domain": "gmail.com",
"local": "joe.user",
"local_plus_suffix": null
}
$ echo 'joe.user+spam@gmail.com' | jc --email-address -p
{
"username": "joe.user",
"domain": "gmail.com",
"local": "joe.user+spam",
"local_plus_suffix": "spam"
}
"""
from typing import Dict
import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.0'
description = 'Email Address string parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
__version__ = info.version
def _process(proc_data: Dict) -> Dict:
"""
Final processing to conform to the schema.
Parameters:
proc_data: (Dictionary) raw structured data to process
Returns:
Dictionary. Structured to conform to the schema.
"""
return proc_data
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.
"""
jc.utils.compatibility(__name__, info.compatible, quiet)
jc.utils.input_type_check(data)
raw_output: Dict = {}
if jc.utils.has_data(data):
data = data.strip()
domain = data.rsplit('@', maxsplit=1)[1]
local = data.rsplit('@', maxsplit=1)[0]
local_plus_prefix = None
local_plus_suffix = None
try:
local_plus_suffix = local.split('+', maxsplit=1)[1]
local_plus_prefix = local.split('+', maxsplit=1)[0]
except IndexError:
pass
raw_output = {
'username': local_plus_prefix or local,
'domain': domain,
'local': local,
'local_plus_suffix': local_plus_suffix
}
return raw_output if raw else _process(raw_output)
+2 -2
View File
@@ -73,7 +73,7 @@ import jc.parsers.universal
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.5'
version = '1.6'
description = '`free` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -96,9 +96,9 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'total', 'used', 'free', 'shared', 'buff_cache', 'available'}
for entry in proc_data:
int_list = ['total', 'used', 'free', 'shared', 'buff_cache', 'available']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -2
View File
@@ -85,7 +85,7 @@ import jc.utils
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.6'
version = '1.7'
description = '`/etc/fstab` file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -107,8 +107,9 @@ def _process(proc_data):
List of Dictionaries. Structured data to conform to the schema.
"""
int_list = {'fs_freq', 'fs_passno'}
for entry in proc_data:
int_list = ['fs_freq', 'fs_passno']
for key in entry:
if key in int_list:
entry[key] = jc.utils.convert_to_int(entry[key])
+3 -2
View File
@@ -153,7 +153,7 @@ changes_pattern = re.compile(r'\s(?P<files>\d+)\s+(files? changed),\s+(?P<insert
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.1'
version = '1.2'
description = '`git log` command parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
@@ -176,7 +176,7 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
List of Dictionaries. Structured to conform to the schema.
"""
int_list = ['files_changed', 'insertions', 'deletions']
int_list = {'files_changed', 'insertions', 'deletions'}
for entry in proc_data:
if 'date' in entry:
@@ -188,6 +188,7 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
for key in entry['stats']:
if key in int_list:
entry['stats'][key] = jc.utils.convert_to_int(entry['stats'][key])
return proc_data

Some files were not shown because too many files have changed in this diff Show More