|
rdobuilder |
b5faac |
From e1392feda59ed0fdcf10934d57f833c64e99c19a Mon Sep 17 00:00:00 2001
|
|
rdobuilder |
b5faac |
From: Alfredo Moralejo <amoralej@redhat.com>
|
|
rdobuilder |
b5faac |
Date: Thu, 30 Sep 2021 09:39:36 +0200
|
|
rdobuilder |
b5faac |
Subject: [PATCH] Use importlib.resources in python >= 3.7
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
importlib.resources was added to python standard library since python 3.7
|
|
rdobuilder |
b5faac |
[1]. This patch is implementing conditional to use it instead of the
|
|
rdobuilder |
b5faac |
importlib_resources backport when using python 3.7 or newer.
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
[1] https://docs.python.org/3/whatsnew/3.7.html
|
|
rdobuilder |
b5faac |
---
|
|
rdobuilder |
b5faac |
setup.cfg | 2 +-
|
|
rdobuilder |
b5faac |
src/saml2/sigver.py | 7 ++++++-
|
|
rdobuilder |
b5faac |
src/saml2/xml/schema/__init__.py | 7 ++++++-
|
|
rdobuilder |
b5faac |
3 files changed, 13 insertions(+), 3 deletions(-)
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
diff --git a/setup.cfg b/setup.cfg
|
|
rdobuilder |
b5faac |
index e04c5520..41ccdd7f 100644
|
|
rdobuilder |
b5faac |
--- a/setup.cfg
|
|
rdobuilder |
b5faac |
+++ b/setup.cfg
|
|
rdobuilder |
b5faac |
@@ -53,7 +53,7 @@ install_requires =
|
|
rdobuilder |
b5faac |
pytz
|
|
rdobuilder |
b5faac |
requests >= 1.0.0
|
|
rdobuilder |
b5faac |
six
|
|
rdobuilder |
b5faac |
- importlib_resources
|
|
rdobuilder |
b5faac |
+ importlib_resources;python_version<'3.7'
|
|
rdobuilder |
b5faac |
xmlschema >= 1.2.1
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py
|
|
rdobuilder |
b5faac |
index 973d6245..c9c66b13 100644
|
|
rdobuilder |
b5faac |
--- a/src/saml2/sigver.py
|
|
rdobuilder |
b5faac |
+++ b/src/saml2/sigver.py
|
|
rdobuilder |
b5faac |
@@ -9,12 +9,12 @@ import logging
|
|
rdobuilder |
b5faac |
import os
|
|
rdobuilder |
b5faac |
import re
|
|
rdobuilder |
b5faac |
import six
|
|
rdobuilder |
b5faac |
+import sys
|
|
rdobuilder |
b5faac |
from uuid import uuid4 as gen_random_key
|
|
rdobuilder |
b5faac |
from time import mktime
|
|
rdobuilder |
b5faac |
from tempfile import NamedTemporaryFile
|
|
rdobuilder |
b5faac |
from subprocess import Popen
|
|
rdobuilder |
b5faac |
from subprocess import PIPE
|
|
rdobuilder |
b5faac |
-from importlib_resources import path as _resource_path
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
from OpenSSL import crypto
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
@@ -59,6 +59,11 @@ from saml2.xmlenc import EncryptedData
|
|
rdobuilder |
b5faac |
from saml2.xml.schema import node_to_schema
|
|
rdobuilder |
b5faac |
from saml2.xml.schema import XMLSchemaError
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
+# importlib.resources was introduced in python 3.7
|
|
rdobuilder |
b5faac |
+if sys.version_info[:2] >= (3, 7):
|
|
rdobuilder |
b5faac |
+ from importlib.resources import path as _resource_path
|
|
rdobuilder |
b5faac |
+else:
|
|
rdobuilder |
b5faac |
+ from importlib_resources import path as _resource_path
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
logger = logging.getLogger(__name__)
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
diff --git a/src/saml2/xml/schema/__init__.py b/src/saml2/xml/schema/__init__.py
|
|
rdobuilder |
b5faac |
index 56e08b1c..ce38b807 100644
|
|
rdobuilder |
b5faac |
--- a/src/saml2/xml/schema/__init__.py
|
|
rdobuilder |
b5faac |
+++ b/src/saml2/xml/schema/__init__.py
|
|
rdobuilder |
b5faac |
@@ -1,10 +1,15 @@
|
|
rdobuilder |
b5faac |
-from importlib_resources import path as _resource_path
|
|
rdobuilder |
b5faac |
+import sys
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
from xmlschema import XMLSchema as _XMLSchema
|
|
rdobuilder |
b5faac |
from xmlschema.exceptions import XMLSchemaException as XMLSchemaError
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
import saml2.data.schemas as _data_schemas
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
+# importlib.resources was introduced in python 3.7
|
|
rdobuilder |
b5faac |
+if sys.version_info[:2] >= (3, 7):
|
|
rdobuilder |
b5faac |
+ from importlib.resources import path as _resource_path
|
|
rdobuilder |
b5faac |
+else:
|
|
rdobuilder |
b5faac |
+ from importlib_resources import path as _resource_path
|
|
rdobuilder |
b5faac |
|
|
rdobuilder |
b5faac |
def _create_xml_schema_validator(source, **kwargs):
|
|
rdobuilder |
b5faac |
kwargs = {
|
|
rdobuilder |
b5faac |
--
|
|
rdobuilder |
b5faac |
2.26.3
|
|
rdobuilder |
b5faac |
|