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