Skip to content

Commit

Permalink
made sure to kill all assignment expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
rlad78 committed Jun 9, 2022
1 parent 0bdf932 commit ad4d1cd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ciscoaxl/wsdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ def get(self, name: str, default=None) -> Union["AXLElement", None]:
if getattr(child, "name", None) == name:
return child
elif child.type == Choice or child.type == Sequence:
if (finding := child.get(name)) is not None:
finding = child.get(name)
if finding is not None:
return finding
else:
return default
Expand All @@ -216,7 +217,8 @@ def find(self, name: str) -> Union["AXLElement", None]:
if getattr(child, "name", None) == name:
return child
elif child.children:
if (result := child.find(name)) is not None:
result = child.find(name)
if result is not None:
return result
else:
return None
Expand Down Expand Up @@ -311,7 +313,9 @@ def return_tags(self) -> dict:
"""
if self.parent is not None:
return self.parent.return_tags()
elif (tags_element := self.get("returnedTags")) is None:

tags_element = self.get("returnedTags")
if tags_element is None:
return {}

def nil_to_str(d: dict) -> dict:
Expand Down Expand Up @@ -511,9 +515,11 @@ def fix_return_tags(
tag
] = Nil # Nil works best for tree leaves (for some reason)
# check inside "choice" nodes to find the tag
elif choice_nodes := [c for c in tag_tree.children if c.type == Choice]:
elif [c for c in tag_tree.children if c.type == Choice]:
choice_nodes = [c for c in tag_tree.children if c.type == Choice]
for choice in choice_nodes:
if (found_node := choice.get(tag, None)) is not None:
found_node = choice.get(tag, None)
if found_node is not None:
other_choices = [
c.name for c in found_node.children if c.name != tag
]
Expand Down Expand Up @@ -575,7 +581,8 @@ def print_return_tags_layout(
:param show_types: Prints element types next to the element names, defaults to False
"""
root: AXLElement = AXLElement(__get_element_by_name(z_client, element_name))
if (r_tags := root.find("returnedTags")) is None:
r_tags = root.find("returnedTags")
if r_tags is None:
raise WSDLException(
f"'returnedTags' element cannot be found within '{element_name}'"
)
Expand Down

0 comments on commit ad4d1cd

Please sign in to comment.