Browse Source

wip Value.template functions

pull/1259/head
Ross McFarland 6 months ago
parent
commit
b3ba45f6f7
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
12 changed files with 86 additions and 0 deletions
  1. +7
    -0
      octodns/record/caa.py
  2. +7
    -0
      octodns/record/ds.py
  3. +5
    -0
      octodns/record/ip.py
  4. +3
    -0
      octodns/record/loc.py
  5. +7
    -0
      octodns/record/mx.py
  6. +13
    -0
      octodns/record/naptr.py
  7. +7
    -0
      octodns/record/srv.py
  8. +7
    -0
      octodns/record/sshfp.py
  9. +8
    -0
      octodns/record/svcb.py
  10. +5
    -0
      octodns/record/target.py
  11. +9
    -0
      octodns/record/tlsa.py
  12. +8
    -0
      octodns/record/urlfwd.py

+ 7
- 0
octodns/record/caa.py View File

@ -87,6 +87,13 @@ class CaaValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.flags} {self.tag} {self.value}'
def template(self, params):
if '{' not in self.value:
return self
new = self.__class__(self)
new.value = new.value.format(**params)
return new
def _equality_tuple(self):
return (self.flags, self.tag, self.value)


+ 7
- 0
octodns/record/ds.py View File

@ -164,6 +164,13 @@ class DsValue(EqualityTupleMixin, dict):
f'{self.key_tag} {self.algorithm} {self.digest_type} {self.digest}'
)
def template(self, params):
if '{' not in self.digest:
return self
new = self.__class__(self)
new.digest = new.digest.format(**params)
return new
def _equality_tuple(self):
return (self.key_tag, self.algorithm, self.digest_type, self.digest)


+ 5
- 0
octodns/record/ip.py View File

@ -45,5 +45,10 @@ class _IpValue(str):
def rdata_text(self):
return self
def template(self, params):
if '{' not in self:
return self
return self.__class__(self.format(**params))
_IpAddress = _IpValue

+ 3
- 0
octodns/record/loc.py View File

@ -305,6 +305,9 @@ class LocValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.lat_degrees} {self.lat_minutes} {self.lat_seconds} {self.lat_direction} {self.long_degrees} {self.long_minutes} {self.long_seconds} {self.long_direction} {self.altitude}m {self.size}m {self.precision_horz}m {self.precision_vert}m'
def template(self, params):
return self
def __hash__(self):
return hash(
(


+ 7
- 0
octodns/record/mx.py View File

@ -101,6 +101,13 @@ class MxValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.preference} {self.exchange}'
def template(self, params):
if '{' not in self.exchange:
return self
new = self.__class__(self)
new.exchange = new.exchange.format(**params)
return new
def __hash__(self):
return hash((self.preference, self.exchange))


+ 13
- 0
octodns/record/naptr.py View File

@ -138,6 +138,19 @@ class NaptrValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.order} {self.preference} {self.flags} {self.service} {self.regexp} {self.replacement}'
def template(self, params):
if (
'{' not in self.service
and '{' not in self.regexp
and '{' not in self.replacement
):
return self
new = self.__class__(self)
new.service = new.service.format(**params)
new.regexp = new.regexp.format(**params)
new.replacement = new.replacement.format(**params)
return new
def __hash__(self):
return hash(self.__repr__())


+ 7
- 0
octodns/record/srv.py View File

@ -135,6 +135,13 @@ class SrvValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f"{self.priority} {self.weight} {self.port} {self.target}"
def template(self, params):
if '{' not in self.target:
return self
new = self.__class__(self)
new.target = new.target.format(**params)
return new
def __hash__(self):
return hash(self.__repr__())


+ 7
- 0
octodns/record/sshfp.py View File

@ -105,6 +105,13 @@ class SshfpValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.algorithm} {self.fingerprint_type} {self.fingerprint}'
def template(self, params):
if '{' in self.fingerprint:
return self
new = self.__class__(self)
new.fingerprint = new.fingerprint.format(**params)
return new
def __hash__(self):
return hash(self.__repr__())


+ 8
- 0
octodns/record/svcb.py View File

@ -287,6 +287,14 @@ class SvcbValue(EqualityTupleMixin, dict):
params += f'={svcparamvalue}'
return f'{self.svcpriority} {self.targetname}{params}'
def template(self, params):
if '{' not in self.targetname:
return self
new = self.__class__(self)
new.targetname = new.targetname.format(**params)
# TODO: what, if any of the svcparams should be templated
return new
def __hash__(self):
return hash(self.__repr__())


+ 5
- 0
octodns/record/target.py View File

@ -80,3 +80,8 @@ class _TargetsValue(str):
@property
def rdata_text(self):
return self
def template(self, params):
if '{' not in self:
return self
return self.__class__(self.format(**params))

+ 9
- 0
octodns/record/tlsa.py View File

@ -136,6 +136,15 @@ class TlsaValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'{self.certificate_usage} {self.selector} {self.matching_type} {self.certificate_association_data}'
def template(self, params):
if '{' in self.certificate_association_data:
return self
new = self.__class__(self)
new.certificate_association_data = (
new.certificate_association_data.format(**params)
)
return new
def _equality_tuple(self):
return (
self.certificate_usage,


+ 8
- 0
octodns/record/urlfwd.py View File

@ -132,6 +132,14 @@ class UrlfwdValue(EqualityTupleMixin, dict):
def rdata_text(self):
return f'"{self.path}" "{self.target}" {self.code} {self.masking} {self.query}'
def template(self, params):
if '{' not in self.path and '{' not in self.target:
return self
new = self.__class__(self)
new.path = new.path.format(**params)
new.target = new.target.format(**params)
return new
def _equality_tuple(self):
return (self.path, self.target, self.code, self.masking, self.query)


Loading…
Cancel
Save