Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- path_to_comands = 'text.json'
- path_to_polyplan_config = 'sample_config.json'
- path_to_auth = 'auth.json'
- polyplan_config_name = 'config_{}.json'
- auth_config = 'auth_{}.py'
- # Read teams_info
- with open(path_to_comands, encoding="utf-16") as crr_file:
- lines = crr_file.readlines()
- teams = {}
- for crr_id in range(len(lines)):
- line = lines[crr_id].split()
- # line[0]-Name, line[1]-Pass, maybe instead a tuple use dictionary with keys 'name'&'password'
- teams[crr_id] = (line[0], line[1])
- # Read and generate polyplan config
- with open(path_to_polyplan_config, encoding="utf-8") as polyplan_configs:
- polyplan_filedata = polyplan_configs.read()
- with open(path_to_auth, encoding="utf-8") as auth:
- auth_filedata = auth.read()
- for key in teams.keys():
- team_id = str(key+1)
- team_name = teams[key][0]
- team_pass = teams[key][1]
- with open(polyplan_config_name.format(team_id), mode='w') as config:
- crr_filedata = polyplan_filedata.replace('%team%', team_name)
- crr_filedata = crr_filedata.replace('%id%', team_id)
- config.write(crr_filedata)
- with open(auth_config.format(team_id), mode='w') as auth:
- crr_auth = auth_filedata.replace('%name%', team_name)
- crr_auth = crr_auth.replace('%pass%', team_pass)
- auth.write(crr_auth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement