File: __init__.py

package info (click to toggle)
python-pkcs11 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 804 kB
  • sloc: python: 3,844; ansic: 1,981; sh: 33; makefile: 24
file content (35 lines) | stat: -rw-r--r-- 671 bytes parent folder | download
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
31
32
33
34
35
"""
:mod:`pkcs11` defines a high-level, "Pythonic" interface to PKCS#11.
"""

from .constants import *  # noqa: F403
from .exceptions import *  # noqa: F403
from .mechanisms import *  # noqa: F403
from .types import *  # noqa: F403


_so = None
_lib = None


def lib(so):
    """
    Wrap the main library call coming from Cython with a preemptive
    dynamic loading.
    """
    global _lib
    global _so

    if _lib:
        if _so != so:
            raise AlreadyInitialized(  # noqa: F405
                "Already initialized with %s" % so)
        else:
            return _lib

    from . import _pkcs11

    _lib = _pkcs11.lib(so)
    _so = so

    return _lib