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

Handle choice/case #16

Closed
ghost opened this issue Apr 20, 2016 · 0 comments
Closed

Handle choice/case #16

ghost opened this issue Apr 20, 2016 · 0 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 20, 2016

Make it obvious in documentation. Indicate which elements are mutually exclusive

Also, if the --choice-subsstatements-as-subclasses option is chosen when running ydk-gen, all the cases of a choice statement should be generated as subclasses of a parent class.

Currently, the cases of a choice statement are modeled as Properties. So, below yang produces below python code.

choice rule-type {
          description
            "This choice matches if all leafs present in the rule
             match the request.  If no leafs are present, the
             choice matches all requests.";
          case protocol-operation {
            leaf rpc-name {
              type union {
                type matchall-string-type;
                type string;
              }
              description
                "This leaf matches if it has the value '*' or if
                 its value equals the requested protocol operation
                 name.";
            }
          }
          case notification {
            leaf notification-name {
              type union {
                type matchall-string-type;
                type string;
              }
              description
                "This leaf matches if it has the value '*' or if its
                 value equals the requested notification name.";
            }
          }
          case data-node {
            leaf path {
              type node-instance-identifier;
              mandatory true;
              description
                "Data Node Instance Identifier associated with the
                 data node controlled by this rule.

                 Configuration data or state data instance
                 identifiers start with a top-level data node.  A
                 complete instance identifier is required for this
                 type of path value.

                 The special value '/' refers to all possible
                 datastore contents.";
            }
          }
        }
self.notification_name = None
self.path = None
self.rpc_name = None

If this option is chosen, below python code will be produced instead :

self.rule_type = RuleType()

class RuleType(object):
     pass

class NotificationName(RuleType):
    pass

class Path(RuleType):
    pass

class(RuleType):
    pass

RuleType is not from the choice, rather it should be from the container or list that is the parent of the choice. No class should be generated for the choice. (In the case where choice is a top level element under the module, the case classes would inherit themodule class)

Note in the case there are 2 choices under the given statement , this generation algorithm should not be used

@ghost ghost modified the milestone: 0.4.1 Apr 20, 2016
@ghost ghost self-assigned this Apr 22, 2016
@ghost ghost added the ready label Apr 29, 2016
@ghost ghost modified the milestone: 0.4.1 Jun 7, 2016
@ghost ghost removed their assignment Jun 7, 2016
@ghost ghost added the bundle label Jun 9, 2016
@ghost ghost closed this as completed Jan 30, 2017
@ghost ghost removed the ready label Jan 30, 2017
This issue was closed.
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

0 participants