Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
fix policy_list converter
Browse files Browse the repository at this point in the history
  • Loading branch information
sbasan committed Mar 14, 2024
1 parent 2e5dd90 commit 801f50d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def sla_class(in_: SLAClassList) -> SLAClassParcel:
def tloc(in_: TLOCList) -> TlocParcel:
out = TlocParcel(**_get_parcel_name_desc(in_))
for entry in in_.entries:
out.add_entry(tloc=entry.tloc, color=entry.color, encapsulation=entry.encap, preference=entry.preference)
_preference = str(entry.preference) if entry.preference is not None else None
out.add_entry(tloc=entry.tloc, color=entry.color, encapsulation=entry.encap, preference=_preference)
return out


Expand Down Expand Up @@ -281,8 +282,15 @@ class ConvertAllResult(NamedTuple):
}


def _find_converter(in_: Input) -> Optional[Callable[[Any], Output]]:
for key in CONVERTERS.keys():
if isinstance(in_, key):
return CONVERTERS[key]
return None


def convert(in_: Input) -> Optional[Output]:
if converter := CONVERTERS.get(type(in_)):
if converter := _find_converter(in_):
return converter(in_)
return None

Expand Down

0 comments on commit 801f50d

Please sign in to comment.