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)
import os
import re
change_list = ("merge_series(", "merge_parallel(")
myfile = open("cmos12lpplus.compare.rs", "r")
tmp_str = ""
out = ""
found = False
count = 0
com = ""
for line in myfile.readlines():
pattern = re.compile(r"(^[\t\s]*//)") #exclude // average_merge_method","perim"}
comments = pattern.finditer(line)
for match in comments:
com = match.group(1)
if any(token in line for token in change_list):
found = True
tmp_str = ""
count = 0
while line[count] == "\t":
count += 1
r1 = "});"
if found and r1 in line:
found = False
tmp_str = ""
if found and not line.startswith(com):
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"
tmp_str = re.sub('[\t\s]*/\*.*\*/', "", tmp_str) #exclude tolerance line 1683/1715
tmp_str = re.sub("^[\t\s]*\/\*", "\t", tmp_str) #exclude c++ comments
tmp_str = re.sub("\*\/", "", tmp_str) #exclude c++ comments
out += tmp_str
continue
if not found:
out += line
outfile= open("cmos12lpplus.compare.rs_int.rs", "w")
outfile.write(out)
import re
change_list = ("merge_series(", "merge_parallel(")
myfile = open("cmos12lpplus.compare.rs", "r")
tmp_str = ""
out = ""
found = False
count = 0
com = ""
for line in myfile.readlines():
pattern = re.compile(r"(^[\t\s]*//)") #exclude // average_merge_method","perim"}
comments = pattern.finditer(line)
for match in comments:
com = match.group(1)
if any(token in line for token in change_list):
found = True
tmp_str = ""
count = 0
while line[count] == "\t":
count += 1
r1 = "});"
if found and r1 in line:
found = False
tmp_str = ""
if found and not line.startswith(com):
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"
tmp_str = re.sub('[\t\s]*/\*.*\*/', "", tmp_str) #exclude tolerance line 1683/1715
tmp_str = re.sub("^[\t\s]*\/\*", "\t", tmp_str) #exclude c++ comments
tmp_str = re.sub("\*\/", "", tmp_str) #exclude c++ comments
out += tmp_str
continue
if not found:
out += line
outfile= open("cmos12lpplus.compare.rs_int.rs", "w")
outfile.write(out)
def starts_with(text, start):
k = len(start)
p = text[:k]
if p == start:
print("the sring starts with -- {}".format(start))
else:
print("Error --> String did not start with -- {}".format(start))
text = "Adfkadjgjaofkgjoafijhodnhhjkhjskghbjsklgjslkfjagkjrman"
start = "Adfkadjgjaofkgjvo"
starts_with(text, start)
k = len(start)
p = text[:k]
if p == start:
print("the sring starts with -- {}".format(start))
else:
print("Error --> String did not start with -- {}".format(start))
text = "Adfkadjgjaofkgjoafijhodnhhjkhjskghbjsklgjslkfjagkjrman"
start = "Adfkadjgjaofkgjvo"
starts_with(text, start)
en asacs funkcian gri vor 2 string tam ases erkrord@ arajini mej parunakvuma te che