Skip to content

Commit

Permalink
Do not assume there is a uses statement in all augmentations
Browse files Browse the repository at this point in the history
Even though it is common to all open-config models.
Check for the object attribute before using.
  • Loading branch information
carlgsmith committed Oct 14, 2024
1 parent b27fdce commit c9c9fca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pyang-apteryx-xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,16 @@ def sample_element(self, node, parent, module, path):
if niffeature is not None:
res.attrib["if-feature"] = niffeature.arg

# Check for a "when" clause on an augmentation
# Check for a "when" clause in a "uses" on an augmented container
if node.keyword == 'container':
if hasattr(node, 'i_augment'):
naug = node.i_augment
for ch in naug.i_children:
for uses in ch.i_uses:
nwhen = uses.search_one("when")
if nwhen is not None:
res.attrib["when"] = nwhen.arg
if hasattr(ch, 'i_uses'):
for uses in ch.i_uses:
nwhen = uses.search_one("when")
if nwhen is not None:
res.attrib["when"] = nwhen.arg

nwhen = node.search_one("when")
if nwhen is not None:
Expand Down

0 comments on commit c9c9fca

Please sign in to comment.