mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-07 00:57:22 +02:00
add apt_cache_show parser. Split list values into an array. fix tests.
This commit is contained in:
@ -1,11 +1,14 @@
|
||||
jc changelog
|
||||
|
||||
20240226 v1.25.2
|
||||
- Add `apt-cache show` command parser
|
||||
- Enhance `df` parser to add human readable output support. Note: the `size`
|
||||
field has been changed to an integer and all size values have been normalized
|
||||
to bytes.
|
||||
- Enhance `free` parser to add human readable output support. All size values
|
||||
have been normalizd to bytes.
|
||||
- Enhance `/proc/pid/stat` parser to support "Idle" state
|
||||
- Enhance `rpm_qi` and `pkg_index_deb` parsers to split list fields into arrays
|
||||
- Fix `iwconfig` parser to handle more special characters in the SSID name
|
||||
- Documentation updates
|
||||
|
||||
|
@ -159,6 +159,7 @@ option.
|
||||
| `--acpi` | `acpi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) |
|
||||
| `--airport` | `airport -I` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport) |
|
||||
| `--airport-s` | `airport -s` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) |
|
||||
| `--apt-cache-show` | `apt-cache show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/apt_cache_show) |
|
||||
| `--arp` | `arp` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) |
|
||||
| `--asciitable` | ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable) |
|
||||
| `--asciitable-m` | multi-line ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) |
|
||||
|
@ -3,8 +3,8 @@ _jc()
|
||||
local cur prev words cword jc_commands jc_parsers jc_options \
|
||||
jc_about_options jc_about_mod_options jc_help_options jc_special_options
|
||||
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_commands=(acpi airport apt-cache arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_parsers=(--acpi --airport --airport-s --apt-cache-show --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_options=(--force-color -C --debug -d --monochrome -m --meta-out -M --pretty -p --quiet -q --raw -r --slurp -s --unbuffer -u --yaml-out -y)
|
||||
jc_about_options=(--about -a)
|
||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||
|
@ -9,10 +9,11 @@ _jc() {
|
||||
jc_help_options jc_help_options_describe \
|
||||
jc_special_options jc_special_options_describe
|
||||
|
||||
jc_commands=(acpi airport arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_commands=(acpi airport apt-cache arp blkid bluetoothctl cbt certbot chage cksum crontab curl date debconf-show df dig dmidecode dpkg du efibootmgr env file findmnt finger free git gpg hciconfig host id ifconfig iostat ip iptables iw iwconfig jobs last lastb ls lsattr lsb_release lsblk lsmod lsof lspci lsusb md5 md5sum mdadm mount mpstat netstat nmcli nsd-control ntpq os-prober pidstat ping ping6 pip pip3 postconf printenv ps route rpm rsync sfdisk sha1sum sha224sum sha256sum sha384sum sha512sum shasum ss ssh sshd stat sum swapon sysctl systemctl systeminfo timedatectl top tracepath tracepath6 traceroute traceroute6 tune2fs udevadm ufw uname update-alternatives upower uptime vdir veracrypt vmstat w wc who xrandr zipinfo zpool)
|
||||
jc_commands_describe=(
|
||||
'acpi:run "acpi" command with magic syntax.'
|
||||
'airport:run "airport" command with magic syntax.'
|
||||
'apt-cache:run "apt-cache" command with magic syntax.'
|
||||
'arp:run "arp" command with magic syntax.'
|
||||
'blkid:run "blkid" command with magic syntax.'
|
||||
'bluetoothctl:run "bluetoothctl" command with magic syntax.'
|
||||
@ -117,11 +118,12 @@ _jc() {
|
||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||
'zpool:run "zpool" command with magic syntax.'
|
||||
)
|
||||
jc_parsers=(--acpi --airport --airport-s --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers=(--acpi --airport --airport-s --apt-cache-show --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --curl-head --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --efibootmgr --email-address --env --file --find --findmnt --finger --free --fstab --git-log --git-log-s --git-ls-remote --gpg --group --gshadow --hash --hashsum --hciconfig --history --host --hosts --http-headers --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --kv-dup --last --ls --ls-s --lsattr --lsb-release --lsblk --lsmod --lsof --lspci --lsusb --m3u --mdadm --mount --mpstat --mpstat-s --netstat --nmcli --nsd-control --ntpq --openvpn --os-prober --os-release --passwd --path --path-list --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-apk --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --proc-cmdline --proc-consoles --proc-cpuinfo --proc-crypto --proc-devices --proc-diskstats --proc-filesystems --proc-interrupts --proc-iomem --proc-ioports --proc-loadavg --proc-locks --proc-meminfo --proc-modules --proc-mtrr --proc-pagetypeinfo --proc-partitions --proc-slabinfo --proc-softirqs --proc-stat --proc-swaps --proc-uptime --proc-version --proc-vmallocinfo --proc-vmstat --proc-zoneinfo --proc-driver-rtc --proc-net-arp --proc-net-dev --proc-net-dev-mcast --proc-net-if-inet6 --proc-net-igmp --proc-net-igmp6 --proc-net-ipv6-route --proc-net-netlink --proc-net-netstat --proc-net-packet --proc-net-protocols --proc-net-route --proc-net-tcp --proc-net-unix --proc-pid-fdinfo --proc-pid-io --proc-pid-maps --proc-pid-mountinfo --proc-pid-numa-maps --proc-pid-smaps --proc-pid-stat --proc-pid-statm --proc-pid-status --ps --resolve-conf --route --rpm-qi --rsync --rsync-s --semver --sfdisk --shadow --srt --ss --ssh-conf --sshd-conf --stat --stat-s --swapon --sysctl --syslog --syslog-s --syslog-bsd --syslog-bsd-s --systemctl --systemctl-lj --systemctl-ls --systemctl-luf --systeminfo --time --timedatectl --timestamp --toml --top --top-s --tracepath --traceroute --tune2fs --udevadm --ufw --ufw-appinfo --uname --update-alt-gs --update-alt-q --upower --uptime --url --ver --veracrypt --vmstat --vmstat-s --w --wc --who --x509-cert --x509-csr --xml --xrandr --yaml --zipinfo --zpool-iostat --zpool-status)
|
||||
jc_parsers_describe=(
|
||||
'--acpi:`acpi` command parser'
|
||||
'--airport:`airport -I` command parser'
|
||||
'--airport-s:`airport -s` command parser'
|
||||
'--apt-cache-show:`apt-cache show` command parser'
|
||||
'--arp:`arp` command parser'
|
||||
'--asciitable:ASCII and Unicode table parser'
|
||||
'--asciitable-m:multi-line ASCII and Unicode table parser'
|
||||
|
@ -27,9 +27,15 @@ Schema:
|
||||
"maintainer": string,
|
||||
"description": string,
|
||||
"homepage": string,
|
||||
"depends": string,
|
||||
"conflicts": string,
|
||||
"replaces": string,
|
||||
"depends": [
|
||||
string
|
||||
],
|
||||
"conflicts": [
|
||||
string
|
||||
],
|
||||
"replaces": [
|
||||
string
|
||||
],
|
||||
"vcs_git": string,
|
||||
"sha256": string,
|
||||
"size": integer,
|
||||
@ -43,35 +49,44 @@ Examples:
|
||||
$ cat Packages | jc --pkg-index-deb
|
||||
[
|
||||
{
|
||||
"package": "aspnetcore-runtime-2.1",
|
||||
"version": "2.1.22-1",
|
||||
"package": "dotnet-host",
|
||||
"version": "3.1.16-1",
|
||||
"architecture": "amd64",
|
||||
"section": "libs",
|
||||
"priority": "standard",
|
||||
"installed_size": 146,
|
||||
"maintainer": ".NET Core Team <dotnetpackages@dotnetfoundation.org>",
|
||||
"description": "Microsoft .NET Core Host - 3.1.16",
|
||||
"homepage": "https://dot.net/core",
|
||||
"conflicts": [
|
||||
"dotnet",
|
||||
"dotnet-nightly"
|
||||
],
|
||||
"depends": [
|
||||
"libgcc1",
|
||||
"libstdc++6",
|
||||
"libc6"
|
||||
],
|
||||
"sha256": "2557da13447d61382f255eb751ba29cc1a8220899c1e3e640a7bb3d2a0c1d297",
|
||||
"size": 32594,
|
||||
"filename": "pool/main/d/dotnet-host/dotnet-host-3.1.16-x64.deb"
|
||||
},
|
||||
{
|
||||
"package": "aspnetcore-runtime-5.0",
|
||||
"version": "5.0.10-1",
|
||||
"architecture": "amd64",
|
||||
"section": "devel",
|
||||
"priority": "standard",
|
||||
"installed_size": 71081,
|
||||
"installed_size": 18551,
|
||||
"maintainer": "Microsoft <nugetaspnet@microsoft.com>",
|
||||
"description": "Microsoft ASP.NET Core 2.1.22 Shared Framework",
|
||||
"homepage": "https://www.asp.net/",
|
||||
"depends": "libc6 (>= 2.14), dotnet-runtime-2.1 (>= 2.1.22)",
|
||||
"sha256": "48d4e78a7ceff34105411172f4c3e91a0359b3929d84d26a493...",
|
||||
"size": 21937036,
|
||||
"filename": "pool/main/a/aspnetcore-runtime-2.1/aspnetcore-run..."
|
||||
},
|
||||
{
|
||||
"package": "azure-functions-core-tools-4",
|
||||
"version": "4.0.4590-1",
|
||||
"architecture": "amd64",
|
||||
"section": "devel",
|
||||
"priority": "optional",
|
||||
"maintainer": "Ahmed ElSayed <ahmels@microsoft.com>",
|
||||
"description": "Azure Function Core Tools v4",
|
||||
"homepage": "https://docs.microsoft.com/en-us/azure/azure-func...",
|
||||
"conflicts": "azure-functions-core-tools-2, azure-functions-co...",
|
||||
"replaces": "azure-functions-core-tools-2, azure-functions-cor...",
|
||||
"vcs_git": "https://github.com/Azure/azure-functions-core-tool...",
|
||||
"sha256": "a2a4f99d6d98ba0a46832570285552f2a93bab06cebbda2afc7...",
|
||||
"size": 124417844,
|
||||
"filename": "pool/main/a/azure-functions-core-tools-4/azure-fu..."
|
||||
"description": "Shared Framework for hosting of Microsoft ASP.NET Core applications. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/dotnet/aspnetcore). We happily accept issues and PRs.",
|
||||
"homepage": "https://asp.net",
|
||||
"depends": [
|
||||
"dotnet-runtime-5.0 (>= 5.0.10)"
|
||||
],
|
||||
"sha256": "1d9869f862cb4e9c46b245a343d8e39fbbc84d9f8ab9ef357c4643da20805ad3",
|
||||
"size": 6084188,
|
||||
"filename": "pool/main/a/aspnetcore-runtime-5.0/aspnetcore-runtime-5.0.10-x64.deb"
|
||||
}
|
||||
]
|
||||
|
||||
@ -137,4 +152,4 @@ Compatibility: linux, darwin, cygwin, win32, aix, freebsd
|
||||
|
||||
Source: [`jc/parsers/pkg_index_deb.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/pkg_index_deb.py)
|
||||
|
||||
Version 1.1 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.2 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
@ -48,6 +48,30 @@ Schema:
|
||||
"build_epoch_utc": integer, # [1]
|
||||
"build_host": string,
|
||||
"relocations": string,
|
||||
"depends": [
|
||||
string
|
||||
],
|
||||
"pre_depends": [
|
||||
string
|
||||
],
|
||||
"recommends": [
|
||||
string
|
||||
],
|
||||
"suggests": [
|
||||
string
|
||||
],
|
||||
"conflicts": [
|
||||
string
|
||||
],
|
||||
"breaks": [
|
||||
string
|
||||
],
|
||||
"tag": [
|
||||
string
|
||||
],
|
||||
"replaces": [
|
||||
string
|
||||
],
|
||||
"packager": string,
|
||||
"vendor": string,
|
||||
"url": string,
|
||||
@ -186,4 +210,4 @@ Compatibility: linux
|
||||
|
||||
Source: [`jc/parsers/rpm_qi.py`](https://github.com/kellyjonbrazil/jc/blob/master/jc/parsers/rpm_qi.py)
|
||||
|
||||
Version 1.7 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
Version 1.8 by Kelly Brazil (kellyjonbrazil@gmail.com)
|
||||
|
@ -16,6 +16,7 @@ parsers: List[str] = [
|
||||
'acpi',
|
||||
'airport',
|
||||
'airport-s',
|
||||
'apt-cache-show',
|
||||
'arp',
|
||||
'asciitable',
|
||||
'asciitable-m',
|
||||
|
188
jc/parsers/apt_cache_show.py
Normal file
188
jc/parsers/apt_cache_show.py
Normal file
@ -0,0 +1,188 @@
|
||||
"""jc - JSON Convert `apt-cache show` command parser
|
||||
|
||||
Usage (cli):
|
||||
|
||||
$ apt-cache show | jc --apt-cache-show
|
||||
|
||||
Usage (module):
|
||||
|
||||
import jc
|
||||
result = jc.parse('apt_cache_show', apt_cache_show_output)
|
||||
|
||||
Schema:
|
||||
|
||||
[
|
||||
{
|
||||
"package": string,
|
||||
"version": string,
|
||||
"installed_size": integer,
|
||||
"maintainer": string,
|
||||
"architecture": string,
|
||||
"depends": [
|
||||
string
|
||||
],
|
||||
"pre_depends": [
|
||||
string
|
||||
],
|
||||
"recommends": [
|
||||
string
|
||||
],
|
||||
"suggests": [
|
||||
string
|
||||
],
|
||||
"conflicts": [
|
||||
string
|
||||
],
|
||||
"breaks": [
|
||||
string
|
||||
],
|
||||
"description_md5": string,
|
||||
"multi_arch": string,
|
||||
"homepage": string,
|
||||
"section": string,
|
||||
"priority": string,
|
||||
"filename": string,
|
||||
"size": integer,
|
||||
"sha256": string,
|
||||
"description": string
|
||||
}
|
||||
]
|
||||
|
||||
Examples:
|
||||
|
||||
$ apt-cache show | jc --apt-cache-show -p
|
||||
[
|
||||
{
|
||||
"package": "systemd",
|
||||
"version": "247.3-6~bpo10+1",
|
||||
"installed_size": 16121,
|
||||
"maintainer": "Debian systemd Maintainers <pkg-systemd-maintaine..",
|
||||
"architecture": "amd64",
|
||||
"depends": [
|
||||
"libacl1 (>= 2.2.23)",
|
||||
"libapparmor1 (>= 2.13)",
|
||||
"libaudit1 (>= 1:2.2.1)",
|
||||
"libcap2 (>= 1:2.10)",
|
||||
"libcryptsetup12 (>= 2:2.0.1)",
|
||||
"libgnutls30 (>= 3.6.6)",
|
||||
"libgpg-error0 (>= 1.14)",
|
||||
"libip4tc0 (>= 1.6.0+snapshot20161117)",
|
||||
"libkmod2 (>= 5~)",
|
||||
"liblz4-1 (>= 0.0~r130)",
|
||||
"libmount1 (>= 2.30)",
|
||||
"libpam0g (>= 0.99.7.1)",
|
||||
"libseccomp2 (>= 2.3.1)",
|
||||
"libsystemd0 (= 247.3-6~bpo10+1)",
|
||||
"systemd-timesyncd | time-daemon",
|
||||
"util-linux (>= 2.27.1)",
|
||||
"mount (>= 2.26)",
|
||||
"adduser"
|
||||
],
|
||||
"pre_depends": [
|
||||
"libblkid1 (>= 2.24)",
|
||||
"libc6 (>= 2.28)",
|
||||
"libgcrypt20 (>= 1.8.0)",
|
||||
"liblz4-1 (>= 0.0~r122)",
|
||||
"liblzma5 (>= 5.1.1alpha+20120614)",
|
||||
"libselinux1 (>= 2.1.9)",
|
||||
"libzstd1 (>= 1.4.0)"
|
||||
],
|
||||
"recommends": [
|
||||
"dbus"
|
||||
],
|
||||
"suggests": [
|
||||
"systemd-container",
|
||||
"policykit-1"
|
||||
],
|
||||
"conflicts": [
|
||||
"consolekit",
|
||||
"libpam-ck-connector"
|
||||
],
|
||||
"breaks": [
|
||||
"python-dbusmock (<< 0.18)",
|
||||
"python3-dbusmock (<< 0.18)",
|
||||
"resolvconf (<< 1.83~)",
|
||||
"systemd-shim (<< 10-4~)",
|
||||
"udev (<< 247~)"
|
||||
],
|
||||
"description_md5": "19399579cbc0c47a303288bf15eadcd4",
|
||||
"multi_arch": "foreign",
|
||||
"homepage": "https://www.freedesktop.org/wiki/Software/systemd",
|
||||
"section": "admin",
|
||||
"priority": "important",
|
||||
"filename": "pool/main/s/systemd/systemd_247.3-6~bpo10+1_amd64.deb",
|
||||
"size": 4382056,
|
||||
"sha256": "2035450655ad02faa0f75dc952128b503e51df5795c67273c0f6...",
|
||||
"description": "system and service manager systemd is a system..."
|
||||
},
|
||||
...
|
||||
]
|
||||
|
||||
$ apt-cache show | jc --apt-cache-show -p -r
|
||||
[
|
||||
{
|
||||
"package": "systemd",
|
||||
"version": "247.3-6~bpo10+1",
|
||||
"installed_size": "16121",
|
||||
"maintainer": "Debian systemd Maintainers <pkg-systemd-maintain...",
|
||||
"architecture": "amd64",
|
||||
"depends": "libacl1 (>= 2.2.23), libapparmor1 (>= 2.13), libaud...",
|
||||
"pre_depends": "libblkid1 (>= 2.24), libc6 (>= 2.28), libgcrypt...",
|
||||
"recommends": "dbus",
|
||||
"suggests": "systemd-container, policykit-1",
|
||||
"conflicts": "consolekit, libpam-ck-connector",
|
||||
"breaks": "python-dbusmock (<< 0.18), python3-dbusmock (<< 0.18...",
|
||||
"description_md5": "19399579cbc0c47a303288bf15eadcd4",
|
||||
"multi_arch": "foreign",
|
||||
"homepage": "https://www.freedesktop.org/wiki/Software/systemd",
|
||||
"section": "admin",
|
||||
"priority": "important",
|
||||
"filename": "pool/main/s/systemd/systemd_247.3-6~bpo10+1_amd64.deb",
|
||||
"size": "4382056",
|
||||
"sha256": "2035450655ad02faa0f75dc952128b503e51df5795c67273c0f6...",
|
||||
"description": "system and service manager systemd is a system..."
|
||||
},
|
||||
...
|
||||
]
|
||||
"""
|
||||
from typing import List
|
||||
from jc.jc_types import JSONDictType
|
||||
import jc.parsers.rpm_qi as rpm_qi
|
||||
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.0'
|
||||
description = '`apt-cache show` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
details = 'Using the rpm-qi parser'
|
||||
compatible = ['linux']
|
||||
tags = ['command']
|
||||
magic_commands = ['apt-cache show']
|
||||
|
||||
|
||||
__version__ = info.version
|
||||
|
||||
|
||||
def parse(
|
||||
data: str,
|
||||
raw: bool = False,
|
||||
quiet: bool = False
|
||||
) -> List[JSONDictType]:
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
# This parser is an alias of rpm_qi.py
|
||||
rpm_qi.info = info # type: ignore
|
||||
return rpm_qi.parse(data, raw, quiet)
|
@ -22,9 +22,15 @@ Schema:
|
||||
"maintainer": string,
|
||||
"description": string,
|
||||
"homepage": string,
|
||||
"depends": string,
|
||||
"conflicts": string,
|
||||
"replaces": string,
|
||||
"depends": [
|
||||
string
|
||||
],
|
||||
"conflicts": [
|
||||
string
|
||||
],
|
||||
"replaces": [
|
||||
string
|
||||
],
|
||||
"vcs_git": string,
|
||||
"sha256": string,
|
||||
"size": integer,
|
||||
@ -38,35 +44,44 @@ Examples:
|
||||
$ cat Packages | jc --pkg-index-deb
|
||||
[
|
||||
{
|
||||
"package": "aspnetcore-runtime-2.1",
|
||||
"version": "2.1.22-1",
|
||||
"package": "dotnet-host",
|
||||
"version": "3.1.16-1",
|
||||
"architecture": "amd64",
|
||||
"section": "libs",
|
||||
"priority": "standard",
|
||||
"installed_size": 146,
|
||||
"maintainer": ".NET Core Team <dotnetpackages@dotnetfoundation.org>",
|
||||
"description": "Microsoft .NET Core Host - 3.1.16",
|
||||
"homepage": "https://dot.net/core",
|
||||
"conflicts": [
|
||||
"dotnet",
|
||||
"dotnet-nightly"
|
||||
],
|
||||
"depends": [
|
||||
"libgcc1",
|
||||
"libstdc++6",
|
||||
"libc6"
|
||||
],
|
||||
"sha256": "2557da13447d61382f255eb751ba29cc1a8220899c1e3e640a7bb3d2a0c1d297",
|
||||
"size": 32594,
|
||||
"filename": "pool/main/d/dotnet-host/dotnet-host-3.1.16-x64.deb"
|
||||
},
|
||||
{
|
||||
"package": "aspnetcore-runtime-5.0",
|
||||
"version": "5.0.10-1",
|
||||
"architecture": "amd64",
|
||||
"section": "devel",
|
||||
"priority": "standard",
|
||||
"installed_size": 71081,
|
||||
"installed_size": 18551,
|
||||
"maintainer": "Microsoft <nugetaspnet@microsoft.com>",
|
||||
"description": "Microsoft ASP.NET Core 2.1.22 Shared Framework",
|
||||
"homepage": "https://www.asp.net/",
|
||||
"depends": "libc6 (>= 2.14), dotnet-runtime-2.1 (>= 2.1.22)",
|
||||
"sha256": "48d4e78a7ceff34105411172f4c3e91a0359b3929d84d26a493...",
|
||||
"size": 21937036,
|
||||
"filename": "pool/main/a/aspnetcore-runtime-2.1/aspnetcore-run..."
|
||||
},
|
||||
{
|
||||
"package": "azure-functions-core-tools-4",
|
||||
"version": "4.0.4590-1",
|
||||
"architecture": "amd64",
|
||||
"section": "devel",
|
||||
"priority": "optional",
|
||||
"maintainer": "Ahmed ElSayed <ahmels@microsoft.com>",
|
||||
"description": "Azure Function Core Tools v4",
|
||||
"homepage": "https://docs.microsoft.com/en-us/azure/azure-func...",
|
||||
"conflicts": "azure-functions-core-tools-2, azure-functions-co...",
|
||||
"replaces": "azure-functions-core-tools-2, azure-functions-cor...",
|
||||
"vcs_git": "https://github.com/Azure/azure-functions-core-tool...",
|
||||
"sha256": "a2a4f99d6d98ba0a46832570285552f2a93bab06cebbda2afc7...",
|
||||
"size": 124417844,
|
||||
"filename": "pool/main/a/azure-functions-core-tools-4/azure-fu..."
|
||||
"description": "Shared Framework for hosting of Microsoft ASP.NET Core applications. It is open source, cross-platform and is supported by Microsoft. We hope you enjoy using it! If you do, please consider joining the active community of developers that are contributing to the project on GitHub (https://github.com/dotnet/aspnetcore). We happily accept issues and PRs.",
|
||||
"homepage": "https://asp.net",
|
||||
"depends": [
|
||||
"dotnet-runtime-5.0 (>= 5.0.10)"
|
||||
],
|
||||
"sha256": "1d9869f862cb4e9c46b245a343d8e39fbbc84d9f8ab9ef357c4643da20805ad3",
|
||||
"size": 6084188,
|
||||
"filename": "pool/main/a/aspnetcore-runtime-5.0/aspnetcore-runtime-5.0.10-x64.deb"
|
||||
}
|
||||
]
|
||||
|
||||
@ -112,7 +127,7 @@ import jc.parsers.rpm_qi as rpm_qi
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.1'
|
||||
version = '1.2'
|
||||
description = 'Debian Package Index file parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
|
@ -43,6 +43,30 @@ Schema:
|
||||
"build_epoch_utc": integer, # [1]
|
||||
"build_host": string,
|
||||
"relocations": string,
|
||||
"depends": [
|
||||
string
|
||||
],
|
||||
"pre_depends": [
|
||||
string
|
||||
],
|
||||
"recommends": [
|
||||
string
|
||||
],
|
||||
"suggests": [
|
||||
string
|
||||
],
|
||||
"conflicts": [
|
||||
string
|
||||
],
|
||||
"breaks": [
|
||||
string
|
||||
],
|
||||
"tag": [
|
||||
string
|
||||
],
|
||||
"replaces": [
|
||||
string
|
||||
],
|
||||
"packager": string,
|
||||
"vendor": string,
|
||||
"url": string,
|
||||
@ -161,7 +185,7 @@ import jc.utils
|
||||
|
||||
class info():
|
||||
"""Provides parser metadata (version, author, etc.)"""
|
||||
version = '1.7'
|
||||
version = '1.8'
|
||||
description = '`rpm -qi` command parser'
|
||||
author = 'Kelly Brazil'
|
||||
author_email = 'kellyjonbrazil@gmail.com'
|
||||
@ -186,12 +210,20 @@ def _process(proc_data):
|
||||
List of Dictionaries. Structured data to conform to the schema.
|
||||
"""
|
||||
int_list = {'epoch', 'size', 'installed_size'}
|
||||
split_list = {'depends', 'pre_depends', 'recommends', 'suggests', 'conflicts',
|
||||
'breaks', 'tag', 'replaces'}
|
||||
|
||||
for entry in proc_data:
|
||||
for key in entry:
|
||||
if key in int_list:
|
||||
entry[key] = jc.utils.convert_to_int(entry[key])
|
||||
|
||||
# for apt-cache show output
|
||||
if key in split_list:
|
||||
val_list = entry[key].split(',')
|
||||
val_list = [x.strip() for x in val_list if x]
|
||||
entry[key] = val_list
|
||||
|
||||
if 'build_date' in entry:
|
||||
timestamp = jc.utils.timestamp(entry['build_date'], format_hint=(3000,))
|
||||
entry['build_epoch'] = timestamp.naive
|
||||
@ -227,6 +259,7 @@ def parse(data, raw=False, quiet=False):
|
||||
last_entry = None
|
||||
this_entry = None
|
||||
desc_entry = False
|
||||
desc_en_entry = False
|
||||
description = []
|
||||
|
||||
if jc.utils.has_data(data):
|
||||
@ -245,24 +278,34 @@ def parse(data, raw=False, quiet=False):
|
||||
entry_obj = {}
|
||||
last_entry = this_entry
|
||||
desc_entry = False
|
||||
|
||||
if len(split_line) == 2:
|
||||
entry_obj[split_line[0].strip().lower().replace(' ', '_').replace('-', '_')] = split_line[1].strip()
|
||||
desc_en_entry = False
|
||||
|
||||
if line.startswith('Description :'):
|
||||
desc_entry = True
|
||||
description = []
|
||||
continue
|
||||
|
||||
# for apt-cache show output
|
||||
if line.startswith('Description-en:'):
|
||||
desc_en_entry = True
|
||||
description = [split_line[1].strip()]
|
||||
continue
|
||||
|
||||
if desc_entry:
|
||||
description.append(line)
|
||||
continue
|
||||
|
||||
if desc_en_entry and line.startswith(' '):
|
||||
description.append(line)
|
||||
continue
|
||||
|
||||
if len(split_line) == 2:
|
||||
keyname = jc.utils.normalize_key(split_line[0])
|
||||
entry_obj[keyname] = split_line[1].strip()
|
||||
|
||||
if entry_obj:
|
||||
if description:
|
||||
entry_obj['description'] = ' '.join(description)
|
||||
raw_output.append(entry_obj)
|
||||
|
||||
if raw:
|
||||
return raw_output
|
||||
else:
|
||||
return _process(raw_output)
|
||||
return raw_output if raw else _process(raw_output)
|
||||
|
5
man/jc.1
5
man/jc.1
@ -52,6 +52,11 @@ Parsers:
|
||||
\fB--airport-s\fP
|
||||
`airport -s` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--apt-cache-show\fP
|
||||
`apt-cache show` command parser
|
||||
|
||||
.TP
|
||||
.B
|
||||
\fB--arp\fP
|
||||
|
2
tests/fixtures/centos-7.7/rpm-qai.json
vendored
2
tests/fixtures/centos-7.7/rpm-qai.json
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/generic/pkg-index-deb.json
vendored
2
tests/fixtures/generic/pkg-index-deb.json
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user