def update(self,config_file): self.config_file=config_file self.sim_mode.blockSignals(True) self.sim_mode.clear() lines=[] files=inp_lsdir("sim.gpvdm") if files!=False: for i in range(0,len(files)): if files[i].endswith(".inp"): lines=inp_load_file(files[i]) value=inp_search_token_value(lines, "#laser_name") if value!=False: value=value.rstrip() self.sim_mode.addItem(value) token=inp_get_token_value(self.config_file, "#pump_laser") all_items = [self.sim_mode.itemText(i) for i in range(self.sim_mode.count())] for i in range(0,len(all_items)): if all_items[i] == token: self.sim_mode.setCurrentIndex(i) found=True self.sim_mode.blockSignals(False)
def clean_unused_files(self): files=inp_lsdir("sim.gpvdm") tab=self.get_all_electrical_files() for i in range(0,len(files)): disk_file=files[i] #dos if is_numbered_file(disk_file,"dos")==True: if disk_file not in tab: inp_remove_file(disk_file) #electrical if is_numbered_file(disk_file,"electrical")==True: if disk_file not in tab: inp_remove_file(disk_file) #pl if is_numbered_file(disk_file,"pl")==True: if disk_file not in tab: inp_remove_file(disk_file) #shape files if is_numbered_file(disk_file,"shape")==True: if disk_file not in tab: inp_remove_file(disk_file) if is_numbered_file(disk_file,"lumo")==True: if disk_file not in tab: inp_remove_file(disk_file) #h**o files if is_numbered_file(disk_file,"h**o")==True: if disk_file not in tab: inp_remove_file(disk_file)
def update(self): self.sim_mode.get_model().clear() lines=[] self.store_list=[] files=inp_lsdir() if files!=False: for i in range(0,len(files)): if files[i].endswith(".inp"): inp_load_file(lines,files[i]) value=inp_search_token_value(lines, "#sim_menu_name") if value!=False: if value.count("@")==1: value=value.rstrip() command,module=value.split("@") self.sim_mode.append_text(command) self.store_list.append(store(command,module)) token=inp_get_token_value("sim.inp", "#simmode") command,module=token.split("@") liststore = self.sim_mode.get_model() for i in xrange(len(liststore)): if liststore[i][0] == command: self.sim_mode.set_active(i)
def clean_dos_files(self): files=inp_lsdir() tab=[] for i in range(0,self.tab.rowCount()): tab.append(str(tab_get_value(self.tab,i, 4))+".inp") for i in range(0,len(files)): if files[i].startswith("dos") and files[i].endswith(".inp"): disk_file=files[i] if disk_file not in tab: inp_remove_file(disk_file)
def clean_dos_files(self): files = inp_lsdir("sim.gpvdm") tab = [] for i in range(0, self.tab.rowCount()): tab.append(str(tab_get_value(self.tab, i, 4)) + ".inp") for i in range(0, len(files)): if files[i].startswith("dos") and files[i].endswith(".inp"): disk_file = files[i] if disk_file not in tab: inp_remove_file(disk_file)
def update(self): self.sim_mode.clear() lines = [] self.store_list = [] temp = [] files = inp_lsdir("sim.gpvdm") if files != False: for i in range(0, len(files)): if files[i].endswith(".inp") and files[i].count("/") == 0: lines = inp_load_file(files[i]) value = inp_search_token_value(lines, "#sim_menu_name") if value != False: if value.count("@") == 1: temp.append(value) temp.sort() for i in range(0, len(temp)): value = temp[i].rstrip() command, module = value.split("@") self.sim_mode.addItem(command) a = store(command, module) self.store_list.append(a) print(os.getcwd()) token = inp_get_token_value("sim.inp", "#simmode") print(token) if token.count("@") != 0: command, module = token.split("@") else: command = token found = False all_items = [ self.sim_mode.itemText(i) for i in range(self.sim_mode.count()) ] for i in range(0, len(all_items)): if all_items[i] == command: self.sim_mode.setCurrentIndex(i) found = True #if there is no known mode, just set it to jv mode if found == False: for i in range(0, len(self.store_list)): if self.store_list[i].token == "jv": self.sim_mode.setCurrentIndex(i) inp_update_token_value( os.path.join(get_sim_path(), "sim.inp"), "#simmode", "jv@jv") break
def update(self): self.sim_mode.clear() lines=[] self.store_list=[] files=inp_lsdir() if files!=False: for i in range(0,len(files)): if files[i].endswith(".inp"): inp_load_file(lines,files[i]) value=inp_search_token_value(lines, "#sim_menu_name") if value!=False: if value.count("@")==1: value=value.rstrip() command,module=value.split("@") self.sim_mode.addItem(command) a=store(command,module) self.store_list.append(a) token=inp_get_token_value("sim.inp", "#simmode") if token.count("@")!=0: command,module=token.split("@") else: command=token found=False all_items = [self.sim_mode.itemText(i) for i in range(self.sim_mode.count())] for i in range(0,len(all_items)): if all_items[i] == command: self.sim_mode.setCurrentIndex(i) found=True #if there is no known mode, just set it to jv mode if found==False: for i in range(0,len(self.store_list)): if self.store_list[i].token=="jv": self.sim_mode.activated(i) inp_update_token_value("sim.inp", "#simmode", "jv@jv",1) break
def update(self): self.sim_mode.clear() lines=[] files=inp_lsdir() if files!=False: for i in range(0,len(files)): if files[i].endswith(".inp"): inp_load_file(lines,files[i]) value=inp_search_token_value(lines, "#laser_name") if value!=False: value=value.rstrip() self.sim_mode.addItem(value) token=inp_get_token_value(self.config_file, "#pump_laser") all_items = [self.sim_mode.itemText(i) for i in range(self.sim_mode.count())] for i in range(0,len(all_items)): if all_items[i] == token: self.sim_mode.setCurrentIndex(i) found=True
def cat_dir(): my_token_lib = tokens() banned = ["dump_file.inp"] files = inp_lsdir(os.path.join(get_sim_path(), "sim.gpvdm")) h = html_gen() h.add_h1(_("Files within sim.gpvdm")) for file_name in files: if file_name.endswith(".inp") == True and file_name not in banned: h.add_collapsible(file_name) h.add_div("content") f = inp() f.load(os.path.join(get_sim_path(), file_name)) tab = [] while (1): token, vals = f.get_next_token_array() if token == False: break result = my_token_lib.find(token) if result != False: text_info = result.info unit = result.units else: text_info = "" unit = "" if len(vals) > 0: val = vals[0] else: val = "" tab.append([token, text_info, val, unit]) h.add_tab(tab) h.end_div() h.gen_list() h.save(os.path.join(get_sim_path(), "index.html"))
def update(self): self.clear_toolbar() lines = [] newton_solver = newton_solver_get_type() files = inp_lsdir("sim.gpvdm") if files != False: for i in range(0, len(files)): if files[i].endswith(".inp") and files[i].count("/") == 0: lines = inp_load_file(files[i]) value = inp_search_token_value(lines, "#sim_menu_name") if value != False: if value.count("@") == 1: value = value.rstrip() command, module = value.split("@") hide = False if newton_solver == "none": if module == "jv": hide = True if module == "pulse": hide = True if module == "suns_jsc": hide = True if module == "sun_voc": hide = True if module == "is": hide = True if command not in self.dont_show and hide == False: a = gQAction(self, files[i], command, module) a.setCheckable(True) a.selected.connect(self.callback_click) self.actions.append(a) #temp.append(value) #temp.sort() token = inp_get_token_value("sim.inp", "#simmode") if token == None: return #print(os.getcwd(),"!!!!!!!!!!!!!") #sys.exit(0) if token.count("@") != 0: command, module = token.split("@") else: command = token found = False self.build = [] added = 0 #This is to stop || appearing in the menu for o in self.order: if o == "|": if added != 0: self.build.append("|") added = 0 else: for i in range(0, len(self.actions)): if self.actions[i].command.lower().startswith( o.lower()) == True: if self.actions[i].done == False: self.build.append(self.actions[i]) self.actions[i].done = True added = added + 1 for i in range(0, len(self.actions)): if self.actions[i].done == False: #print(self.actions[i].command) self.build.append(self.actions[i]) self.actions = self.build self.blockSignals(True) for a in self.actions: #self.sim_mode.addItem(command) if type(a) == gQAction: self.addAction(a) if command.lower() == a.command.lower(): self.callback_click(a, disable_help=True) found = True else: self.addSeparator() #if there is no known mode, just set it to jv mode if found == False: for a in self.actions: if a.command == "jv": self.callback_click(a, disable_help=True) inp_update_token_value( os.path.join(get_sim_path(), "sim.inp"), "#simmode", "jv@jv") break self.blockSignals(False)