From 81fbcc042aa434336a17a84485ef2c130e37aff7 Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Tue, 10 Jan 2023 21:19:47 -0500 Subject: [PATCH 1/2] chore: added support to allocating sid values to sx:structure --- pyang/plugins/sid.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pyang/plugins/sid.py b/pyang/plugins/sid.py index dc9134ff..86a55629 100644 --- a/pyang/plugins/sid.py +++ b/pyang/plugins/sid.py @@ -566,6 +566,15 @@ def out_of_ranges(self, sid): def has_yang_data_extension(statement): try: return statement.i_extension.arg == 'yang-data' + + except AttributeError: + return False + + @staticmethod + def has_structure_extension(statement): + try: + return statement.i_extension.arg == 'structure' + except AttributeError: return False @@ -616,6 +625,8 @@ def collect_module_items(self, module): self.collect_in_substmts(substmt.substmts) elif self.has_yang_data_extension(substmt): self.collect_in_substmts(substmt.substmts) + elif self.has_structure_extension(substmt): + self.collect_in_substmts(substmt.substmts) def collect_inner_data_nodes(self, statements, prefix=""): for statement in statements: From adba6cdcaab136636b94474477ae6cde4ac9e673 Mon Sep 17 00:00:00 2001 From: Michael Richardson Date: Wed, 22 Oct 2025 17:47:40 -0400 Subject: [PATCH 2/2] when looking for items to match, only compare last component of name --- pyang/plugins/sid.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyang/plugins/sid.py b/pyang/plugins/sid.py index 86a55629..f39ad260 100644 --- a/pyang/plugins/sid.py +++ b/pyang/plugins/sid.py @@ -690,8 +690,11 @@ def get_path(self, statement, prefix=""): return prefix + path def merge_item(self, namespace, identifier): + # only compare the last component. + lastid = re.split(r'[/:]', identifier)[-1] for item in self.content['items']: - if (namespace == item['namespace'] and identifier == item['identifier']): + itemlast = re.split(r'[/:]',item['identifier'])[-1] + if (namespace == item['namespace'] and lastid == itemlast): item['lifecycle'] = 'o' # Item already assigned return self.content['items'].append(collections.OrderedDict(