示例#1
0
def inp_isfile(file_path):

	zip_file_name=os.path.join(os.path.dirname(file_path),"sim.gpvdm")
	return archive_isfile(zip_file_name,os.path.basename(file_path))
示例#2
0
def merge_archives(src_archive,dest_archive,only_over_write):
#	src_dir=os.path.dirname(src_archive)
#	dest_dir=os.path.dirname(dest_archive)
	template_archive=os.path.join(get_inp_file_path(),"sim.gpvdm")

	remove_non_used_index_files(dest_archive,src_archive)

	files=[ "sim.inp", "device.inp", "led.inp","stark.inp" ,"shg.inp"   ,"jv.inp" , "math.inp",  "dump.inp",  "dump_file.inp"  , "light.inp", "server.inp", "light_exp.inp","info.inp","config.inp" ]

	base_file=files[:]

	print(src_archive)
	ls=zip_lsdir(src_archive)
	for i in range(0,len(ls)):
		if inp_issequential_file(ls[i],"dos"):
			files.append(ls[i])
			base_file.append(os.path.join(get_materials_path(),"generic","dos.inp"))

		if inp_issequential_file(ls[i],"pl"):
			files.append(ls[i])
			base_file.append(os.path.join(get_materials_path(),"generic","pl.inp"))

		if inp_issequential_file(ls[i],"pulse"):
			files.append(ls[i])
			base_file.append("pulse0.inp")

		if inp_issequential_file(ls[i],"laser"):
			files.append(ls[i])
			base_file.append("laser0.inp")

	for i in range(0,len(files)):
		print("Importing",files[i],"to",dest_archive,template_archive,base_file[i])
		if only_over_write==False:
			if archive_isfile(dest_archive,files[i])==False:
				if archive_copy_file(dest_archive,files[i],template_archive,base_file[i])==False:
					print("problem copying",template_archive,base_file[i])
				print("made new file",dest_archive,files[i])

		ret=archive_merge_file(dest_archive,src_archive,files[i])
		print("merged",dest_archive,src_archive,files[i],ret)


	files=[ "epitaxy.inp", "fit.inp", "constraints.inp","duplicate.inp", "thermal.inp","mesh_x.inp","mesh_y.inp","mesh_z.inp" ]
	base_file=files[:]

	ls=zip_lsdir(src_archive)
	for i in range(0,len(ls)):

		if inp_issequential_file(ls[i],"time_mesh_config"):
			files.append(ls[i])
			base_file.append("time_mesh_config0.inp")

		if inp_issequential_file(ls[i],"h**o"):
			files.append(ls[i])
			base_file.append("homo0.inp")

		if inp_issequential_file(ls[i],"lumo"):
			files.append(ls[i])
			base_file.append("lumo0.inp")

	for i in range(0,len(files)):
		print("Importing",files[i])
		template_ver=archive_get_file_ver(template_archive,base_file[i])
		src_ver=archive_get_file_ver(src_archive,files[i])
		print(template_ver,src_ver,template_ver==src_ver,template_archive,files[i],src_archive)

		if template_ver!="" and src_ver!="":
			if template_ver==src_ver:
				archive_copy_file(dest_archive,files[i],src_archive,files[i])
				print("complex copy",dest_archive,files[i],src_archive,files[i])
示例#3
0
def merge_archives(src_archive,dest_archive,only_over_write):
	debug=False

	progress_window=progress_class()
	progress_window.show()
	progress_window.start()

	process_events()

#	src_dir=os.path.dirname(src_archive)
#	dest_dir=os.path.dirname(dest_archive)
	dest_path=os.path.dirname(dest_archive)
	template_archive=gpvdm_paths.get_inp_template_path()

	remove_non_used_index_files(dest_archive,src_archive)

	ls=zip_lsdir(src_archive)

	#copy files without checking ver

	for i in range(0,len(ls)):
		info=get_file_info(ls[i])
		if info!=False:
			if info.copy_opp==file_type().JUST_COPY:
				#print(ls[i])
				archive_copy_file(dest_archive,ls[i],src_archive,ls[i],dest=info.dest)

			
			#src_ver=inp_get_file_ver(src_archive,ls[i])

			if info.copy_opp==file_type().CHECK_VER_THEN_COPY:
				template_ver=inp().get_ver(os.path.join(template_archive,info.base_file))
				src_ver=inp_get_file_ver(src_archive,ls[i])

				if template_ver!=False and src_ver!="":
					if template_ver==src_ver:
						archive_copy_file(dest_archive,ls[i],src_archive,ls[i])
						#print("complex copy")

			if info.copy_opp==file_type().MERGE:
				if only_over_write==False:
					if archive_isfile(dest_archive,ls[i])==False:
						if archive_copy_file(dest_archive,ls[i],template_archive,info.base_file)==False:
							print("problem copying",template_archive,info.base_file)
							#if info.base_file=="dump.inp":
							#	sys.exit(0)
						#print("made new file",dest_archive,ls[i])

				ret=archive_merge_file(dest_archive,src_archive,ls[i],ls[i])
		
		progress_window.set_fraction(float(i)/float(len(ls)))
		progress_window.set_text("Importing "+ls[i])
		process_events()

	#if you find a materials directory in the archive try to merge it
	for i in range(0,len(ls)):
		zip_dir_name=ls[i].split("/")
		if zip_dir_name[0]=="materials":
			dest=os.path.join(os.path.dirname(get_materials_path()))
			#print("Try to read",src_archive,ls[i],dest)
			extract_file_from_archive(dest,src_archive,ls[i])

		if zip_dir_name[0]=="sim":
			extract_file_from_archive(dest_path,src_archive,ls[i])

		if zip_dir_name[0]=="calibrate":
			extract_file_from_archive(dest_path,src_archive,ls[i])

	#search for scan directories
	scan_dirs=[]
	for i in range(0,len(ls)):
		if ls[i].endswith("gpvdm_gui_config.inp"):
			scan_dirs.append(os.path.dirname(ls[i]))

	#extract scan directories
	for i in range(0,len(ls)):
		for ii in range(0,len(scan_dirs)):
			if ls[i].startswith(scan_dirs[ii])==True:
				#print("Try to read",src_archive,ls[i])
				extract_file_from_archive(dest_path,src_archive,ls[i])
	print("search",scan_dirs)

	progress_window.stop()
示例#4
0
def inp_isfile(file_path, archive="sim.gpvdm"):
    file_name = default_to_sim_path(file_path)

    zip_file_name = os.path.join(os.path.dirname(file_name), archive)
    return archive_isfile(zip_file_name, os.path.basename(file_name))
示例#5
0
    def isfile(self, file_path, archive="sim.gpvdm"):
        file_name = default_to_sim_path(file_path)

        self.zip_file_name = search_zip_file(file_name, archive)

        return archive_isfile(self.zip_file_name, os.path.basename(file_name))