summaryrefslogtreecommitdiff
path: root/game/python-extra/certifi/core.py
blob: 56b52a3c8f4f66a6f1fb6be36dd25fc906303fef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-

"""
certifi.py
~~~~~~~~~~

This module returns the installation location of cacert.pem or its contents.
"""
import os

try:
    from importlib.resources import read_text
except ImportError:
    # This fallback will work for Python versions prior to 3.7 that lack the
    # importlib.resources module but relies on the existing `where` function
    # so won't address issues with environments like PyOxidizer that don't set
    # __file__ on modules.
    def read_text(_module, _path, encoding="ascii"):
        with open(where(), "r", encoding=encoding) as data:
            return data.read()


def where():
    f = os.path.dirname(__file__)

    return os.path.join(f, "cacert.pem")


def contents():
    return read_text("certifi", "cacert.pem", encoding="ascii")