Make Link
Make Link
# ./tcbn07_bwph240l(identifier0)_(identifier1)_(identifier2)_130a/
file_path_list = []
file_name_list = []
file_id0_list = []
file_id1_list = []
file_id2_list = []
file_lib_list = []
file_dop_list = []
count = 0
for folders in os.scandir(os.getcwd()):
if folders.is_dir():
cur_lib = None
cur_dop = None
for files in os.scandir(folders.path):
if count > 0 and count % 32 == 0:
print(str(count) + " files done")
file_path_list.append(files.path)
file_name_list.append(files.name)
cur_lib = None
cur_dop = None
with open(files.path, "rt") as lib_src:
# if count > 0 and count % 8 == 0:
# print(str(count + 1) + " files read")
for lines in lib_src:
if cur_lib is None and "library (" in lines:
cur_lib = lines[len("library ("):].partition(")
{")[0].lstrip().rstrip()
if cur_dop is None and
"default_operating_conditions :" in lines:
cur_dop = lines.partition(":")
[2].partition(";")[0].lstrip().rstrip()
if not True in [cur is None for cur in [cur_lib,
cur_dop]]:
count = count + 1
break
for idx, lists in
zip(folders.name[len("tcbn07_bwph240l"):].split("_")[:3] + [cur_lib, cur_dop],
[file_id0_list, file_id1_list, file_id2_list, file_lib_list, file_dop_list]):
lists.append(idx)
print(str(count) + " files done")
# print([len(x) for x in [file_path_list, file_name_list, file_id0_list,
file_id1_list, file_id2_list, file_lib_list, file_dop_list]])
for path, name in zip(file_path_list, file_name_list):
try:
os.symlink(path, os.getcwd() + "/" + name)
except FileExistsError:
pass
digit_length = len(str(len(file_path_list)))
data = sorted(sorted(sorted(sorted(zip(file_id0_list, file_id1_list, file_id2_list,
file_dop_list, file_lib_list, file_name_list), key=lambda x0: x0[3]), key=lambda
x1: x1[2]), key=lambda x3: x3[1][0]), key=lambda x2: x2[0], reverse=True)
with open(os.getcwd() + "/lib_info.csv", "wt") as csv_file:
csv_file.write("No,\tID 0,\tID 1,\tID 2,\tDefault Operating Conditions,\
tLibrary Name,\tFile Name")
csv_file.write("\n")
for z, x in enumerate(data):
csv_file.write(''.join([str(string) + ",\t" for string in
[str(z).zfill(digit_length)] + list(x)])[:-2])
csv_file.write("\n")