-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLicense-Creator.py
More file actions
42 lines (32 loc) · 1.16 KB
/
License-Creator.py
File metadata and controls
42 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import json
import sys
# Dosya adları
CONFIG_FILE = "Config.json"
LICENSES_DIR = "Licenses"
OUTPUT_LICENSE_FILE = "../LICENSE"
def CreateLicense():
# JSON dosyasını oku
if not os.path.exists(CONFIG_FILE):
print(f"❌ Error: {CONFIG_FILE} could not be found.")
sys.exit(1)
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
config = json.load(f)
license_name = config.get("license")
if not license_name:
print("❌ Error: The 'license' field could not be found in the JSON file.")
sys.exit(1)
# Lisans dosyasını bul
license_file = os.path.join(LICENSES_DIR, f"{license_name}.txt")
if not os.path.exists(license_file):
print(f"❌ Error: {license_file} could not be found.")
sys.exit(1)
# Lisans içeriğini oku
with open(license_file, "r", encoding="utf-8") as f:
license_content = f.read()
# LICENSE dosyasına yaz
with open(OUTPUT_LICENSE_FILE, "w", encoding="utf-8") as f:
f.write(license_content)
print(f"✅ The {license_name} license has been written to the '{OUTPUT_LICENSE_FILE}' file.")
if __name__ == "__main__":
CreateLicense()