48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
OUTPUT="keypadOS.lua";
|
|
FILES= [
|
|
"updater.lua",
|
|
"config.lua",
|
|
"ui.lua",
|
|
"utils.lua",
|
|
"main.lua",
|
|
]
|
|
|
|
def read_file(p: str) -> str:
|
|
buf = "";
|
|
with open("src/"+p, "r", encoding="utf-8") as f:
|
|
buf += f"\n__BUNDLER_FILES[\"{p}\"] = function ()\n";
|
|
for line in f.readlines():
|
|
if str.strip(line) != "":
|
|
buf += " " + line;
|
|
buf += f"\nend -- FILE END: {p} --\n";
|
|
return buf;
|
|
|
|
|
|
def main():
|
|
buf = ""
|
|
buf += "local __BUNDLER_FILES = {}\n";
|
|
buf += "local __DEFAULT_IMPORT = require\n";
|
|
buf += "local require = function(path)\n";
|
|
buf += " if __BUNDLER_FILES[path] then\n";
|
|
buf += " return __BUNDLER_FILES[path]()\n";
|
|
buf += " else\n";
|
|
buf += " __DEFAULT_IMPORT(path)\n";
|
|
buf += " end\n";
|
|
buf += "end\n";
|
|
|
|
for file in FILES:
|
|
print(f"=== FILE: {file}");
|
|
buf += read_file(file);
|
|
|
|
buf += "\nrequire(\"main.lua\").Main()\n";
|
|
|
|
with open(OUTPUT, "w", encoding="utf-8") as f:
|
|
f.write(buf);
|
|
print("DONE");
|
|
|
|
if __name__ == "__main__":
|
|
main();
|
|
|