1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-08 22:36:48 +02:00

rename deb-packages-index to pkg-index-deb

This commit is contained in:
Kelly Brazil
2023-12-09 10:17:48 -08:00
parent ee12c52291
commit 356857f5d6
11 changed files with 149 additions and 23 deletions

View File

@ -179,7 +179,6 @@ option.
| `--csv-s` | CSV file streaming parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/csv_s) |
| `--date` | `date` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/date) |
| `--datetime-iso` | ISO 8601 Datetime string parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/datetime_iso) |
| `--deb-packages-index` | Debian Packages Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/deb_packages_index) |
| `--debconf-show` | `debconf-show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/debconf_show) |
| `--df` | `df` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/df) |
| `--dig` | `dig` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/dig) |
@ -254,6 +253,7 @@ option.
| `--pip-list` | `pip list` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_list) |
| `--pip-show` | `pip show` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pip_show) |
| `--pkg-index-alpine` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_alpine) |
| `--pkg-index-deb` | Debian Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/pkg_index_deb) |
| `--plist` | PLIST file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/plist) |
| `--postconf` | `postconf -M` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/postconf) |
| `--proc` | `/proc/` file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/proc) |

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 bluetoothctl cbt certbot chage cksum crontab date debconf-show df dig dmidecode dpkg du 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 --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --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 --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --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 --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --plist --postconf --proc --proc-buddyinfo --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 --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --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 --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --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 --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --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 --unbuffer -u --yaml-out -y)
jc_about_options=(--about -a)
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)

View File

@ -115,7 +115,7 @@ _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 --date --datetime-iso --deb-packages-index --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --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 --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --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 --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --plist --postconf --proc --proc-buddyinfo --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 --arp --asciitable --asciitable-m --blkid --bluetoothctl --cbt --cef --cef-s --certbot --chage --cksum --clf --clf-s --crontab --crontab-u --csv --csv-s --date --datetime-iso --debconf-show --df --dig --dir --dmidecode --dpkg-l --du --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 --id --ifconfig --ini --ini-dup --iostat --iostat-s --ip-address --iptables --ip-route --iw-scan --iwconfig --jar-manifest --jobs --jwt --kv --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 --pci-ids --pgpass --pidstat --pidstat-s --ping --ping-s --pip-list --pip-show --pkg-index-alpine --pkg-index-deb --plist --postconf --proc --proc-buddyinfo --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'
@ -139,7 +139,6 @@ _jc() {
'--csv-s:CSV file streaming parser'
'--date:`date` command parser'
'--datetime-iso:ISO 8601 Datetime string parser'
'--deb-packages-index:Debian Packages Index file parser'
'--debconf-show:`debconf-show` command parser'
'--df:`df` command parser'
'--dig:`dig` command parser'
@ -214,6 +213,7 @@ _jc() {
'--pip-list:`pip list` command parser'
'--pip-show:`pip show` command parser'
'--pkg-index-alpine:Alpine Linux Package Index file parser'
'--pkg-index-deb:Debian Package Index file parser'
'--plist:PLIST file parser'
'--postconf:`postconf -M` command parser'
'--proc:`/proc/` file parser'

View File

@ -0,0 +1,126 @@
[Home](https://kellyjonbrazil.github.io/jc/)
<a id="jc.parsers.pkg_index_alpine"></a>
# jc.parsers.pkg\_index\_alpine
jc - JSON Convert Alpine Linux Package Index files
Usage (cli):
$ cat APKINDEX | jc --pkg-index-alpine
Usage (module):
import jc
result = jc.parse('pkg_index_alpine', pkg_index_alpine_output)
Schema:
[
{
"checksum": string,
"package": string,
"version": string,
"architecture": string,
"package_size": integer,
"installed_size": integer,
"description": string,
"url": string,
"license": string,
"origin": string,
"maintainer": {
"name": string,
"email": string,
},
"build_time": integer,
"commit": string,
"provider_priority": string,
"dependencies": [
string
],
"provides": [
string
],
"install_if": [
string
],
}
]
Example:
$ cat APKINDEX | jc --pkg-index-alpine
[
{
"checksum": "Q1znBl9k+RKgY6gl5Eg3iz73KZbLY=",
"package": "yasm",
"version": "1.3.0-r4",
"architecture": "x86_64",
"package_size": 772109,
"installed_size": 1753088,
"description": "A rewrite of NASM to allow for multiple synta...",
"url": "http://www.tortall.net/projects/yasm/",
"license": "BSD-2-Clause",
"origin": "yasm",
"maintainer": {
"name": "Natanael Copa",
"email": "ncopa@alpinelinux.org"
},
"build_time": 1681228881,
"commit": "84a227baf001b6e0208e3352b294e4d7a40e93de",
"dependencies": [
"so:libc.musl-x86_64.so.1"
],
"provides": [
"cmd:vsyasm=1.3.0-r4",
"cmd:yasm=1.3.0-r4",
"cmd:ytasm=1.3.0-r4"
]
}
]
$ cat APKINDEX | jc --pkg-index-alpine --raw
[
{
"C": "Q1znBl9k+RKgY6gl5Eg3iz73KZbLY=",
"P": "yasm",
"V": "1.3.0-r4",
"A": "x86_64",
"S": "772109",
"I": "1753088",
"T": "A rewrite of NASM to allow for multiple syntax supported...",
"U": "http://www.tortall.net/projects/yasm/",
"L": "BSD-2-Clause",
"o": "yasm",
"m": "Natanael Copa <ncopa@alpinelinux.org>",
"t": "1681228881",
"c": "84a227baf001b6e0208e3352b294e4d7a40e93de",
"D": "so:libc.musl-x86_64.so.1",
"p": "cmd:vsyasm=1.3.0-r4 cmd:yasm=1.3.0-r4 cmd:ytasm=1.3.0-r4"
},
]
<a id="jc.parsers.pkg_index_alpine.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 Roey Darwish Dror (roey.ghost@gmail.com)

View File

@ -34,7 +34,6 @@ parsers: List[str] = [
'csv-s',
'date',
'datetime-iso',
'deb-packages-index',
'debconf-show',
'df',
'dig',
@ -109,6 +108,7 @@ parsers: List[str] = [
'pip-list',
'pip-show',
'pkg-index-alpine',
'pkg-index-deb',
'plist',
'postconf',
'proc',

View File

@ -1,13 +1,13 @@
"""jc - JSON Convert Debian Packages Index file parser
"""jc - JSON Convert Debian Package Index file parser
Usage (cli):
$ cat Packages | jc --deb-packages-index
$ cat Packages | jc --pkg-index-deb
Usage (module):
import jc
result = jc.parse('deb_packages_index', deb_package_index_output)
result = jc.parse('pkg_index_deb', pkg_index_deb_output)
Schema:
@ -35,7 +35,7 @@ Schema:
Examples:
$ cat Packages | jc --deb-packages-index
$ cat Packages | jc --pkg-index-deb
[
{
"package": "aspnetcore-runtime-2.1",
@ -70,7 +70,7 @@ Examples:
}
]
$ cat Packages | jc --deb-packages-index -r
$ cat Packages | jc --pkg-index-deb -r
[
{
"package": "aspnetcore-runtime-2.1",
@ -113,7 +113,7 @@ import jc.parsers.rpm_qi as rpm_qi
class info():
"""Provides parser metadata (version, author, etc.)"""
version = '1.0'
description = 'Debian Packages Index file parser'
description = 'Debian Package Index file parser'
author = 'Kelly Brazil'
author_email = 'kellyjonbrazil@gmail.com'
details = 'Using the rpm-qi parser'

View File

@ -147,11 +147,6 @@ CSV file streaming parser
\fB--datetime-iso\fP
ISO 8601 Datetime string parser
.TP
.B
\fB--deb-packages-index\fP
Debian Packages Index file parser
.TP
.B
\fB--debconf-show\fP
@ -522,6 +517,11 @@ PostgreSQL password file parser
\fB--pkg-index-alpine\fP
Alpine Linux Package Index file parser
.TP
.B
\fB--pkg-index-deb\fP
Debian Package Index file parser
.TP
.B
\fB--plist\fP

View File

@ -2,7 +2,7 @@ import os
import unittest
import json
from typing import Dict
from jc.parsers.deb_packages_index import parse
from jc.parsers.pkg_index_deb import parse
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@ -15,8 +15,8 @@ class MyTests(unittest.TestCase):
def setUpClass(cls):
fixtures = {
'deb_packages_index': (
'fixtures/generic/deb-packages-index.out',
'fixtures/generic/deb-packages-index.json')
'fixtures/generic/pkg-index-deb.out',
'fixtures/generic/pkg-index-deb.json')
}
for file, filepaths in fixtures.items():
@ -26,16 +26,16 @@ class MyTests(unittest.TestCase):
cls.f_json[file] = json.loads(b.read())
def test_deb_packages_index_nodata(self):
def test_pkg_index_deb_nodata(self):
"""
Test 'deb_packages_index' with no data
Test 'pkg-index-deb' with no data
"""
self.assertEqual(parse('', quiet=True), [])
def test_deb_packages_index(self):
def test_pkg_index_deb(self):
"""
Test 'deb_packages_index'
Test 'pkg-index-deb'
"""
self.assertEqual(
parse(self.f_in['deb_packages_index'], quiet=True),