Shorten syntax to access Name object

dns.name all over the place does not make it easier to read the code at
all, and I'm going to add lot more code here.
This commit is contained in:
Petr Špaček 2025-05-21 15:19:25 +02:00
parent bd8be10329
commit 3fb6b990af

View file

@ -9,12 +9,12 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
import dns.name
from dns.name import Name
def prepend_label(label: str, name: dns.name.Name) -> dns.name.Name:
return dns.name.Name((label,) + name.labels)
def prepend_label(label: str, name: Name) -> Name:
return Name((label,) + name.labels)
def len_wire_uncompressed(name: dns.name.Name) -> int:
def len_wire_uncompressed(name: Name) -> int:
return len(name) + sum(map(len, name.labels))