-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgenerate_data_config.py
More file actions
30 lines (24 loc) · 1.35 KB
/
generate_data_config.py
File metadata and controls
30 lines (24 loc) · 1.35 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
import yaml
import json
import re
import logging
def generate_data_config() -> None:
with open(file = "./config/languages.yml", mode = "r", encoding = "utf-8") as config_file:
config_data = yaml.safe_load(config_file)
config_json = json.dumps(config_data, indent = 2, ensure_ascii = False)
config_json = re.sub(r'\bnull\b', 'None', config_json)
logging.basicConfig(level = logging.DEBUG, format = "%(asctime)s - %(levelname)s - %(message)s")
with open(file = "./etc/generate/config_data.py", mode = "w", encoding = "utf-8") as output_file:
output_file.write("\n".join([
"# ================================================================",
"# Auto-generated file config from YAML configuration",
"# You can customize this config via config/languages.yml file",
"# If this file is not exists, you can find this in:",
"# https://github.com/Reim-developer/Sephera/tree/master/config",
"# This project is licensed under the GNU General Public License v3.0",
"# https://github.com/Reim-developer/Sephera?tab=GPL-3.0-1-ov-file",
"# ==============================================================\n"
]))
output_file.write(f"CONFIG_DATA = {config_json}\n")
logging.debug("Generate data configuration sucessfully.")
generate_data_config()