mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
add apkindex parser
This commit is contained in:
@ -1,12 +1,14 @@
|
|||||||
jc changelog
|
jc changelog
|
||||||
|
|
||||||
20231128 v1.24.0
|
20231128 v1.24.0
|
||||||
|
- Add `apkindex` parser for Alpine Linux Package Index files
|
||||||
- Add `deb-packages-index` parser for Debian/Ubuntu Package Index files
|
- Add `deb-packages-index` parser for Debian/Ubuntu Package Index files
|
||||||
- Add `debconf-show` command parser
|
- Add `debconf-show` command parser
|
||||||
- Add `swapon` command parser
|
- Add `swapon` command parser
|
||||||
- Add `tune2fs` command parser
|
- Add `tune2fs` command parser
|
||||||
- Remove `iso-datetime` parser (use `datetime-iso` instead)
|
- Remove `iso-datetime` parser deprecated since v1.22.1. (use `datetime-iso` instead)
|
||||||
- Update timezone change in Github Actions for node v16 requirement
|
- Update timezone change in Github Actions for node v16 requirement
|
||||||
|
- Add Python 3.12 tests to Github Actions
|
||||||
- Refactor `acpi` command parser for code cleanup
|
- Refactor `acpi` command parser for code cleanup
|
||||||
- Fix `iptables` parser for cases where the `target` field is blank in a rule
|
- Fix `iptables` parser for cases where the `target` field is blank in a rule
|
||||||
- Fix `vmstat` parsers for some cases where wide output is used
|
- Fix `vmstat` parsers for some cases where wide output is used
|
||||||
|
@ -160,6 +160,7 @@ option.
|
|||||||
| `--acpi` | `acpi` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/acpi) |
|
| `--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` | `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) |
|
| `--airport-s` | `airport -s` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/airport_s) |
|
||||||
|
| `--apkindex` | Alpine Linux Package Index file parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/apkindex) |
|
||||||
| `--arp` | `arp` command parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/arp) |
|
| `--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` | 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) |
|
| `--asciitable-m` | multi-line ASCII and Unicode table parser | [details](https://kellyjonbrazil.github.io/jc/docs/parsers/asciitable_m) |
|
||||||
|
@ -4,7 +4,7 @@ _jc()
|
|||||||
jc_about_options jc_about_mod_options jc_help_options jc_special_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 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_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 --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 --apkindex --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 --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_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_options=(--about -a)
|
||||||
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
jc_about_mod_options=(--pretty -p --yaml-out -y --monochrome -m --force-color -C)
|
||||||
|
@ -115,11 +115,12 @@ _jc() {
|
|||||||
'zipinfo:run "zipinfo" command with magic syntax.'
|
'zipinfo:run "zipinfo" command with magic syntax.'
|
||||||
'zpool:run "zpool" 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 --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 --apkindex --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 --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=(
|
jc_parsers_describe=(
|
||||||
'--acpi:`acpi` command parser'
|
'--acpi:`acpi` command parser'
|
||||||
'--airport:`airport -I` command parser'
|
'--airport:`airport -I` command parser'
|
||||||
'--airport-s:`airport -s` command parser'
|
'--airport-s:`airport -s` command parser'
|
||||||
|
'--apkindex:Alpine Linux Package Index file parser'
|
||||||
'--arp:`arp` command parser'
|
'--arp:`arp` command parser'
|
||||||
'--asciitable:ASCII and Unicode table parser'
|
'--asciitable:ASCII and Unicode table parser'
|
||||||
'--asciitable-m:multi-line ASCII and Unicode table parser'
|
'--asciitable-m:multi-line ASCII and Unicode table parser'
|
||||||
|
126
docs/parsers/apkindex.md
Normal file
126
docs/parsers/apkindex.md
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
[Home](https://kellyjonbrazil.github.io/jc/)
|
||||||
|
<a id="jc.parsers.apkindex"></a>
|
||||||
|
|
||||||
|
# jc.parsers.apkindex
|
||||||
|
|
||||||
|
jc - JSON Convert Alpine Linux Package Index files
|
||||||
|
|
||||||
|
Usage (cli):
|
||||||
|
|
||||||
|
$ jc --apkindex < APKINDEX
|
||||||
|
|
||||||
|
Usage (module):
|
||||||
|
|
||||||
|
import jc
|
||||||
|
result = jc.parse('apkindex', apkindex_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:
|
||||||
|
|
||||||
|
$ jc --apkindex < APKINDEX
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
$ jc --apkindex --raw < APKINDEX
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"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.apkindex.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)
|
@ -1,4 +1,4 @@
|
|||||||
"""jc - JSON Convert `APKINDEX` files
|
"""jc - JSON Convert Alpine Linux Package Index files
|
||||||
|
|
||||||
Usage (cli):
|
Usage (cli):
|
||||||
|
|
||||||
@ -7,32 +7,38 @@ Usage (cli):
|
|||||||
Usage (module):
|
Usage (module):
|
||||||
|
|
||||||
import jc
|
import jc
|
||||||
result = jc.parse('apkindex', apkindex)
|
result = jc.parse('apkindex', apkindex_output)
|
||||||
|
|
||||||
Schema:
|
Schema:
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"checksum": string,
|
"checksum": string,
|
||||||
"package": string,
|
"package": string,
|
||||||
"version": string,
|
"version": string,
|
||||||
"architecture": string,
|
"architecture": string,
|
||||||
"package_size": integer,
|
"package_size": integer,
|
||||||
"installed_size": integer,
|
"installed_size": integer,
|
||||||
"description": string,
|
"description": string,
|
||||||
"url": string,
|
"url": string,
|
||||||
"license": string,
|
"license": string,
|
||||||
"origin": string,
|
"origin": string,
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
"name": string,
|
"name": string,
|
||||||
"email": string,
|
"email": string,
|
||||||
},
|
},
|
||||||
"build_time": integer,
|
"build_time": integer,
|
||||||
"commit": string,
|
"commit": string,
|
||||||
"provider_priority": string,
|
"provider_priority": string,
|
||||||
"dependencies": [string],
|
"dependencies": [
|
||||||
"provides": [string],
|
string
|
||||||
"install_if": [string],
|
],
|
||||||
|
"provides": [
|
||||||
|
string
|
||||||
|
],
|
||||||
|
"install_if": [
|
||||||
|
string
|
||||||
|
],
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -47,7 +53,7 @@ Example:
|
|||||||
"architecture": "x86_64",
|
"architecture": "x86_64",
|
||||||
"package_size": 772109,
|
"package_size": 772109,
|
||||||
"installed_size": 1753088,
|
"installed_size": 1753088,
|
||||||
"description": "A rewrite of NASM to allow for multiple syntax supported (NASM, TASM, GAS, etc.)",
|
"description": "A rewrite of NASM to allow for multiple synta...",
|
||||||
"url": "http://www.tortall.net/projects/yasm/",
|
"url": "http://www.tortall.net/projects/yasm/",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"origin": "yasm",
|
"origin": "yasm",
|
||||||
@ -77,7 +83,7 @@ Example:
|
|||||||
"A": "x86_64",
|
"A": "x86_64",
|
||||||
"S": "772109",
|
"S": "772109",
|
||||||
"I": "1753088",
|
"I": "1753088",
|
||||||
"T": "A rewrite of NASM to allow for multiple syntax supported (NASM, TASM, GAS, etc.)",
|
"T": "A rewrite of NASM to allow for multiple syntax supported...",
|
||||||
"U": "http://www.tortall.net/projects/yasm/",
|
"U": "http://www.tortall.net/projects/yasm/",
|
||||||
"L": "BSD-2-Clause",
|
"L": "BSD-2-Clause",
|
||||||
"o": "yasm",
|
"o": "yasm",
|
||||||
@ -96,13 +102,12 @@ import jc.utils
|
|||||||
|
|
||||||
class info:
|
class info:
|
||||||
"""Provides parser metadata (version, author, etc.)"""
|
"""Provides parser metadata (version, author, etc.)"""
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
description = "APKINDEX parser"
|
description = "Alpine Linux Package Index file parser"
|
||||||
author = "Roey Darwish Dror"
|
author = "Roey Darwish Dror"
|
||||||
author_email = "roey.ghost@gmail.com"
|
author_email = "roey.ghost@gmail.com"
|
||||||
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
compatible = ['linux', 'darwin', 'cygwin', 'win32', 'aix', 'freebsd']
|
||||||
tags = ['standard', 'file', 'string', 'binary']
|
tags = ['standard', 'file', 'string']
|
||||||
|
|
||||||
|
|
||||||
__version__ = info.version
|
__version__ = info.version
|
||||||
@ -125,7 +130,7 @@ _KEY = {
|
|||||||
"k": "provider_priority",
|
"k": "provider_priority",
|
||||||
"D": "dependencies",
|
"D": "dependencies",
|
||||||
"p": "provides",
|
"p": "provides",
|
||||||
"i": "install_if",
|
"i": "install_if"
|
||||||
}
|
}
|
||||||
|
|
||||||
def _value(key: str, value: str) -> Union[str, int, List[str], Dict[str, str]]:
|
def _value(key: str, value: str) -> Union[str, int, List[str], Dict[str, str]]:
|
||||||
@ -155,8 +160,9 @@ def _value(key: str, value: str) -> Union[str, int, List[str], Dict[str, str]]:
|
|||||||
else:
|
else:
|
||||||
return {'name': value}
|
return {'name': value}
|
||||||
|
|
||||||
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def _process(proc_data: List[Dict]) -> List[Dict]:
|
def _process(proc_data: List[Dict]) -> List[Dict]:
|
||||||
"""
|
"""
|
||||||
Final processing to conform to the schema.
|
Final processing to conform to the schema.
|
||||||
@ -184,14 +190,14 @@ def parse(data: str, raw: bool = False, quiet: bool = False) -> List[Dict]:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
||||||
Dictionary. Raw or processed structured data.
|
List of Dictionaries. Raw or processed structured data.
|
||||||
"""
|
"""
|
||||||
jc.utils.compatibility(__name__, info.compatible, quiet)
|
jc.utils.compatibility(__name__, info.compatible, quiet)
|
||||||
jc.utils.input_type_check(data)
|
jc.utils.input_type_check(data)
|
||||||
|
|
||||||
raw_output: List[dict] = []
|
raw_output: List[dict] = []
|
||||||
|
|
||||||
package = {}
|
package: Dict = {}
|
||||||
if jc.utils.has_data(data):
|
if jc.utils.has_data(data):
|
||||||
lines = iter(data.splitlines())
|
lines = iter(data.splitlines())
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
10
man/jc.1
10
man/jc.1
@ -52,6 +52,11 @@ Parsers:
|
|||||||
\fB--airport-s\fP
|
\fB--airport-s\fP
|
||||||
`airport -s` command parser
|
`airport -s` command parser
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B
|
||||||
|
\fB--apkindex\fP
|
||||||
|
Alpine Linux Package Index file parser
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--arp\fP
|
\fB--arp\fP
|
||||||
@ -332,11 +337,6 @@ IPv4 and IPv6 Address string parser
|
|||||||
\fB--ip-route\fP
|
\fB--ip-route\fP
|
||||||
`ip route` command parser
|
`ip route` command parser
|
||||||
|
|
||||||
.TP
|
|
||||||
.B
|
|
||||||
\fB--iso-datetime\fP
|
|
||||||
Deprecated - please use datetime-iso
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B
|
.B
|
||||||
\fB--iw-scan\fP
|
\fB--iw-scan\fP
|
||||||
|
@ -10,30 +10,51 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|||||||
class Apkindex(unittest.TestCase):
|
class Apkindex(unittest.TestCase):
|
||||||
f_in: Dict = {}
|
f_in: Dict = {}
|
||||||
f_json: Dict = {}
|
f_json: Dict = {}
|
||||||
f_raw: Dict = {}
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
fixtures = {
|
fixtures = {
|
||||||
"normal": ("fixtures/generic/apkindex", "fixtures/generic/apkindex.json", "fixtures/generic/apkindex.raw.json"),
|
'normal': (
|
||||||
|
'fixtures/generic/apkindex',
|
||||||
|
'fixtures/generic/apkindex.json'),
|
||||||
|
'raw': (
|
||||||
|
'fixtures/generic/apkindex',
|
||||||
|
'fixtures/generic/apkindex.raw.json')
|
||||||
}
|
}
|
||||||
|
|
||||||
for file, filepaths in fixtures.items():
|
for file, filepaths in fixtures.items():
|
||||||
with open(os.path.join(THIS_DIR, filepaths[0]), "r", encoding="utf-8") as a, open(
|
with open(os.path.join(THIS_DIR, filepaths[0]), 'r', encoding='utf-8') as a, \
|
||||||
os.path.join(THIS_DIR, filepaths[1]), "r", encoding="utf-8"
|
open(os.path.join(THIS_DIR, filepaths[1]), 'r', encoding='utf-8') as b:
|
||||||
) as b, open(
|
|
||||||
os.path.join(THIS_DIR, filepaths[1]), "r", encoding="utf-8"
|
|
||||||
) as c:
|
|
||||||
cls.f_in[file] = a.read()
|
cls.f_in[file] = a.read()
|
||||||
cls.f_json[file] = json.loads(b.read())
|
cls.f_json[file] = json.loads(b.read())
|
||||||
cls.f_raw[file] = json.loads(c.read())
|
|
||||||
|
|
||||||
|
def test_apkindex_nodata(self):
|
||||||
|
"""
|
||||||
|
Test 'apkindex' with no data
|
||||||
|
"""
|
||||||
|
self.assertEqual(parse('', quiet=True), [])
|
||||||
|
|
||||||
|
|
||||||
def test_apkindex(self):
|
def test_apkindex(self):
|
||||||
"""
|
"""
|
||||||
Test 'apkindex'
|
Test 'apkindex' normal output
|
||||||
"""
|
"""
|
||||||
f = "normal"
|
self.assertEqual(
|
||||||
self.assertEqual(parse(self.f_in[f], quiet=True), self.f_json[f])
|
parse(self.f_in['normal'], quiet=True),
|
||||||
|
self.f_json['normal']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_apkindex_raw(self):
|
||||||
|
"""
|
||||||
|
Test 'apkindex' raw output
|
||||||
|
"""
|
||||||
|
self.assertEqual(
|
||||||
|
parse(self.f_in['raw'], quiet=True, raw=True),
|
||||||
|
self.f_json['raw']
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user