Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. path_to_comands = 'text.json'
  2. path_to_polyplan_config = 'sample_config.json'
  3. path_to_auth = 'auth.json'
  4.  
  5. polyplan_config_name = 'config_{}.json'
  6. auth_config = 'auth_{}.py'
  7.  
  8.  
  9. # Read teams_info
  10. with open(path_to_comands, encoding="utf-16") as crr_file:
  11.     lines = crr_file.readlines()
  12.  
  13. teams = {}
  14. for crr_id in range(len(lines)):
  15.     line = lines[crr_id].split()
  16.     # line[0]-Name, line[1]-Pass, maybe instead a tuple use dictionary with keys 'name'&'password'
  17.     teams[crr_id] = (line[0], line[1])
  18.  
  19. # Read and generate polyplan config
  20. with open(path_to_polyplan_config, encoding="utf-8") as polyplan_configs:
  21.     polyplan_filedata = polyplan_configs.read()
  22. with open(path_to_auth, encoding="utf-8") as auth:
  23.     auth_filedata = auth.read()
  24.  
  25.  
  26. for key in teams.keys():
  27.     team_id = str(key+1)
  28.     team_name = teams[key][0]
  29.     team_pass = teams[key][1]
  30.     with open(polyplan_config_name.format(team_id), mode='w') as config:
  31.         crr_filedata = polyplan_filedata.replace('%team%', team_name)
  32.         crr_filedata = crr_filedata.replace('%id%', team_id)
  33.         config.write(crr_filedata)
  34.     with open(auth_config.format(team_id), mode='w') as auth:
  35.         crr_auth = auth_filedata.replace('%name%', team_name)
  36.         crr_auth = crr_auth.replace('%pass%', team_pass)
  37.         auth.write(crr_auth)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement