File: lib

package info (click to toggle)
python-lib1305 0~20250415.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 120 kB
  • sloc: python: 184; makefile: 2
file content (28 lines) | stat: -rwxr-xr-x 641 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
#!/usr/bin/env python3

project='lib1305'
libname='1305'

lib="""'''
Import shared library.
'''


from ctypes import CDLL as _CDLL
from ctypes.util import find_library as _find_library

_libname = _find_library('%s')
if _libname is None:
    raise FileNotFoundError("unable to locate library '%s'")
_lib = _CDLL(_libname)


def _check_input(x, xlen, name):
    if not isinstance(x, bytes):
        raise TypeError(f'{name} must be bytes')
    if xlen != -1 and xlen != len(x):
        raise ValueError(f'{name} length must have exactly {xlen} bytes')
""" % (libname, libname)

with open(f'src/{project}/_lib.py', 'w') as f:
    f.write(lib)