ยปCore Development>Code coverage>Modules/_blake2/blake2b2s.py

Python code coverage for Modules/_blake2/blake2b2s.py

#countcontent
1n/a#!/usr/bin/python3
2n/a
3n/aimport os
4n/aimport re
5n/a
6n/aHERE = os.path.dirname(os.path.abspath(__file__))
7n/aBLAKE2 = os.path.join(HERE, 'impl')
8n/a
9n/aPUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(')
10n/a
11n/a
12n/adef getfiles():
13n/a for name in os.listdir(BLAKE2):
14n/a name = os.path.join(BLAKE2, name)
15n/a if os.path.isfile(name):
16n/a yield name
17n/a
18n/a
19n/adef find_public():
20n/a public_funcs = set()
21n/a for name in getfiles():
22n/a with open(name) as f:
23n/a for line in f:
24n/a # find public functions
25n/a mo = PUBLIC_SEARCH.search(line)
26n/a if mo:
27n/a public_funcs.add(mo.group(1))
28n/a
29n/a for f in sorted(public_funcs):
30n/a print('#define {0:<18} PyBlake2_{0}'.format(f))
31n/a
32n/a return public_funcs
33n/a
34n/a
35n/adef main():
36n/a lines = []
37n/a with open(os.path.join(HERE, 'blake2b_impl.c')) as f:
38n/a for line in f:
39n/a line = line.replace('blake2b', 'blake2s')
40n/a line = line.replace('BLAKE2b', 'BLAKE2s')
41n/a line = line.replace('BLAKE2B', 'BLAKE2S')
42n/a lines.append(line)
43n/a with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f:
44n/a f.write(''.join(lines))
45n/a # find_public()
46n/a
47n/a
48n/aif __name__ == '__main__':
49n/a main()