Fix certifi per Kodi 18 (potrebbe richiedere reinstallazione)

This commit is contained in:
Alhaziel01
2022-09-29 18:34:38 +02:00
parent 9109d6ec55
commit 6c43f5101b
+7 -15
View File
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
""" """
certifi.py certifi.py
~~~~~~~~~~ ~~~~~~~~~~
@@ -5,8 +7,6 @@ certifi.py
This module returns the installation location of cacert.pem or its contents. This module returns the installation location of cacert.pem or its contents.
""" """
import os import os
import types
from typing import Union
try: try:
from importlib.resources import path as get_path, read_text from importlib.resources import path as get_path, read_text
@@ -14,7 +14,7 @@ try:
_CACERT_CTX = None _CACERT_CTX = None
_CACERT_PATH = None _CACERT_PATH = None
def where() -> str: def where():
# This is slightly terrible, but we want to delay extracting the file # This is slightly terrible, but we want to delay extracting the file
# in cases where we're inside of a zipimport situation until someone # in cases where we're inside of a zipimport situation until someone
# actually calls where(), but we don't want to re-extract the file # actually calls where(), but we don't want to re-extract the file
@@ -40,29 +40,21 @@ try:
except ImportError: except ImportError:
Package = Union[types.ModuleType, str]
Resource = Union[str, "os.PathLike"]
# This fallback will work for Python versions prior to 3.7 that lack the # This fallback will work for Python versions prior to 3.7 that lack the
# importlib.resources module but relies on the existing `where` function # importlib.resources module but relies on the existing `where` function
# so won't address issues with environments like PyOxidizer that don't set # so won't address issues with environments like PyOxidizer that don't set
# __file__ on modules. # __file__ on modules.
def read_text( def read_text(_module, _path, encoding="ascii"):
package: Package, with open(where(), "r", encoding=encoding) as data:
resource: Resource,
encoding: str = 'utf-8',
errors: str = 'strict'
) -> str:
with open(where(), encoding=encoding) as data:
return data.read() return data.read()
# If we don't have importlib.resources, then we will just do the old logic # If we don't have importlib.resources, then we will just do the old logic
# of assuming we're on the filesystem and munge the path directly. # of assuming we're on the filesystem and munge the path directly.
def where() -> str: def where():
f = os.path.dirname(__file__) f = os.path.dirname(__file__)
return os.path.join(f, "cacert.pem") return os.path.join(f, "cacert.pem")
def contents() -> str: def contents():
return read_text("certifi", "cacert.pem", encoding="ascii") return read_text("certifi", "cacert.pem", encoding="ascii")