8000 set tuple for default value on union typedef by gunhanoral · Pull Request #318 · robshakir/pyangbind · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

set tuple for default value on union typedef #318

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

Merged
merged 2 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyangbind/plugin/pybind.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ def build_typedefs(ctx, defnd):
default = (i[1]["default"], q)
class_map[type_name] = {"native_type": native_type, "base_type": False, "parent_type": parent_type}
if default:
if not isinstance(default, tuple):
q = True if "quote_arg" in i[1] else False
default = (default, q)
class_map[type_name]["default"] = default[0]
class_map[type_name]["quote_default"] = default[1]

Expand Down
13 changes: 13 additions & 0 deletions tests/union/union.yang
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ module union {
}
}

typedef union-with-default {
type union {
type string;
type uint64;
}
default "0";
}

container container {

leaf u2 {
Expand Down Expand Up @@ -189,5 +197,10 @@ module union {
}
}
}

// issue reported in pull req #318
leaf u13 {
type union-with-default;
}
}
}
0