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

Pyangbind generates redundant python classes for each included submodule #114

Open
matej-staron opened this issue Feb 23, 2017 · 3 comments
Assignees
Labels

Comments

@matej-staron
Copy link

Hi,

I came across this weird situation. When a single module including other submodules is built, pyangbind seems to generate set of classes with identical content (compared to the classes built from the main module) for each of included submodules.
This results in considerable overhead in generated .py files. The redundant classes seem to behave in the same manner as the 'original' class, thus having no actual use.

Let's say we have these two files (main-module.yang, submodule-one.yang):

module main-module {
    prefix "main";
    namespace "http://example.com/foo";
    include submodule-one;

    leaf main-mod-item {
        type int32;
    }
}
submodule submodule-one {
    belongs-to main-module  { prefix "main"; }

    container submod-container {
        leaf submod-item {
            type string;
        }
    }
}

After using pyangbind to build main-module.yang, generated python class contains 'doubled' code, allowing identical operations on these classes:

>>> from pybind_output import main_module
>>> from pybind_output import submodule_one
>>> mm = main_module()
>>> sm = submodule_one()
>>> mm.get()
{'main-mod-item': 0L, 'submod-container': {'submod-item': u''}}
>>> sm.get()
{'main-mod-item': 0L, 'submod-container': {'submod-item': u''}}

I am not completely sure whether this is an actual feature or a bug.
Could you please look into this?

@robshakir
Copy link
Owner

Thanks for the report here. This does look to be a bug.

I have a fix for this in a development branch where I am working through some other issues, I'll merge it ASAP.

If fixing this is more urgent, please let me know and I can cherry-pick this back into master quicker.

r.

@robshakir robshakir self-assigned this Mar 13, 2017
@robshakir robshakir added the bug label Mar 13, 2017
@matej-staron
Copy link
Author

Thanks for feedback.
Fixing is not urgent.

@password636
Copy link

@robshakir Is the fix not merged yet? Or could you let me know which branch has the fix?

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

No branches or pull requests

3 participants