import os
import re
myfile = open("7lpp.compare.rs", "r")
texttofind = re.findall(r'[merge][l]*', myfile)
#texttofind = re.findall("Environment Switches")
texttoreplace = "Worked: ha ha ha"
filedata = myfile.read()
filedata = filedata.replace(texttofind,texttoreplace)
## Creating and writing changes
outfile= open("7lpp.compare.rs_int_re", "w")
outfile.write(filedata)
import re
myfile = open("7lpp.compare.rs", "r")
texttofind = re.findall(r'[merge][l]*', myfile)
#texttofind = re.findall("Environment Switches")
texttoreplace = "Worked: ha ha ha"
filedata = myfile.read()
filedata = filedata.replace(texttofind,texttoreplace)
## Creating and writing changes
outfile= open("7lpp.compare.rs_int_re", "w")
outfile.write(filedata)
import os
texttofind = """{
merge_parallel(
state,
device_type,
device_names = {res_schname},
exclude_tolerances = res_merge_p_exclude_tol,
property_functions = res_merge_p_property_func
);"""
change_list = ("merge_series(", "merge_parallel(")
#text_to_replace0 = texttofind.replace("\t", "\\")
#text_to_replace1 = texttoreplace0.replace(" ", "")
#text_to_replace = texttoreplace1.replace("\n", ",")
myfile = open("7lpp.compare.rs", "r")
tmp_str = ""
out = ""
found = False
count = 0
for line in myfile.readlines():
if any(token in line for token in change_list):
found = True
tmp_str = ""
count = 0
while line[count] == "\t":
count += 1
if found:
tmp_str += line
out += "//" + line
if found and ");" in line:
found = False
tmp_str = tmp_str.replace("\n","")
tmp_str = tmp_str.replace(" ","")
tmp_str = tmp_str.replace("\t","")
tmp_str = "\n" + "\t" * count + tmp_str + "\n"
out += tmp_str
continue
if not found:
out += line
## Creating and writing changes
#outfile= open("7lpp.compare.rs_int", "w")
outfile= open("sample", "w")
outfile.write(out)
texttofind = """{
merge_parallel(
state,
device_type,
device_names = {res_schname},
exclude_tolerances = res_merge_p_exclude_tol,
property_functions = res_merge_p_property_func
);"""
change_list = ("merge_series(", "merge_parallel(")
#text_to_replace0 = texttofind.replace("\t", "\\")
#text_to_replace1 = texttoreplace0.replace(" ", "")
#text_to_replace = texttoreplace1.replace("\n", ",")
myfile = open("7lpp.compare.rs", "r")
tmp_str = ""
out = ""
found = False
count = 0
for line in myfile.readlines():
if any(token in line for token in change_list):
found = True
tmp_str = ""
count = 0
while line[count] == "\t":
count += 1
if found:
tmp_str += line
out += "//" + line
if found and ");" in line:
found = False
tmp_str = tmp_str.replace("\n","")
tmp_str = tmp_str.replace(" ","")
tmp_str = tmp_str.replace("\t","")
tmp_str = "\n" + "\t" * count + tmp_str + "\n"
out += tmp_str
continue
if not found:
out += line
## Creating and writing changes
#outfile= open("7lpp.compare.rs_int", "w")
outfile= open("sample", "w")
outfile.write(out)
import os
import re
myfile_txt = open("umc22ull_drc_test.txt", "r")
#myfile = myfile_txt.readlines()
start_var = "start variable \n \n"
end_var = "end variable"
#mystring = "guru99 , education is fun"
# = re.findall(r".*", myfile)
#print(options)
temp_str = ""
grad_den = ""
#save_com = ""
comchanged = ""
for line in myfile_txt.readlines():
pattern = re.compile(r"gradient_density.*")
gradient_density = pattern.finditer(line)
for match in gradient_density:
com = match.group()
#print (com)
#def findandchange(com,comchanged):
# com = re.sub("gradient_density.*", "From:" + "\t" + com, com)
# comchanged = re.sub("From", "To ", com)
# comchanged = re.sub("delta_x = \d*, delta_y = \d*", "delta_x = 0.5, delta_y =0.5 ", comchanged)
# return
if "violation_name_unselect" in line:
temp_str = temp_str + line
elif "gradient_density" in line:
grad_den = re.sub(grad_den, "From:" + "\t" + grad_den, grad_den)
comchanged = re.sub("From", "To ", grad_den)
comchanged = re.sub("delta_x = \d*, delta_y = \d*", "delta_x = 0.5, delta_y =0.5 ", comchanged)
grad_den = grad_den + line
#save_com = save_com + line
# Creating and writing changes
outfile = open("umc22ull_drc_optionstest.txt", "w")
outfile.write(start_var + temp_str + "\n" + "\n" + grad_den + "\n" + comchanged + "\n" + end_var)
import re
myfile_txt = open("umc22ull_drc_test.txt", "r")
#myfile = myfile_txt.readlines()
start_var = "start variable \n \n"
end_var = "end variable"
#mystring = "guru99 , education is fun"
# = re.findall(r".*", myfile)
#print(options)
temp_str = ""
grad_den = ""
#save_com = ""
comchanged = ""
for line in myfile_txt.readlines():
pattern = re.compile(r"gradient_density.*")
gradient_density = pattern.finditer(line)
for match in gradient_density:
com = match.group()
#print (com)
#def findandchange(com,comchanged):
# com = re.sub("gradient_density.*", "From:" + "\t" + com, com)
# comchanged = re.sub("From", "To ", com)
# comchanged = re.sub("delta_x = \d*, delta_y = \d*", "delta_x = 0.5, delta_y =0.5 ", comchanged)
# return
if "violation_name_unselect" in line:
temp_str = temp_str + line
elif "gradient_density" in line:
grad_den = re.sub(grad_den, "From:" + "\t" + grad_den, grad_den)
comchanged = re.sub("From", "To ", grad_den)
comchanged = re.sub("delta_x = \d*, delta_y = \d*", "delta_x = 0.5, delta_y =0.5 ", comchanged)
grad_den = grad_den + line
#save_com = save_com + line
# Creating and writing changes
outfile = open("umc22ull_drc_optionstest.txt", "w")
outfile.write(start_var + temp_str + "\n" + "\n" + grad_den + "\n" + comchanged + "\n" + end_var)