Fix
[ryzomcore.git] / ryzom / server / tools / cfg_creator / create_cfgs.py
blob755503b8c23d713801fc8fd100e06952986f1052
1 #!/usr/bin/python3
2 # ______ _____ _ _ _____ _
3 # | ___ \ / ___| | | | |_ _| | |
4 # | |_/ / _ _______ _ __ ___ \ `--.| |__ __ _ _ __ __| | | | ___ ___ | |___
5 # | / | | |_ / _ \| '_ ` _ \ `--. \ '_ \ / _` | '__/ _` | | |/ _ \ / _ \| / __|
6 # | |\ \ |_| |/ / (_) | | | | | | /\__/ / | | | (_| | | | (_| | | | (_) | (_) | \__ \
7 # \_| \_\__, /___\___/|_| |_| |_| \____/|_| |_|\__,_|_| \__,_| \_/\___/ \___/|_|___/
8 # __/ |
9 # |___/
11 # Ryzom - MMORPG Framework <https://ryzom.com/dev/>
12 # Copyright (C) 2019 Winch Gate Property Limited
13 # This program is free software: read https://ryzom.com/dev/copying.html for more details
15 # This script is a helper to generate the configurations files of a ryzom shard
16 # just reading fields in a globals.cfg file and replacing it in all final cfgs files
18 # Usage are ./create_cfgs.py SHARD_PATH
23 import os, sys
25 dstpath = sys.argv[1]
27 dir_path = os.path.dirname(os.path.realpath(__file__))
29 templatepath = dir_path+"/templates/"
30 finalpath = dstpath+"/cfgs/"
32 enc = "iso-8859-1"
34 with open(dstpath+"/globals.cfg", 'r', encoding=enc) as fd:
35 if fd:
36 lines = fd.read().split("\n")
37 tmp = []
38 for n in lines:
39 if n:
40 line = n.split(" = ")
41 if line:
42 tmp.append(line)
44 for f in os.listdir(templatepath):
45 with open(templatepath+f, 'r', encoding=enc) as content:
46 if content:
47 content = content.read()
48 for k, v in tmp:
49 content = content.replace(k, v)
50 with open(finalpath+f, 'w') as fd:
51 fd.write(content)
52 print(f)