def remove_non_used_index_files(dest_archive,src_archive): ls_dest=zip_lsdir(dest_archive) if ls_dest==False: print("File ",ls_dest, "not found") return ls_src=zip_lsdir(src_archive) if ls_src==False: print("File ",ls_src, "not found") for my_file in ls_dest: if my_file.endswith(".inp"): if my_file.startswith("dos"): if ls_src.count(my_file)==0: zip_remove_file(dest_archive,my_file) if my_file.startswith("pulse"): if ls_src.count(my_file)==0: zip_remove_file(dest_archive,my_file) if my_file.startswith("pl"): if ls_src.count(my_file)==0: zip_remove_file(dest_archive,my_file) if my_file.startswith("time_mesh_config"): if ls_src.count(my_file)==0: zip_remove_file(dest_archive,my_file) if my_file.startswith("laser"): if ls_src.count(my_file)==0: zip_remove_file(dest_archive,my_file)
def remove_non_used_index_files(dest_archive, src_archive): ls_dest = zip_lsdir(dest_archive) if ls_dest == False: print("File ", ls_dest, "not found") return ls_src = zip_lsdir(src_archive) if ls_src == False: print("File ", src_archive, "not found") for my_file in ls_dest: if my_file.endswith(".inp"): file_info = get_file_info(my_file) if file_info != False: if file_info.index_file == True: if ls_src.count(my_file) == 0: zip_remove_file(dest_archive, my_file)
def inp_remove_file(file_name): zip_remove_file("sim.gpvdm",file_name)
def device_lib_delete(file_name): archives=find_device_libs() for archive in archives: zip_remove_file(archive,file_name)
def inp_remove_file(file_name, archive="sim.gpvdm"): """Remove a file from an archive""" full_name = default_to_sim_path(file_name) archive_path = os.path.join(os.path.dirname(full_name), archive) zip_remove_file(archive_path, os.path.basename(full_name))
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # ## @package gpvdm_zip # A command line tool to add files to a zip file - not sure what this is used for. # import sys import zipfile from util_zip import zip_remove_file archive=sys.argv[1] infile=sys.argv[2] new_name=sys.argv[3] zip_remove_file(archive,new_name) zf = zipfile.ZipFile(archive, mode='a') try: zf.write(infile, arcname=new_name) finally: zf.close()
def extract_data(path, driver): html = driver.page_source.split("\n") for i in range(0, len(html)): if html[i].count( "OutputDataTable") > 3: #<tr><td class=\'OutputDataTable\'> lines_n = [] lines_n.append("#gpvdm") lines_n.append("#title Refractive index") lines_n.append("#type xy") lines_n.append("#x_mul 1e9") lines_n.append("#y_mul 1.000000") lines_n.append("#x_label Wavelength") lines_n.append("#data_label Refractive index") lines_n.append("#x_units nm") lines_n.append("#data_units m^{-1}") lines_n.append("#logscale_x 0") lines_n.append("#logscale_y 0") lines_n.append("#section_one Materials") lines_n.append("#section_two Refractive index") lines_n.append("#data") lines_alpha = [] lines_alpha.append("#gpvdm") lines_alpha.append("#title Absorption") lines_alpha.append("#type xy") lines_alpha.append("#x_mul 1e9") lines_alpha.append("#y_mul 1.000000") lines_alpha.append("#x_label Wavelength") lines_alpha.append("#data_label Absorption") lines_alpha.append("#x_units nm") lines_alpha.append("#data_units m^{-1}") lines_alpha.append("#logscale_x 0") lines_alpha.append("#logscale_y 0") lines_alpha.append("#section_one Materials") lines_alpha.append("#section_two Absorption") lines_alpha.append("#data") data = html[i] data = data.replace("<td class=\"OutputDataTable\">", " ") data = BeautifulSoup(data, "lxml").text data = data.replace(u"\xa0", "") numbers = data.split() lines = int(len(numbers) / 5) for i in range(0, lines): pos = i * 5 lam = float(numbers[pos]) * 1e-9 n = float(numbers[pos + 1]) alpha = float(numbers[pos + 4]) * 100.0 #print(lam,n,alpha) lines_n.append(str(lam) + " " + str(n)) lines_alpha.append(str(lam) + " " + str(alpha)) #return "hello"#cleantext write_lines_to_archive(path, "alpha.omat", lines_alpha, mode="l", dest="file") write_lines_to_archive(path, "n.omat", lines_n, mode="l", dest="file") zip_remove_file(path, "cost.xlsx") zip_remove_file(path, "n_eq.inp") zip_remove_file(path, "alpha_eq.inp") zip_remove_file(path, "n_gen.omat") zip_remove_file(path, "alpha_gen.omat") return None
def device_lib_delete(file_name, dir_name=""): if dir_name == "": dir_name = get_device_lib_path() archives = glob.glob(os.path.join(dir_name, "*.gpvdm")) for i in range(0, len(archives)): zip_remove_file(archives[i], file_name)
def delete(self): zip_remove_file(self.zip_file_path, self.file_name)
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License v2.0, as published by # the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys import zipfile from util_zip import zip_remove_file archive=sys.argv[1] infile=sys.argv[2] new_name=sys.argv[3] zip_remove_file(archive,new_name) zf = zipfile.ZipFile(archive, mode='a') try: zf.write(infile, arcname=new_name) finally: zf.close()