Skip to content

Commit ab58c7b

Browse files
committed
fixed problem with parenting config tree nodes
1 parent b694b99 commit ab58c7b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

elmclient/_rm.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
643643

644644
# now iterate over the unparented nodes repeatedly finding their parents until there are none left because all have been parented
645645
while self._confstoparent:
646+
foundparent = False
646647
# we're going to copy unparented node into this new list, then copy the new list into confstoparent
647648
newconfstoparent = []
648649
for (i,nodedetails) in enumerate(self._confstoparent):
@@ -651,12 +652,17 @@ def load_configs(self, cacheable=True, stopatnameoruri=None, verbose=False, incr
651652
parentnode = anytree.search.find( self.configTree, filter_=lambda n: n.name==theparent_u )
652653
if parentnode:
653654
# found!
654-
thisnode.parent = parentnode
655+
node.parent = parentnode
656+
foundparent = True
655657
# print( f"Parented {node}" )
656658
else:
657-
# remember this still needs parenting! Will be found on a later pass
659+
# remember this still needs parenting! Will be found on a later pass UNLESS it's been tried a few times and always fails
660+
# in which case we'll print a message and ignore the config!
658661
newconfstoparent.append( (node,theparent_u) )
659662
self._confstoparent = newconfstoparent
663+
if not foundparent:
664+
print( f"Postponing potentially unparentable configs {self._confstoparent}" )
665+
break
660666

661667
if verbose:
662668
print( "" )

0 commit comments

Comments
 (0)