Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make mkylib reusable and install it #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jktjkt
Copy link
Contributor

@jktjkt jktjkt commented Jul 11, 2019

I'm looking at using yangson with @Telecominfraproject's oopt-gnpy because yangson looks like something that can validate JSON files against a YANG schema. Thanks for the tool!

One thing which made the workflow more complex for me was the fact that mkylib was not installed via pip install yangson. This patch therefore makes it available as yangson-mkylib. While at it, I also adjusted the wrapping a bit so that the code is usable from Python without direct sys.exit calls, print(), etc.:

>>> import json
>>> from yangson.mkylib import process_directory as PPP
>>> print(json.dumps(PPP("yang/"), indent=4))
{
    "ietf-yang-library:modules-state": {
        "module-set-id": "",
        "module": [
            {
                "name": "ietf-network-topology",
                "revision": "2018-02-26",
                "namespace": "urn:ietf:params:xml:ns:yang:ietf-network-topology",
                "conformance-type": "implement"
            },
            {
                "name": "ietf-network",
                "revision": "2018-02-26",
                "namespace": "urn:ietf:params:xml:ns:yang:ietf-network",
                "conformance-type": "implement"
            },
            {
                "name": "ietf-yang-types",
                "revision": "2013-07-15",
                "namespace": "urn:ietf:params:xml:ns:yang:ietf-yang-types",
                "conformance-type": "import"
            },
            {
                "name": "ietf-geo-location",
                "revision": "2019-02-17",
                "namespace": "urn:ietf:params:xml:ns:yang:ietf-geo-location",
                "feature": [
                    "alternate-systems"
                ],
                "conformance-type": "import"
            },
            {
                "name": "tip-photonic-topology",
                "revision": "2019-07-02",
                "namespace": "https://oopt.telecominfraproject.com/yang/topology",
                "conformance-type": "implement"
            },
            {
                "name": "ietf-inet-types",
                "revision": "2013-07-15",
                "namespace": "urn:ietf:params:xml:ns:yang:ietf-inet-types",
                "conformance-type": "import"
            },
            {
                "name": "tip-photonic-equipment",
                "revision": "2019-06-20",
                "namespace": "https://oopt.telecominfraproject.com/yang/equipment",
                "conformance-type": "implement"
            }
        ]
    }
}
>>>

Those who obtained yangson via PIP do not have access to tools/, so
let's make this binary available as a command.
This means no direct print() or sys.exit() or sys.argv access, so let's
wrap this into something which preserves the required behavior of
setuptools' `console_scripts`, yet makes it possoble for Python calles
to simply import this submodule and use it directly from code.
@llhotka
Copy link
Member

llhotka commented Aug 9, 2019

Ahoj @jktjkt, I am sorry for responding so late. Regarding your PR, I am somewhat concerned that by making it an “official” script we could mislead users into thinking that it solves the problem of creating a YANG library file completely. It is usually not the case – modules from other directories often have to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants