diff --git a/localzone-0.9.7.tar.gz b/localzone-0.9.7.tar.gz new file mode 100644 index 0000000..ba93e32 --- /dev/null +++ b/localzone-0.9.7.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a03afb61683e63737cd7ccdf286e22b0c4ced87c1eb67896d9916e92d48bad4d +size 27905 diff --git a/localzone-0.9.8.tar.gz b/localzone-0.9.8.tar.gz deleted file mode 100644 index 12df2fc..0000000 --- a/localzone-0.9.8.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6ef39de76dc59a0c6c13ae85fe85bf3a58323cab568b47cb51b435d42a1d39e6 -size 28102 diff --git a/localzone-dnspython-2.1.patch b/localzone-dnspython-2.1.patch new file mode 100644 index 0000000..6c8989d --- /dev/null +++ b/localzone-dnspython-2.1.patch @@ -0,0 +1,129 @@ +From c508257d6478e75a74a2fe0c9e770ef89c50eb41 Mon Sep 17 00:00:00 2001 +From: Ben Greiner +Date: Mon, 18 Jan 2021 19:05:03 +0100 +Subject: [PATCH] add support for dnspython 2.1 + +--- + localzone/context.py | 69 +++++++++++++++++++++++++++++-------------- + tests/test_context.py | 5 +++- + tests/test_models.py | 3 +- + 3 files changed, 53 insertions(+), 24 deletions(-) + +diff --git a/localzone/context.py b/localzone/context.py +index 8da5048..7354c4a 100644 +--- a/localzone/context.py ++++ b/localzone/context.py +@@ -13,6 +13,14 @@ + import dns.rdataclass + import dns.tokenizer + import dns.zone ++try: ++ # The api for the zonefile reader was exposed in dnspython 2.1 ++ from dns.zonefile import Reader ++ DNSPYTHON21 = True ++except ImportError: ++ from dns.zone import _MasterReader ++ DNSPYTHON21 = False ++ + from .models import Zone + + +@@ -57,25 +65,42 @@ def load(filename, origin=None): + """ + with open(filename) as text: + tok = dns.tokenizer.Tokenizer(text, filename) +- reader = dns.zone._MasterReader( +- tok, +- origin=origin, +- rdclass=dns.rdataclass.IN, +- relativize=True, +- zone_factory=Zone, +- allow_include=True, +- check_origin=True, +- ) +- reader.read() +- +- # TODO: remember that any method using the zone.filename property should +- # have it passed as a parameter +- reader.zone._filename = filename +- +- # starting with dnspython v1.16.0, use default_ttl +- try: +- reader.zone._ttl = reader.default_ttl +- except AttributeError: +- reader.zone._ttl = reader.ttl +- +- return reader.zone ++ if DNSPYTHON21: ++ zone = Zone( ++ origin, ++ dns.rdataclass.IN, ++ relativize=True, ++ ) ++ with zone.writer() as txn: ++ reader = Reader( ++ tok, ++ rdclass=dns.rdataclass.IN, ++ txn=txn, ++ allow_include=True, ++ ) ++ reader.read() ++ else: ++ reader = _MasterReader( ++ tok, ++ origin=origin, ++ rdclass=dns.rdataclass.IN, ++ relativize=True, ++ zone_factory=Zone, ++ allow_include=True, ++ check_origin=True, ++ ) ++ reader.read() ++ zone = reader.zone ++ ++ # TODO: remember that any method using the zone.filename property should ++ # have it passed as a parameter ++ zone._filename = filename ++ ++ # starting with dnspython v1.16.0, use default_ttl ++ try: ++ zone._ttl = reader.default_ttl ++ except AttributeError: ++ zone._ttl = reader.ttl ++ ++ return zone ++ +diff --git a/tests/test_context.py b/tests/test_context.py +index 2a32d00..baac084 100644 +--- a/tests/test_context.py ++++ b/tests/test_context.py +@@ -1,6 +1,9 @@ + import pytest + import localzone +-from dns.zone import UnknownOrigin ++try: ++ from dns.zonefile import UnknownOrigin ++except ImportError: ++ from dns.zone import UnknownOrigin + + ZONEFILE = "tests/zonefiles/db.example.com" + ORIGIN = "example.com." +diff --git a/tests/test_models.py b/tests/test_models.py +index 9ba0c40..621f6c0 100644 +--- a/tests/test_models.py ++++ b/tests/test_models.py +@@ -1,4 +1,5 @@ + from dns.rdatatype import UnknownRdatatype ++from dns.exception import SyntaxError as DNSSyntaxError + import pytest + import localzone + +@@ -77,7 +78,7 @@ def test_zone_add_record_unknown_type(): + + def test_zone_add_record_no_content(): + with localzone.manage(ZONEFILE, ORIGIN) as z: +- with pytest.raises(AttributeError): ++ with pytest.raises((AttributeError, DNSSyntaxError)): + z.add_record("test", "txt", None) + + diff --git a/python-localzone.changes b/python-localzone.changes index 4e5bc3f..9493606 100644 --- a/python-localzone.changes +++ b/python-localzone.changes @@ -1,10 +1,3 @@ -------------------------------------------------------------------- -Sat Jan 7 23:06:36 UTC 2023 - Dirk Müller - -- update to 0.9.8: - * Support dnspython 2.1. -- drop localzone-dnspython-2.1.patch (upstream) - ------------------------------------------------------------------- Mon Jan 18 14:00:08 UTC 2021 - Benjamin Greiner diff --git a/python-localzone.spec b/python-localzone.spec index 15605ac..cd1f6f5 100644 --- a/python-localzone.spec +++ b/python-localzone.spec @@ -1,7 +1,7 @@ # # spec file for package python-localzone # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-localzone -Version: 0.9.8 +Version: 0.9.7 Release: 0 Summary: A library for managing DNS zones License: BSD-3-Clause @@ -26,6 +26,8 @@ Group: Development/Languages/Python URL: https://github.com/ags-slc/localzone # The PyPI sdist does not provide the tests Source: https://github.com/ags-slc/localzone/archive/v%{version}.tar.gz#/localzone-%{version}.tar.gz +# PATCH-FIX-UPSTREAM localzone-dnspython-2.1.patch gh#ags-slc/localzone#3 -- support dnspython 2.1 +Patch0: https://github.com/ags-slc/localzone/pull/3.patch#/localzone-dnspython-2.1.patch BuildRequires: %{python_module dnspython} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools}