forked from pool/python-localzone
Accepting request 864132 from home:bnavigator:branches:devel:languages:python
- Update to version 0.9.7 * Support dnspython 2. - Add localzone-dnspython-2.1.patch gh#ags-slc/localzone#3 OBS-URL: https://build.opensuse.org/request/show/864132 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-localzone?expand=0&rev=12
This commit is contained in:
3
localzone-0.9.7.tar.gz
Normal file
3
localzone-0.9.7.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:a03afb61683e63737cd7ccdf286e22b0c4ced87c1eb67896d9916e92d48bad4d
|
||||||
|
size 27905
|
||||||
129
localzone-dnspython-2.1.patch
Normal file
129
localzone-dnspython-2.1.patch
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Jan 18 14:00:08 UTC 2021 - Benjamin Greiner <code@bnavigator.de>
|
||||||
|
|
||||||
|
- Update to version 0.9.7
|
||||||
|
* Support dnspython 2.
|
||||||
|
- Add localzone-dnspython-2.1.patch gh#ags-slc/localzone#3
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Wed Apr 15 09:17:57 UTC 2020 - pgajdos@suse.com
|
Wed Apr 15 09:17:57 UTC 2020 - pgajdos@suse.com
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-localzone
|
# spec file for package python-localzone
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2021 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -18,13 +18,16 @@
|
|||||||
|
|
||||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||||
Name: python-localzone
|
Name: python-localzone
|
||||||
Version: 0.9.6
|
Version: 0.9.7
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: A library for managing DNS zones
|
Summary: A library for managing DNS zones
|
||||||
License: BSD-3-Clause
|
License: BSD-3-Clause
|
||||||
Group: Development/Languages/Python
|
Group: Development/Languages/Python
|
||||||
URL: https://github.com/ags-slc/localzone
|
URL: https://github.com/ags-slc/localzone
|
||||||
Source: https://github.com/ags-slc/localzone/archive/v%{version}.tar.gz
|
# 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 dnspython}
|
||||||
BuildRequires: %{python_module pytest}
|
BuildRequires: %{python_module pytest}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
@@ -38,7 +41,7 @@ BuildArch: noarch
|
|||||||
A simple library for managing DNS zones.
|
A simple library for managing DNS zones.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n localzone-%{version}
|
%autosetup -p1 -n localzone-%{version}
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
@@ -53,6 +56,7 @@ A simple library for managing DNS zones.
|
|||||||
%files %{python_files}
|
%files %{python_files}
|
||||||
%doc README.rst
|
%doc README.rst
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%{python_sitelib}/*
|
%{python_sitelib}/localzone
|
||||||
|
%{python_sitelib}/localzone-%{version}*-info
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:d2618d304fcb509ead36a948fab84a81e2f5e8ee62ae592fc1e5e3fec7e26897
|
|
||||||
size 27873
|
|
||||||
Reference in New Issue
Block a user