Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 68315c0

Browse files
committed
Generate license header with definition files
Why not
1 parent 4e064a3 commit 68315c0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scripts/generateDefinitions.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ def main():
1111
print("Error: Project directory must be passed in as a command-line argument.")
1212
exit(1)
1313
project = sys.argv[1]
14+
license_file = os.path.join(project, "LICENSE")
1415
globals_file = os.path.join(project, "globals.d.lua")
1516
types_file = os.path.join(project, "types.d.lua")
1617
parts_file = os.path.join(project, "parts.json")
1718
output_file = os.path.join(project, "build", "pilot.d.lua")
18-
content = ""
19+
# Generate header comment
20+
header_content = "--[[\n"
21+
with open(license_file, 'r') as fr:
22+
for line in fr.readlines():
23+
header_content += f" {line}"
24+
header_content += "\n https://github.com/flxwed/autopilot-lua/\n--]]\n"
1925
# Generate types
26+
content = ""
2027
with open(types_file, 'r') as fr:
2128
content += fr.read().strip() + "\n"
2229
# Get parts data
@@ -49,7 +56,7 @@ def main():
4956
if not os.path.isdir(os.path.join(project, "build")):
5057
os.makedirs(os.path.join(project, "build"))
5158
with open(output_file, 'w+') as fw:
52-
fw.write(content)
59+
fw.write(header_content + "\n" + content)
5360
print(f"{output_file} created successfully")
5461

5562
if __name__ == "__main__":

0 commit comments

Comments
 (0)