Skip to content

Commit

Permalink
change from repr to string in changeset
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Schaller <ivan@schaller.sh>
  • Loading branch information
olofvndrhr committed Mar 1, 2024
1 parent 4fe8be6 commit 696d2a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/octodns_netbox_dns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def _make_absolute(self, value: str) -> str:
return absolute_value

def _escape_semicolon(self, value: str) -> str:
fixed = value.replace(";", "\\;")
fixed = value.replace(";", r"\;")
self.log.debug(rf"in='{value}', escaped='{fixed}'")
return fixed

def _unescape_semicolon(self, value: str) -> str:
fixed = value.replace("\\\\", "\\").replace("\\;", ";")
fixed = value.replace(r"\;", ";")
self.log.debug(rf"in='{value}', unescaped='{fixed}'")
return fixed

Expand Down Expand Up @@ -317,9 +317,10 @@ def _format_changeset(self, change: Any) -> set[str]:
"""
match change:
case octodns.record.ValueMixin():
changeset = {repr(change.value)[1:-1]}
changeset = {str(change.value)}
case octodns.record.ValuesMixin():
changeset = {repr(v)[1:-1] for v in change.values}
changeset = {str(v) for v in change.values}

case _:
raise ValueError

Expand Down
4 changes: 2 additions & 2 deletions tests/test_escaple_semicolon.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def test_unescape2():
rcd_value = r"v=TLSRPTv1\\; rua=mailto:tlsrpt@example.com"
value = nbdns._unescape_semicolon(rcd_value)

assert value == r"v=TLSRPTv1; rua=mailto:tlsrpt@example.com"
assert value == r"v=TLSRPTv1\; rua=mailto:tlsrpt@example.com"


def test_unescape3():
nbdns = NetBoxDNSProvider(**DEFAULT_CONFIG)
rcd_value = r"t=y\\;o=~\;"
value = nbdns._unescape_semicolon(rcd_value)

assert value == r"t=y;o=~;"
assert value == r"t=y\;o=~;"


def test_unescape4():
Expand Down

0 comments on commit 696d2a2

Please sign in to comment.