Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import numpy as np
- import glob
- target_dir = r'E:\Program Files (x86)\Steam\steamapps\common\Stellaris\common\pop_jobs'
- out_dir = r'C:\Users\Andrey\Documents\Paradox Interactive\Stellaris\mod\daily_pop_calc_is_bad\common\pop_jobs'
- def jobs(files):
- for file in files:
- out_file = os.path.join(out_dir, os.path.basename(file))
- with open(file, 'r') as f:
- text = f.read()
- #text = re.sub('#+.*\n', '\n', text)
- text = re.sub('\t*\n', '\n', text)
- text = re.sub(' *\n', '\n', text)
- things = re.findall(r'\n\w*? = {.*?\n}', text, re.DOTALL)
- with open(out_file, 'w') as f:
- for thing in things:
- name = ''
- name = re.match(r'\n\w* = {', thing).group(0).replace(' = {', '').replace('\n', '')
- if 'is_capped_by_modifier = no' not in thing:
- thing = thing.replace('possible = {', 'possible = {{\n\t\tor = {{\n\t\t\thas_job = {}\n\t\t\tdpcb_trigger_job = yes\n\t\t}}'.format(name), 1)
- thing = thing.replace('modifier = {\n\t\t\tfactor = 10\n\t\t\tis_enslaved = yes\n\t\t\tcan_take_servant_job = no\n\t\t}\n\t\tmodifier = {\n\t\t\tfactor = 2\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t\towner = { has_technology = tech_droid_workers }\n\t\t}\n\t\tmodifier = {\n\t\t\tfactor = 10\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t\towner = { NOT = { has_technology = tech_droid_workers } }\n\t\t}', 'modifier = {\n\t\t\tfactor = 10\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t\tis_enslaved = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t}', 1)
- thing = thing.replace('modifier = {\n\t\t\tfactor = 8\n\t\t\tis_enslaved = yes\n\t\t\tcan_take_servant_job = no\n\t\t}\n\t\tmodifier = {\n\t\t\tfactor = 2\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t}', 'modifier = {\n\t\t\tfactor = 10\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t\tis_enslaved = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t}', 1)
- thing = thing.replace('modifier = {\n\t\t\tfactor = 0.25\n\t\t\tis_enslaved = yes\n\t\t\tcan_take_servant_job = no\n\t\t}\n\t\tmodifier = {\n\t\t\tfactor = 2\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t}', 'modifier = {\n\t\t\tfactor = 10\n\t\t\tOR = {\n\t\t\t\tis_non_sapient_robot = yes\n\t\t\t\tis_shackled_robot = yes\n\t\t\t\tis_enslaved = yes\n\t\t\t}\n\t\t\tcan_take_servant_job = no\n\t\t}', 1)
- #print(thing)
- f.write(thing)
- f.write('\n')
- files = glob.glob(target_dir + '\\*.txt')
- jobs(files)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement