Staging
v0.5.1
https://github.com/python/cpython
Revision 550e4673be538d98b6ddf5550b3922539cf5c4b2 authored by Victor Stinner on 08 December 2020, 23:32:54 UTC, committed by GitHub on 08 December 2020, 23:32:54 UTC
pymain_run_startup() now pass the filename as a Python object to
_PyRun_SimpleFileObject().
1 parent 98a5417
Raw File
Tip revision: 550e4673be538d98b6ddf5550b3922539cf5c4b2 authored by Victor Stinner on 08 December 2020, 23:32:54 UTC
bpo-32381: Add _PyRun_SimpleFileObject() (GH-23709)
Tip revision: 550e467
blake2b2s.py
#!/usr/bin/python3

import os
import re

HERE = os.path.dirname(os.path.abspath(__file__))
BLAKE2 = os.path.join(HERE, 'impl')

PUBLIC_SEARCH = re.compile(r'\ int (blake2[bs]p?[a-z_]*)\(')


def getfiles():
    for name in os.listdir(BLAKE2):
        name = os.path.join(BLAKE2, name)
        if os.path.isfile(name):
            yield name


def find_public():
    public_funcs = set()
    for name in getfiles():
        with open(name) as f:
            for line in f:
                # find public functions
                mo = PUBLIC_SEARCH.search(line)
                if mo:
                    public_funcs.add(mo.group(1))

    for f in sorted(public_funcs):
        print('#define {0:<18} PyBlake2_{0}'.format(f))

    return public_funcs


def main():
    lines = []
    with open(os.path.join(HERE, 'blake2b_impl.c')) as f:
        for line in f:
            line = line.replace('blake2b', 'blake2s')
            line = line.replace('BLAKE2b', 'BLAKE2s')
            line = line.replace('BLAKE2B', 'BLAKE2S')
            lines.append(line)
    with open(os.path.join(HERE, 'blake2s_impl.c'), 'w') as f:
        f.write(''.join(lines))
    # find_public()


if __name__ == '__main__':
    main()
back to top