Advertisement
Guest User

PYTHON SCRIPT FOR DLCRUNORDER

a guest
Aug 10th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. import os
  2. import fnmatch
  3. import re
  4. import fileinput
  5.  
  6. os.chdir('C:\\Program Files (x86)\\Steam\\steamapps\\workshop\\content\\268500')
  7.  
  8. for path,dirs,files in os.walk('.'):
  9.     for f in fnmatch.filter(files,'XComGame.ini'):
  10.         fullname = os.path.abspath(os.path.join(path,f))
  11.         if re.search( r'^(.*\\[0-9]+\\[cC]onfig\\)([bB]ase\\)?[xcomgaeXCOMGAE]{8}[.][inIN]{3}', fullname):
  12.             ctrl = True
  13.             name = None
  14.             with fileinput.input(files=fullname) as file:
  15.                 for line in file:
  16.                     if not name and re.search( r'^\[.+[.X2]{3}[a-zA-Z]+[_].+]', line):
  17.                         name = line.split('.X2')[0].strip().removeprefix('[')
  18.                    
  19.                     if ctrl and re.search( r'^\[.+CHDLCRunOrder]', line):
  20.                         ctrl = False
  21.                     elif ctrl and re.search( r'^\[.+CHModDependency]', line):
  22.                         ctrl = False
  23.                     elif ctrl and re.search( r'^\[.+CHHelpers]', line):
  24.                         ctrl = False
  25.                     elif ctrl and file.filelineno() > 10:
  26.                         ctrl = False
  27.  
  28.  
  29.  
  30.             if ctrl and type(name) == str:
  31.                 print(name)
  32.                 with open(fullname, 'a') as file:
  33.                     file.write('\n'.join(['','',f'[{name} CHDLCRunOrder]',
  34.                                                 'RunPriorityGroup=RUN_LAST']))
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement