1import os
2import sys
3
4pkgRelDir = sys.argv[1]
5pkgFiles = sys.argv[2:]
6
7getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
8importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
9
10script = """__all__ = [{import_names}]
11for x in __all__:
12  __import__('lldb.{pkg_name}.' + x)
13""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
14
15pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
16with open(pkgIniFile, "w") as f:
17    f.write(script)
18