[NFC][Coroutines] Use structured binding with llvm::enumerate in CoroSplit (#116879)
[llvm-project.git] / lldb / bindings / python / createPythonInit.py
blobf343832b949bafea4e4e117a6d5992b151cc1f68
1 import os
2 import sys
4 pkgRelDir = sys.argv[1]
5 pkgFiles = sys.argv[2:]
7 getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
8 importNames = ", ".join('"{}"'.format(getFileName(f)) for f in pkgFiles)
10 script = """__all__ = [{import_names}]
11 for x in __all__:
12 __import__('lldb.{pkg_name}.' + x)
14 def __lldb_init_module(debugger, internal_dict):
15 import lldb
16 for x in __all__:
17 submodule = getattr(lldb.{pkg_name}, x)
18 lldb_init = getattr(submodule, '__lldb_init_module', None)
19 if lldb_init:
20 lldb_init(debugger, internal_dict)
21 """.format(
22 import_names=importNames, pkg_name=pkgRelDir.replace("/", ".")
25 pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
26 with open(pkgIniFile, "w") as f:
27 f.write(script)