Skip to content

Commit

Permalink
Fixed bug introduced in commit: fcfe591 (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoqin Zhu authored and Abhi Keshav committed Nov 9, 2016
1 parent d43df73 commit 3c500d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
19 changes: 18 additions & 1 deletion profiles/test/ydktest-cpp.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,24 @@
"yang/ietf/ietf-inet-types@2013-07-15.yang",
"yang/ietf/ietf-yang-types@2013-07-15.yang",
"yang/ydktest/oc-pattern@2015-11-17.yang"
]
],

"git":
[
{
"url": "https://github.com/YangModels/yang.git",
"commits":
[
{
"commitid": "a5e3d7f27e0e846cac6b6357ff460b8facc810a8",
"file":
[
"standard/ietf/RFC/iana-if-type.yang"
]
}
]
}
]
}
}

16 changes: 8 additions & 8 deletions ydkgen/printer/language_bindings_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ def _get_identity_subclasses_map(self):
identity_tuples = self._get_identity_tuples()
for (child_identity, base_identities) in identity_tuples:
for base_identity in base_identities:
if base_identity in identity_subclasses:
existing_child_identities = identity_subclasses[base_identity]
if id(base_identity) in identity_subclasses:
existing_child_identities = identity_subclasses[id(base_identity)]
existing_child_identities.append(child_identity)
identity_subclasses[base_identity] = existing_child_identities
identity_subclasses[id(base_identity)] = existing_child_identities
else:
identity_subclasses[base_identity] = [child_identity]
identity_subclasses[id(base_identity)] = [child_identity]
return identity_subclasses

def _get_identity_tuples(self):
Expand All @@ -134,7 +134,7 @@ def _get_identity_subclasses_for_package(self, element):
return identity_subclasses

def _filter_bundle_pkgs(self):
bundle_pkgs = set()
bundle_pkgs = {}
for pkg in self.packages:
if pkg.bundle_name == self.bundle_name:
# we have multiple models being augmented.
Expand All @@ -145,7 +145,7 @@ def _filter_bundle_pkgs(self):
# augmenting models in existing bundle.
aug_pkg.aug_bundle_name = aug_pkg.bundle_name
aug_pkg.bundle_name = self.bundle_name
bundle_pkgs.add(aug_pkg)
bundle_pkgs.add(pkg)
bundle_pkgs[id(aug_pkg)] = aug_pkg
bundle_pkgs[id(pkg)] = pkg

return list(bundle_pkgs)
return list(bundle_pkgs.values())
2 changes: 1 addition & 1 deletion ydkgen/printer/python/module_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _print_imports(self, package):
imports_to_print = set()

for imported_type in package.imported_types():
if all((imported_type in self.identity_subclasses,
if all((id(imported_type) in self.identity_subclasses,
self._is_derived_identity(package, imported_type))):
imported_stmt = 'from %s import %s' % (
imported_type.get_py_mod_name(),
Expand Down

0 comments on commit 3c500d2

Please sign in to comment.