diff options
author | deshevoy <deshevoy@yandex-team.ru> | 2022-02-10 16:46:57 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:57 +0300 |
commit | 28148f76dbfcc644d96427d41c92f36cbf2fdc6e (patch) | |
tree | b83306b6e37edeea782e9eed673d89286c4fef35 /build/scripts/gen_py3_reg.py | |
parent | e988f30484abe5fdeedcc7a5d3c226c01a21800c (diff) | |
download | ydb-28148f76dbfcc644d96427d41c92f36cbf2fdc6e.tar.gz |
Restoring authorship annotation for <deshevoy@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'build/scripts/gen_py3_reg.py')
-rw-r--r-- | build/scripts/gen_py3_reg.py | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/build/scripts/gen_py3_reg.py b/build/scripts/gen_py3_reg.py index 151679b88b..149c094898 100644 --- a/build/scripts/gen_py3_reg.py +++ b/build/scripts/gen_py3_reg.py @@ -1,34 +1,34 @@ -import sys - -template = ''' +import sys + +template = ''' struct PyObject; extern "C" int PyImport_AppendInittab(const char* name, PyObject* (*initfunc)()); extern "C" PyObject* {1}(); - -namespace { - struct TRegistrar { - inline TRegistrar() { - // TODO Collect all modules and call PyImport_ExtendInittab once - PyImport_AppendInittab("{0}", {1}); - } - } REG; -} -''' - - -def mangle(name): - if '.' not in name: - return name - return ''.join('{}{}'.format(len(s), s) for s in name.split('.')) - -if __name__ == '__main__': - if len(sys.argv) != 3: - print >>sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' - print >>sys.stderr, 'Passed: ' + ' '.join(sys.argv) - sys.exit(1) - - with open(sys.argv[2], 'w') as f: - modname = sys.argv[1] - initname = 'PyInit_' + mangle(modname) - code = template.replace('{0}', modname).replace('{1}', initname) - f.write(code) + +namespace { + struct TRegistrar { + inline TRegistrar() { + // TODO Collect all modules and call PyImport_ExtendInittab once + PyImport_AppendInittab("{0}", {1}); + } + } REG; +} +''' + + +def mangle(name): + if '.' not in name: + return name + return ''.join('{}{}'.format(len(s), s) for s in name.split('.')) + +if __name__ == '__main__': + if len(sys.argv) != 3: + print >>sys.stderr, 'Usage: <path/to/gen_py_reg.py> <python_module_name> <output_file>' + print >>sys.stderr, 'Passed: ' + ' '.join(sys.argv) + sys.exit(1) + + with open(sys.argv[2], 'w') as f: + modname = sys.argv[1] + initname = 'PyInit_' + mangle(modname) + code = template.replace('{0}', modname).replace('{1}', initname) + f.write(code) |