Git Product home page Git Product logo

Comments (6)

kellyjonbrazil avatar kellyjonbrazil commented on August 12, 2024 1

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.

kellyjonbrazil avatar kellyjonbrazil commented on August 12, 2024

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.

brainwo avatar brainwo commented on August 12, 2024

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.

windupbird144 avatar windupbird144 commented on August 12, 2024

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.

brainwo avatar brainwo commented on August 12, 2024

@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.

windupbird144 avatar windupbird144 commented on August 12, 2024

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.

Table of the keys used by the outputs of different commands
Link to the spreadsheet

from jc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.