Comments (6)
Not sure if adding one schema for each different commands would be good (like if I understood correctly is how jc ended up with --git-log and --git-log-s).
git-log
is a standard parser, which means all of the data resides in memory during parsing. git-log-s
is a streaming parser which means it only holds one line of data at a time in memory so it uses much less memory for large git logs. Their schemas should be nearly identical.
We can make a parser that allows for new keys. There are already a couple package management parsers that may already work or get close if the output format is similar.
from jc.
Hi there - it looks like two parsers that can work for this output would be the --kv
parser or the --rpm-qi
parser, which is also used for various other package index parsers, like --pkg-index-deb
.
I can create a parser specifically for this format if these parsers don't work for specific output. I can probably modify the --rpm-qi
parser and create a new alias for pacman -Si
output.
$ echo 'Repository : extra
Name : jc
Version : 1.25.2-1
Description : Converts the output of popular command-line tools and file-types
to JSON
Architecture : any
URL : https://github.com/kellyjonbrazil/jc
Licenses : MIT
Groups : None
Provides : None
Depends On : python python-pygments python-ruamel-yaml python-xmltodict
Optional Deps : None
Conflicts With : None
Replaces : None
Download Size : 866.14 KiB
Installed Size : 8474.19 KiB
Packager : Antonio Rojas <[email protected]>
Build Date : Mon 06 May 2024 02:37:45 PM +08
Validated By : SHA-256 Sum Signature' | jc --kv -p
{
"Repository": "extra",
"Name": "jc",
"Version": "1.25.2-1",
"Description": "Converts the output of popular command-line tools and file-types\nto JSON",
"Architecture": "any",
"URL": "https://github.com/kellyjonbrazil/jc",
"Licenses": "MIT",
"Groups": "None",
"Provides": "None",
"Depends On": "python python-pygments python-ruamel-yaml python-xmltodict",
"Optional Deps": "None",
"Conflicts With": "None",
"Replaces": "None",
"Download Size": "866.14 KiB",
"Installed Size": "8474.19 KiB",
"Packager": "Antonio Rojas <[email protected]>",
"Build Date": "Mon 06 May 2024 02:37:45 PM +08",
"Validated By": "SHA-256 Sum Signature"
}
$ echo 'Repository : extra
Name : jc
Version : 1.25.2-1
Description : Converts the output of popular command-line tools and file-types
to JSON
Architecture : any
URL : https://github.com/kellyjonbrazil/jc
Licenses : MIT
Groups : None
Provides : None
Depends On : python python-pygments python-ruamel-yaml python-xmltodict
Optional Deps : None
Conflicts With : None
Replaces : None
Download Size : 866.14 KiB
Installed Size : 8474.19 KiB
Packager : Antonio Rojas <[email protected]>
Build Date : Mon 06 May 2024 02:37:45 PM +08
Validated By : SHA-256 Sum Signature' | jc --rpm-qi -p
[
{
"repository": "extra"
},
{
"name": "jc",
"version": "1.25.2-1",
"description": "Converts the output of popular command-line tools and file-types",
"architecture": "any",
"url": "https://github.com/kellyjonbrazil/jc",
"licenses": "MIT",
"groups": "None",
"provides": "None",
"depends_on": "python python-pygments python-ruamel-yaml python-xmltodict",
"optional_deps": "None",
"conflicts_with": "None",
"replaces": [
"None"
],
"download_size": "866.14 KiB",
"installed_size": 8474,
"packager": "Antonio Rojas <[email protected]>",
"build_date": "Mon 06 May 2024 02:37:45 PM +08",
"validated_by": "SHA-256 Sum Signature",
"build_epoch": null,
"build_epoch_utc": null
}
]
from jc.
A new parser would be nice. I see there are inconsistency on the use of null
and "None"
, as well as "depends_on"
values not being an array. And that "\n"
inside the string too.
Also I want to mention there is this flag -Qi
that does output the same as -Si
, but it's for querying installed package. -Q
is short hand for --query
, and -S
is for --sync
while -i
is for --info
. (If this information matters. Perhaps for naming the command or for jc magic?)
Another thing is I got a question:
If I got some new format I don't know what parser to use, how can I find what to use? Is there a list of how other formats looks like? I'm not familiar with how other format works, like other package managers for example (that surely isn't available in my distro of choice).
from jc.
I would like to submit a parser for pacman -Si
.
I would propose the following schema:
[
{
"repository": string,
"name": string,
"version": string,
"description": string,
"architecture": string,
"url": string,
"licenses": [
string
],
"groups": [
string
],
"provides": [
string
],
"depends_on": [
string
],
"optional_deps": [
{
"name": string,
"description": string
}
],
"conflicts_with": [
string
],
"replaces": [
string
],
"download_size": string,
"installed_size": string,
"packager": string,
"build_date": string,
"validated_by": [
string
]
}
]
It should be noted optional depenendcies is a list of key value pairs in the output of pacman -Si
.
Here's an example of a package with optional dependencies.
What do you think?
from jc.
@windupbird144, you may also want to cover pacman -Sii
and pacman -Qii
too.
Not to mention pacman/libalpm wrappers like yay
and paru
might add additional information.
I think the parser should be made flexible enough to covers additional keys as well. Not sure if adding one schema for each different commands would be good (like if I understood correctly is how jc ended up with --git-log
and --git-log-s
).
from jc.
The outputs of package managers are close enough, but maybe there are enough quirks to warrant making a separate parser per package manager.
- The rpm parser assumes that 'Name' is the first key, which is true for pacman -Qi but not true for pacman -Si. This information is used to separate the entries for commands that show information on multiple packages, like rpm -qai.
- It looks like in rpm the field 'Description' spans over multiple lines
- In pacman the field Optional Deps might need special parsing because it's key-value pairs
- In rpm int and time conversions are used
I tried a couple of commands and made an overview of the keys that were produced, for what it's worth.
from jc.
Related Issues (20)
- New Parser - NUT-upsc command HOT 1
- [parsers /pci_ids.py] Only last [subvendor][subdevice] got loaded into result when multiple subdevices having the same subvendor id HOT 3
- Bug: Traceroute ignored IPs when multiple IPs on hop HOT 3
- "ss" Parser not working correctly: Entries Missing HOT 5
- .netrc support HOT 1
- Problem with --pip-show parser for a module with nothing on the License: line but which has following lines HOT 4
- lspci strips trailing digit on bus ID HOT 3
- `--zpool-status` fails to handle the `spares` section of `zpool status` HOT 3
- 1.25.3: pytest fails in nits which are comparing time HOT 8
- Python 3.12 test regression: `tests.test_ip_address.MyTests.test_ip_address_ipv6_6to4` HOT 11
- Parsing mounts with spaces in filenames fails - AttributeError: 'NoneType' object has no attribute 'groupdict' HOT 2
- New Streaming-parser proposal: traceroute-s HOT 1
- ethtool parsing doesn't work HOT 1
- Netstat issue with spaces in program name HOT 2
- jc ls --time-style=+"%F %T" -al -> wrong output HOT 1
- New Parser: cloudformation template.yaml HOT 4
- ifconfig parser of IPv4 do not support utun interfaces on macOS HOT 1
- Python 3.13 test failure: `test_ip_address_ipv6_ipv4_mapped` HOT 4
- uptime parser with 0 user(s) on ubuntu 24.04 docker not matching HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jc.