Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import fnmatch
- import re
- import fileinput
- os.chdir('C:\\Program Files (x86)\\Steam\\steamapps\\workshop\\content\\268500')
- for path,dirs,files in os.walk('.'):
- for f in fnmatch.filter(files,'XComGame.ini'):
- fullname = os.path.abspath(os.path.join(path,f))
- if re.search( r'^(.*\\[0-9]+\\[cC]onfig\\)([bB]ase\\)?[xcomgaeXCOMGAE]{8}[.][inIN]{3}', fullname):
- ctrl = True
- name = None
- with fileinput.input(files=fullname) as file:
- for line in file:
- if not name and re.search( r'^\[.+[.X2]{3}[a-zA-Z]+[_].+]', line):
- name = line.split('.X2')[0].strip().removeprefix('[')
- if ctrl and re.search( r'^\[.+CHDLCRunOrder]', line):
- ctrl = False
- elif ctrl and re.search( r'^\[.+CHModDependency]', line):
- ctrl = False
- elif ctrl and re.search( r'^\[.+CHHelpers]', line):
- ctrl = False
- elif ctrl and file.filelineno() > 10:
- ctrl = False
- if ctrl and type(name) == str:
- print(name)
- with open(fullname, 'a') as file:
- file.write('\n'.join(['','',f'[{name} CHDLCRunOrder]',
- 'RunPriorityGroup=RUN_LAST']))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement