14
0

Updating link to change in openSUSE:Factory/python-localzone revision 6

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-localzone?expand=0&rev=92c1fce642c26008820a67139ca40c22
This commit is contained in:
OBS User buildservice-autocommit
2023-01-08 20:25:36 +00:00
committed by Git OBS Bridge
parent d407363493
commit d573890d29
5 changed files with 12 additions and 136 deletions

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a03afb61683e63737cd7ccdf286e22b0c4ced87c1eb67896d9916e92d48bad4d
size 27905

3
localzone-0.9.8.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6ef39de76dc59a0c6c13ae85fe85bf3a58323cab568b47cb51b435d42a1d39e6
size 28102

View File

@@ -1,129 +0,0 @@
From c508257d6478e75a74a2fe0c9e770ef89c50eb41 Mon Sep 17 00:00:00 2001
From: Ben Greiner <code@bnavigator.de>
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)

View File

@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Sat Jan 7 23:06:36 UTC 2023 - Dirk Müller <dmueller@suse.com>
- 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 <code@bnavigator.de>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-localzone
#
# Copyright (c) 2021 SUSE LLC
# Copyright (c) 2023 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.7
Version: 0.9.8
Release: 0
Summary: A library for managing DNS zones
License: BSD-3-Clause
@@ -26,8 +26,6 @@ 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}