chore(bird): Improve code readability
This commit is contained in:
parent
54d227232b
commit
9aaa619173
1 changed files with 3 additions and 9 deletions
|
@ -89,7 +89,7 @@ class IPv4orIPv6(BaseModel):
|
|||
ipv6: list[int] = Field(ge=0, min_items=2, max_items=2)
|
||||
|
||||
|
||||
class IPFlag(str):
|
||||
class IPFlag:
|
||||
@classmethod
|
||||
def __get_validators__(cls):
|
||||
yield cls.validate
|
||||
|
@ -236,14 +236,8 @@ def str_of_condition(condition: Condition, ctx: bool) -> str:
|
|||
return f"{min_v6} <= net.len && net.len <= {max_v6}"
|
||||
|
||||
case NetMatch(matches=matches):
|
||||
if ctx.ipv4:
|
||||
networks = [
|
||||
m for m in matches if isinstance(m[0], IPv4Network)
|
||||
]
|
||||
else:
|
||||
networks = [
|
||||
m for m in matches if isinstance(m[0], IPv6Network)
|
||||
]
|
||||
networkType = IPv4Network if ctx.ipv4 else IPv6Network
|
||||
networks = [m for m in matches if isinstance(m[0], networkType)]
|
||||
|
||||
return f"net ~ [ {', '.join([f'{network}{flag}' for (network, flag) in networks])} ]"
|
||||
|
||||
|
|
Loading…
Reference in a new issue