GithubHelp home page GithubHelp logo

Comments (7)

robshakir avatar robshakir commented on May 21, 2024 1

I would see that _presence would work like _mchanged where hierarchically it would be True if any descendent was set. I'll look into implementing this over the coming few days.

from pyangbind.

robshakir avatar robshakir commented on May 21, 2024

Hi,

This was currently a design choice. Pyangbind would generate something that looks like the following if requested to create this object (I made some minor modifications to think about this):

class new_net(object):
      _pyangbind_elements = {}

This class seems relatively useless - since I'm not sure what one would do to manipulate it. Currently, there is no support for the presence keyword. Could you explain to me how you would expect to use this such that we can design how this would work?

Thanks,
r.

from pyangbind.

sangwookha-vz avatar sangwookha-vz commented on May 21, 2024

In the IETF network model they use presence to indicate the network types.

In section 3.4.8. it says:

A network's network types are represented using a container which
contains a data node for each of its network types.  A network can
encompass several types of network simultaneously, hence a container
is used instead of a case construct, with each network type in turn
represented by a dedicated presence container itself.  The reason for
not simply using an empty leaf, or even simpler, do away even with
the network container and just use a leaf-list of network-type
instead, is to be able to represent "class hierarchies" of network
types, with one network type refining the other.  Network-type
specific containers are to be defined in the network-specific
modules, augmenting the network-types container.

In the model it has the following:

container network-types {
  description
    "Serves as an augmentation target.
     The network type is indicated through corresponding
     presence containers augmented into this container.";
}

I couldn't load JSON data which has a network type specified with an empty container.

from pyangbind.

robshakir avatar robshakir commented on May 21, 2024

Right - but how would you want to interact with this in Python?

One option would be to have something in the meta-class that lets one set the presence, for example:

model.container._presence = True

This would then set _changed to True as well, which would mean that it would be serialised when creating JSON instances.

When de-serialising we would need to understand that "model": { "container": {} } meant that _presence for container needed to be set, but that is something that we could do relatively easily in the lib.serialise modules.

Would this make sense for you?

r.

from pyangbind.

sangwookha-vz avatar sangwookha-vz commented on May 21, 2024

Yes, that makes sense to me.

One question: if there is a hierarchy of presence containers, how can it be handled?

container network-types {
    container type-a {
        presence "type-a";
        container type-a-1 {
            presence "type-a-1";
        }
    }
}

When serializing should _presence for both type-a and type-a-1 be set True to include type-a-1 container?

from pyangbind.

robshakir avatar robshakir commented on May 21, 2024

Hi @sangwookha-vz,

If you pull the presence branch - the functionality that we discussed above is implemented therein.

You can see some examples of how to use it in https://github.com/robshakir/pyangbind/blob/presence/tests/presence/run.py

Any comments very welcome.

Cheers,
r.

from pyangbind.

robshakir avatar robshakir commented on May 21, 2024

I merged this branch and released it to PyPI. If there are issues, please do let me know.

Cheers,
r.

from pyangbind.

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.