def gpvdm_clone(dest,copy_dirs,materials=["all"]): src_dir=get_inp_file_path() src_archive=os.path.join(src_dir,"sim.gpvdm") dest_archive=os.path.join(dest,"sim.gpvdm") print(src_archive) files=zip_lsdir(src_archive) lines=[] archive_make_empty(dest_archive) for i in range(0,len(files)): if files[i].endswith(".inp"): read_lines_from_archive(lines,src_archive,files[i]) write_lines_to_archive(dest_archive,files[i],lines) if copy_dirs==True: if os.path.isdir(os.path.join(src_dir,"plot")): shutil.copytree(os.path.join(src_dir,"plot"), os.path.join(dest,"plot")) if os.path.isdir(os.path.join(src_dir,"exp")): shutil.copytree(os.path.join(src_dir,"exp"), os.path.join(dest,"exp")) if os.path.isdir(os.path.join(src_dir,"materials")): shutil.copytree(os.path.join(src_dir,"materials"), os.path.join(dest,"materials")) clone_materials(dest,materials)
def copy_check_ver(dest_archive,src_archive,file_name,only_over_write,clever): if dest_archive==src_archive: print "I can't opperate on the same .opvdm file" return #remove the dest file if both exist ready to copy do_copy=True src_ver="" dest_ver="" orig_exists=False dest_exists=False src_lines=[] dest_lines=[] orig_exists=read_lines_from_archive(src_lines,src_archive,file_name) if orig_exists==True: src_ver=inp_search_token_value(src_lines, "#ver") else: print "Warning: ",src_archive,file_name," no origonal file to copy" return #read in the dest file where ever it may be dest_exists=read_lines_from_archive(dest_lines,dest_archive,file_name) if dest_exists==True: dest_ver=inp_search_token_value(dest_lines, "#ver") #if we are only over writing only copy if dest file exists if (only_over_write==True): if dest_exists==True: do_copy=True else: print "Warning: ", file_name," - only exists in the source" do_copy=False return if dest_exists==True: if src_ver!=dest_ver: print "Warning: Verstion numbers do not match for files",dest_archive,src_archive,file_name print "src_ver=",src_ver,"dest ver=",dest_ver if clever==False: print "Not copying that file you will have to deal that with by hand" return if clever==True and dest_exists==True: errors=inp_merge(dest_lines,src_lines) if len(errors)!=0: print "File ",file_name,errors else: dest_lines=src_lines if (do_copy==True): write_lines_to_archive(dest_archive,file_name,dest_lines)
def gpvdm_clone(path,src_archive="",copy_dirs=False,dest="archive"): if src_archive=="": src_dir=get_inp_file_path() src_archive=os.path.join(src_dir,"base.gpvdm") dest_archive=os.path.join(path,"sim.gpvdm") files=zip_lsdir(src_archive) lines=[] archive_make_empty(dest_archive) for i in range(0,len(files)): if files[i].endswith(".inp"): lines=read_lines_from_archive(src_archive,files[i]) write_lines_to_archive(dest_archive,files[i],lines,dest=dest) if copy_dirs==True: if os.path.isdir(os.path.join(src_dir,"plot")): shutil.copytree(os.path.join(src_dir,"plot"), os.path.join(path,"plot")) if os.path.isdir(os.path.join(src_dir,"exp")): shutil.copytree(os.path.join(src_dir,"exp"), os.path.join(path,"exp")) #if os.path.isdir(os.path.join(src_dir,"materials")): # shutil.copytree(os.path.join(src_dir,"materials"), os.path.join(path,"materials")) #clone_materials(path) clone_spectras(path)
def gpvdm_clone(path, src_archive="", copy_dirs=False, dest="archive"): #print("Cloning from",get_inp_file_path()) if src_archive == "": src_dir = get_inp_file_path() src_archive = os.path.join(src_dir, "base.gpvdm") dest_archive = os.path.join(path, "sim.gpvdm") files = zip_lsdir(src_archive) lines = [] archive_make_empty(dest_archive) for i in range(0, len(files)): if files[i].endswith(".inp"): lines = read_lines_from_archive(src_archive, files[i], mode="b") write_lines_to_archive(dest_archive, files[i], lines, dest=dest, mode="b") #if (files[i]=="dos0.inp"): # asdsa if copy_dirs == True: if os.path.isdir(os.path.join(src_dir, "plot")): shutil.copytree(os.path.join(src_dir, "plot"), os.path.join(path, "plot")) if os.path.isdir(os.path.join(src_dir, "exp")): shutil.copytree(os.path.join(src_dir, "exp"), os.path.join(path, "exp"))
def inp_get_file_ver(archive, file_name): lines = [] lines = read_lines_from_archive(archive, file_name) if lines != False: ver = inp_search_token_value(lines, "#ver") else: return "" return ver
def load(self,file_path,archive="sim.gpvdm",mode="l"): self.set_file_name(file_path,archive=archive,mode=mode) if self.file_name!=None: self.lines=read_lines_from_archive(self.zip_file_path,self.file_name,mode=mode) if self.lines==False: return False return self
def inp_load_file(file_path,archive="sim.gpvdm",mode="l"): """load file""" if file_path==None: return False file_name=default_to_sim_path(file_path) #print(">",file_name) zip_file_path=search_zip_file(file_name,archive)#os.path.join(os.path.dirname(file_name),archive) #print(">>",zip_file_path) file_name=os.path.basename(file_name) ret=read_lines_from_archive(zip_file_path,file_name,mode=mode) return ret
def inp_update_token_array(file_path, token, replace): lines = [] base_name = os.path.basename(file_path) path = os.path.dirname(file_path) zip_file_name = os.path.join(path, "sim.gpvdm") lines = read_lines_from_archive(zip_file_name, os.path.basename(file_path)) lines = inp_replace_token_array(lines, token, replace) write_lines_to_archive(zip_file_name, base_name, lines)
def inp_update_token_value(file_path, token, replace,line_number): lines=[] if token=="#Tll": inp_update_token_value("thermal.inp", "#Tlr", replace,1) files=inp_lsdir(file_path) for i in range(0,len(files)): if files[i].startswith("dos") and files[i].endswith(".inp"): inp_update_token_value(files[i], "#Tstart", replace,1) try: upper_temp=str(float(replace)+5) except: upper_temp="300.0" inp_update_token_value(files[i], "#Tstop", upper_temp,1) path=os.path.dirname(file_path) zip_file_name=os.path.join(path,"sim.gpvdm") read_lines_from_archive(lines,zip_file_name,os.path.basename(file_path)) new_lines=inp_replace_multi_line_token(lines,token,replace) if os.path.isfile(file_path): fh, abs_path = mkstemp() dump='\n'.join(new_lines) dump=dump.rstrip("\n") dump=dump.encode('ascii') f=open(abs_path, mode='wb') written = f.write(dump) f.close() os.close(fh) shutil.move(abs_path, file_path) else: replace_file_in_zip_archive(zip_file_name,os.path.basename(file_path),new_lines)
def inp_update_token_value(file_path, token, replace,line_number): lines=[] if token=="#Tll": inp_update_token_value("thermal.inp", "#Tlr", replace,1) inp_update_token_value("dos0.inp", "#Tstart", replace,1) try: upper_temp=str(float(replace)+5) except: upper_temp="300.0" inp_update_token_value("dos0.inp", "#Tstop", upper_temp,1) path=os.path.dirname(file_path) zip_file_name=os.path.join(path,"sim.opvdm") read_lines_from_archive(lines,zip_file_name,os.path.basename(file_path)) for i in range(0, len(lines)): if lines[i]==token: lines[i+line_number]=replace break if os.path.isfile(file_path): fh, abs_path = mkstemp() dump='\n'.join(lines) #for item in lines: # dump=dump+item+"\n" dump=dump.rstrip("\n") f=open(abs_path, mode='wb') lines = f.write(dump) f.close() os.close(fh) shutil.move(abs_path, file_path) else: replace_file_in_zip_archive(zip_file_name,os.path.basename(file_path),lines)
def ver_check_compatibility(file_name): lines=[] core="" lines=read_lines_from_archive(file_name,"ver.inp") if lines!=False: core=inp_search_token_value(lines,"#core") if core==ver_core(): return True else: return False return False
def ver_check_compatibility(file_name): lines=[] core="" mat="" if read_lines_from_archive(lines,file_name,"ver.inp")==True: core=lines[1] if core==ver_core(): return True else: return False return False
def create_model(self): self.tab.clear() self.tab.setColumnCount(3) self.tab.setSelectionBehavior(QAbstractItemView.SelectRows) self.tab.setHorizontalHeaderLabels([_("File name"), _("Device type"), _("Description")]) self.tab.setColumnWidth(0, 150); self.tab.setColumnWidth(2, 500); self.tab.verticalHeader().setDefaultSectionSize(80); files=glob.glob(os.path.join(get_device_lib_path(),"*.gpvdm")) for i in range(0,len(files)): print("working on",files[i],zip_lsdir(files[i])) lines=[] if read_lines_from_archive(lines,files[i],"info.inp")==True: tab_add(self.tab,[os.path.basename(files[i]), " ".join(inp_search_token_value_multiline(lines,"#info_device_type"))," ".join(inp_search_token_value_multiline(lines,"#info_description"))])
def create_model(self): self.tab.clear() self.tab.setColumnCount(3) self.tab.setSelectionBehavior(QAbstractItemView.SelectRows) self.tab.setHorizontalHeaderLabels([_("File name"), _("Device type"), _("Description")]) self.tab.setColumnWidth(0, 150); self.tab.setColumnWidth(2, 500); self.tab.verticalHeader().setDefaultSectionSize(80); files=glob.glob(os.path.join(get_device_lib_path(),"*.gpvdm")) for i in range(0,len(files)): print("working on",files[i],zip_lsdir(files[i])) lines=read_lines_from_archive(lines,files[i],"info.inp") if lines!=False: tab_add(self.tab,[os.path.basename(files[i]), " ".join(inp_search_token_value_multiline(lines,"#info_device_type"))," ".join(inp_search_token_value_multiline(lines,"#info_description"))])
def get_vectors(path, dir_name, file_name, dolog=False, div=1.0, fabs=False, do_norm=False): base = os.path.join(path, dir_name) lines = read_lines_from_archive(os.path.join(base, "sim.gpvdm"), file_name) if lines == False: print("\n\nbase>>", base, "\n\n") return False if lines[0].count("nan") == 0 and lines[0].count("inf") == 0: ret = lines[0].split() if do_norm == True: mi = 1e6 for i in range(0, len(ret)): if float(ret[i]) < mi: mi = float(ret[i]) div = mi n = [] for i in range(0, len(ret)): #print(ret[i]) r = float(ret[i]) / div if fabs == True: r = abs(r) if dolog == True: #print(r) if r != 0.0: r = log10(r) else: r = 0.0 n.append(r) #print(n) s = "" for ii in range(0, len(n)): s = s + '{:e}'.format(float(n[ii])) + " " return s
def is_mat_file(file_path): if os.path.isdir(file_path)==True: gpvdm_file_type=inp_get_token_value(os.path.join(file_path,"mat.inp"), "#gpvdm_file_type") if gpvdm_file_type=="mat": return True return False zfile=file_path if os.path.isfile(zfile)==False: zfile=zfile+".zip" if os.path.isfile(zfile)==True: lines=read_lines_from_archive(zfile,"mat.inp",mode="l") if lines!=False: gpvdm_file_type=inp_search_token_value(lines, "#gpvdm_file_type") if gpvdm_file_type=="mat": return True return False
def clone_materials(dest,materials=["all"]): src_dir=os.path.join(get_materials_path()) dest_dir=os.path.join(dest,"materials") if os.path.isdir(dest_dir)==False: os.mkdir(dest_dir) files=os.listdir(src_dir) for i in range(0,len(files)): src_file=os.path.join(src_dir,files[i]) dest_file=os.path.join(dest_dir,files[i]) if files[i].endswith(".spectra"): copyfile(src_file, dest_file) if os.path.isdir(src_file)==True: lines=[] mat_sub_path=os.path.join("materials",files[i],"mat.inp") if read_lines_from_archive(lines,os.path.join(get_inp_file_path(),"sim.gpvdm"),mat_sub_path)==True: do_copy=False mat_type=inp_search_token_value(lines, "#material_type") if mat_type!=False: if materials.count("all")!=0: do_copy=True if materials.count(mat_type)!=0: do_copy=True if do_copy==True: print("copy",dest_file) if os.path.isdir(dest_file)==False: os.mkdir(dest_file) for copy_file in ["alpha_eq.inp","alpha.omat","dos.inp","info.txt","n_eq.inp","n.omat","alpha_gen.omat","cost.xlsx","fit.inp","mat.inp","n_gen.omat","pl.inp"]: src_mat_file=os.path.join(src_file,copy_file) if os.path.isfile(src_mat_file)==True: copyfile(src_mat_file,os.path.join(dest_file,copy_file)) else: print("not copy",dest_file)
def __create_model(self): # create list store model = gtk.ListStore(str, str, str) # add items files = glob.glob(os.path.join(get_device_lib_path(), "*.opvdm")) for i in range(0, len(files)): print "working on", files[i], zip_lsdir(files[i]) iter = model.append() lines = [] if read_lines_from_archive(lines, files[i], "info.inp") == True: print lines model.set( iter, COLUMN_FILENAME, os.path.basename(files[i]), COLUMN_TYPE, " ".join(inp_search_token_value_multiline(lines, "#info_device_type")), COLUMN_INFO, " ".join(inp_search_token_value_multiline(lines, "#info_description")), ) return model
def get_vectors_binary(path, dir_name): base = os.path.join(path, dir_name) lines = read_lines_from_archive(os.path.join(base, "sim.gpvdm"), "measure_output.dat") ret = lines[0].split() n = [] names = [ "#mueffe", "#mueffh", "#Etrape", "#Etraph", "#Ntrape", "#Ntraph", "#srhsigman_e", "#srhsigmap_e", "#srhsigman_h", "#srhsigmap_h", "#Rshunt", "#Rcontact", "#jv_pmax_tau", "#jv_pmax_mue", "#jv_pmax_muh" ] s = "" for i in range(0, len(ret)): r = int(float(ret[i])) s = s + names[i] + "_bin\n" if r == 1: s = s + "1 0\n" else: s = s + "0 1\n" return s
def inp_load_file(lines,file_path): zip_file_path=os.path.join(os.path.dirname(file_path),"sim.gpvdm") file_name=os.path.basename(file_path) return read_lines_from_archive(lines,zip_file_path,file_name)
def fill_store(self): #partitions = #for p in partitions: # print(p.mountpoint, psutil.disk_usage(p.mountpoint).percent) #print(expanduser("~")) self.file_list=[] #print(self.path) if self.path=="/gpvdmroot": itm=file_store() itm.file_name="simulation_dir" itm.icon="si" itm.display_name=_("Simulation") self.file_list.append(itm) itm=file_store() itm.file_name="home_dir" itm.icon="user-home" itm.display_name=_("Home") self.file_list.append(itm) if get_desktop_path()!=False: itm=file_store() itm.file_name="desktop_dir" itm.icon="desktop" itm.display_name=_("Desktop") self.file_list.append(itm) if get_downloads_path()!=False: itm=file_store() itm.file_name="downloads_dir" itm.icon="folder-download" itm.display_name=_("Downloads") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_configure" itm.icon="cog" itm.display_name=_("Configure") self.file_list.append(itm) for p in psutil.disk_partitions(): name=p.mountpoint if running_on_linux()==True: name=os.path.basename(name) if name=="": name="/" itm=file_store() itm.file_name="mount_point::::"+p.mountpoint itm.icon="drive-harddisk" itm.display_name=name self.file_list.append(itm) elif self.path=="/gpvdmroot/gpvdm_configure": itm=file_store() itm.file_name="gpvdm_cluster_config" itm.icon="server" itm.display_name=_("Cluster") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_language_config" itm.icon="internet-chat" itm.display_name=_("Language") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_solver_config" itm.icon="accessories-calculator" itm.display_name=_("Solver") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_led_config" itm.icon="oled" itm.display_name=_("LED") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_dump_config" itm.icon="hdd_custom" itm.display_name=_("Output files") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_gui_config" itm.icon="applications-interfacedesign" itm.display_name=_("GUI configuration") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_thermal_config" itm.icon="thermal" itm.display_name=_("Thermal") self.file_list.append(itm) itm=file_store() itm.file_name="gpvdm_server_config" itm.icon="cpu" itm.display_name=_("Server") self.file_list.append(itm) else: path=self.path if os.path.isdir(path)==False: error_dlg(self,_("The directory is gone, so I can't open it. Did you delete it?")+" "+path) return else: all_files=os.listdir(path) all_files.sort() for fl in all_files: #print(fl) file_name=os.path.join(path, fl) itm=file_store() if is_mat_file(file_name)==True: if fl.endswith(".zip"): fl=fl[:-4] itm.file_name=fl itm.icon="organic_material" #if it is a directory if os.path.isdir(file_name): gpvdm_file_type=inp_get_token_value(os.path.join(file_name,"mat.inp"), "#gpvdm_file_type") if gpvdm_file_type=="spectra": itm.file_name=fl itm.icon="spectra" else: show_dir=True if os.path.isfile(os.path.join(file_name,"gpvdm_gui_config.inp"))==True: show_dir=False if show_dir==True: itm.file_name=fl itm.icon="folder" else: #append=False ext=os.path.splitext(file_name) if len(ext)>1: ext=ext[1].lower() else: ext="" if (ext==".dat"): read_ok=False try: f = open(file_name, 'rb') text = f.readline() f.close() read_ok=True except: pass if read_ok==True: if len(text)>0: if text[len(text)-1]==10: text=text[:-1] if text==b"#gpvdm": itm.file_name=fl itm.icon="dat_file" elif (ext==".inp") and self.show_inp_files==True: itm.file_name=fl itm.icon="text-x-generic" elif (ext==".omat"): itm.file_name=fl itm.icon="omat" elif os.path.basename(file_name)=="sim_info.dat": itm.file_name=fl itm.icon="info" elif file_name.endswith("default.gpvdm")==False and file_name.endswith(".gpvdm"): lines=[] lines=inp_load_file("info.inp",archive=file_name) if lines!=False: itm.file_name=fl itm.display_name=inp_get_token_value_from_list(lines, "#info_name")+" ("+fl+")" icon_name=inp_get_token_value_from_list(lines, "#info_icon") itm.icon=icon_name itm.hidden=str2bool(inp_get_token_value_from_list(lines, "#info_hidden")) a=zip_lsdir(file_name,sub_dir="fs/") #,zf=None,sub_dir=None if len(a)!=0: for fname in a: lines=ret=read_lines_from_archive(file_name,"fs/"+fname) if lines!=False: web_link=inp_get_token_value_from_list(lines, "#web_link") name=inp_get_token_value_from_list(lines, "#name") sub_itm=file_store() sub_itm.icon="internet-web-browser" sub_itm.display_name=name sub_itm.file_name=web_link sub_itm.hidden=False self.file_list.append(sub_itm) if itm.icon=="": if icon_get(ext)!=False: itm.icon=ext itm.file_name=fl else: itm.icon="misc" itm.file_name=fl if itm.display_name=="": itm.display_name=itm.file_name if file_name.endswith("sim.gpvdm")==False: self.file_list.append(itm) for i in range(0,len(self.file_list)): if self.file_list[i].file_name=="p3htpcbm.gpvdm": self.file_list.insert(0, self.file_list.pop(i)) break self.paint()
def fill_store(self): self.file_list = [] if os.path.isdir(self.path) == False: error_dlg( self, _("The directory is gone, so I can't open it. Did you delete it?" ) + " " + self.path) return all_files = os.listdir(self.path) #all_files.sort() for fl in all_files: file_name = os.path.join(self.path, fl) itm = file_store() #if it is a directory if os.path.isdir(file_name): gpvdm_file_type = inp_get_token_value( os.path.join(file_name, "mat.inp"), "#gpvdm_file_type") if gpvdm_file_type == "spectra": itm.file_name = fl itm.icon = "spectra" elif gpvdm_file_type == "mat": itm.file_name = fl itm.icon = "organic_material" else: show_dir = True if os.path.isfile( os.path.join(file_name, "gpvdm_gui_config.inp")) == True: show_dir = False if show_dir == True: itm.file_name = fl itm.icon = "folder" else: #append=False if (file_name.endswith(".dat") == True): f = open(file_name, 'rb') text = f.readline() f.close() #text=text.encode('utf-8').strip() #print(text) #text=text.rstrip() if len(text) > 0: if text[len(text) - 1] == 10: text = text[:-1] if text == b"#gpvdm": itm.file_name = fl itm.icon = "dat_file" if (file_name.endswith(".inp") == True) and self.show_inp_files == True: itm.file_name = fl itm.icon = "text-x-generic" if (file_name.endswith(".omat") == True): itm.file_name = fl itm.icon = "omat" if file_name.endswith(".pdf") == True: itm.file_name = fl itm.icon = "pdf" if file_name.endswith(".jpg") == True: itm.file_name = fl itm.icon = "image-x-generic" if os.path.basename(file_name) == "sim_info.dat": itm.file_name = fl itm.icon = "info" if file_name.endswith( "default.gpvdm") == False and file_name.endswith( ".gpvdm"): lines = [] lines = inp_load_file("info.inp", archive=file_name) if lines != False: itm.file_name = fl itm.display_name = inp_get_token_value_from_list( lines, "#info_name") + " (" + fl + ")" icon_name = inp_get_token_value_from_list( lines, "#info_icon") itm.icon = icon_name itm.hidden = str2bool( inp_get_token_value_from_list( lines, "#info_hidden")) a = zip_lsdir(file_name, sub_dir="fs/") #,zf=None,sub_dir=None if len(a) != 0: for fname in a: lines = ret = read_lines_from_archive( file_name, "fs/" + fname) if lines != False: web_link = inp_get_token_value_from_list( lines, "#web_link") name = inp_get_token_value_from_list( lines, "#name") sub_itm = file_store() sub_itm.icon = "internet-web-browser" sub_itm.display_name = name sub_itm.file_name = web_link sub_itm.hidden = False self.file_list.append(sub_itm) if itm.display_name == "": itm.display_name = itm.file_name self.file_list.append(itm) for i in range(0, len(self.file_list)): if self.file_list[i].file_name == "p3htpcbm.gpvdm": self.file_list.insert(0, self.file_list.pop(i)) break self.paint()
def fill_store(self): self.file_list = [] path = self.path all_files = self.listdir() #all_files.sort() if path.endswith("dynamic") == True: self.set_list_view() else: self.set_grid_view() for itm in all_files: #print(fl) #if it is a directory file_name = os.path.join(path, itm.file_name) if itm.isdir == True: if itm.type == "spectra": itm.icon = "spectra" elif itm.type == "shape": itm.icon = "shape" elif itm.type == "snapshots": itm.icon = "cover_flow" elif itm.type == "light": itm.icon = "optics2" elif itm.type == "material": itm.icon = "organic_material" elif itm.type == "emission": itm.icon = "emission" elif itm.type == "backup_main": itm.icon = "backup" elif itm.type == "multi_plot_dir": itm.icon = "multi_plot_dir" elif itm.type == "backup": itm.icon = "backup" elif itm.type == "scan_dir": itm.icon = "scan" elif itm.type == "parameter_dir": itm.icon = "star" elif itm.type == "cache": itm.hidden = True else: itm.icon = "folder" else: #append=False ext = os.path.splitext(file_name) if len(ext) > 1: ext = ext[1].lower() else: ext = "" if (ext == ".dat"): text = peek_data(file_name) if itm.file_name in [ "theta_small_x.dat", "theta_small_z.dat", "theta_Y.dat", "theta_small_y.dat", "theta_X.dat", "theta_Z.dat", "theta_RGB.dat" ]: itm.icon = "color" elif text.startswith(b"#multiplot"): itm.icon = "multiplot" elif str(text).count("#type poly") > 0: itm.icon = "vector" elif str(text).count("#gobj") > 0: itm.icon = "vector" elif text.startswith(b"#"): itm.icon = "dat_file" else: itm.hidden = True if (ext == ".chk"): itm.hidden = True elif (ext == ".inp"): if self.show_inp_files == True: itm.icon = "text-x-generic" else: itm.hidden = True elif (ext == ".gmat"): itm.icon = "gmat" elif os.path.basename(file_name) == "sim_info.dat": itm.icon = "info" elif file_name.endswith( "default.gpvdm") == False and file_name.endswith( ".gpvdm"): text = peek_data(file_name) if text.startswith(b"gpvdmenc"): itm.hidden = True itm.icon = "sim_lock" else: lines = [] lines = inp_load_file("info.inp", archive=file_name) if lines != False: itm.display_name = inp_get_token_value_from_list( lines, "#info_name") icon_name = inp_get_token_value_from_list( lines, "#info_icon") itm.icon = icon_name itm.hidden = str2bool( inp_get_token_value_from_list( lines, "#info_hidden")) a = zip_lsdir( file_name, sub_dir="fs/") #,zf=None,sub_dir=None if len(a) != 0: for fname in a: lines = ret = read_lines_from_archive( file_name, "fs/" + fname) if lines != False: web_link = inp_get_token_value_from_list( lines, "#web_link") name = inp_get_token_value_from_list( lines, "#name") sub_itm = file_store() sub_itm.icon = "internet-web-browser" sub_itm.display_name = name sub_itm.file_name = web_link sub_itm.hidden = False self.file_list.append(sub_itm) if itm.icon == "": if icon_get(ext) != False: itm.icon = ext else: itm.icon = "misc" if itm.display_name == "": itm.display_name = itm.file_name if len(self.show_only) != 0: if itm.type not in self.show_only: itm.hidden = True self.file_list.append(itm) for i in range(0, len(self.file_list)): if self.file_list[i].file_name == "p3htpcbm.gpvdm": self.file_list.insert(0, self.file_list.pop(i)) if self.file_list[i].file_name == "perovskite.gpvdm": self.file_list.insert(1, self.file_list.pop(i)) if self.file_list[i].file_name == "ofet.gpvdm": self.file_list.insert(2, self.file_list.pop(i)) if self.file_list[i].file_name == "oled.gpvdm": self.file_list.insert(3, self.file_list.pop(i)) self.paint()