当前位置: 首页>>代码示例>>Python>>正文


Python General.validate_String方法代码示例

本文整理汇总了Python中General.validate_String方法的典型用法代码示例。如果您正苦于以下问题:Python General.validate_String方法的具体用法?Python General.validate_String怎么用?Python General.validate_String使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在General的用法示例。


在下文中一共展示了General.validate_String方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Btn_Create_Clicked

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
 def Btn_Create_Clicked(self):
     
     name = self.ProjName.get().strip()
     if name != '':
         
         if General.validate_String(name, '', False, True, False):
             print('  ERROR: The name \'' + name + '\' is invalid. Try again.')
             return
         
         Project_Dir = os.path.join(self.ActualDirPath,name)
         
         if not os.path.isdir(Project_Dir):
             try:
                 os.makedirs(Project_Dir)
             except OSError:
                 print('  ERROR: Could not create the project: \'' + name + '\' under that directory.')
                 return 
                 
             self.Update_ProjectFile(Project_Dir, name)
             
             self.top.Project_Dir = Project_Dir
             self.top.ProjectName = name       
             
             self.Quit()
             self.After_Quit()
             
             print('  Successfully created the project: \'' + name + '\'')
             print('  The project was loaded by default.')
 
         else:
             print('  The project: \'' + name + '\' already exists.')
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:33,代码来源:NewProject.py

示例2: Save_SessionFile

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Save_SessionFile(self, SaveFile):

        if len(SaveFile) > 0:
            
            SaveFile = os.path.normpath(SaveFile)
            
            if General.validate_String(SaveFile, '.nrgfs', True, True, False):
                self.DisplayMessage("  ERROR: Could not save the file because you entered an invalid name.", 2)
                return
            
            if self.ValidateSaveProject(SaveFile, 'Session'):
                self.DisplayMessage("  ERROR: The file can only be saved at its default location", 2)
                return
            
            try:
                out = open(SaveFile, 'wb')
                pickle.dump(self.SessionPath, out)
                
                for Tab in self.listTabs:
                    pickle.dump(Tab.Vars, out)
                out.close()
                
                self.SaveSessionFile = SaveFile
                self.DisplayMessage("  The session '" + os.path.split(SaveFile)[1] + "' was saved successfully.", 2)
                
            except pickle.PicklingError:
                self.DisplayMessage("  ERROR: Could not properly save the session: " + str(sys.exc_info()), 2)
            except:
                self.DisplayMessage("  Unexpected error: " + str(sys.exc_info()), 2)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:31,代码来源:FlexAID.py

示例3: Enter

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Enter(self):

        if General.validate_String(self.SmilesName.get(), '', False, False, True):
            self.top.DisplayMessage("  ERROR: Could not process the smiles string because you entered an invalid name.", 2)
            return
            
        #Test : CCC[[email protected]@H](O)CC\C=C\C=C\C#CC#C\C=C\CO
        self.inputWindow.destroy()
        self.top.SmilesRunning(False, True)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:11,代码来源:Smiles.py

示例4: Btn_SaveObject_Clicked

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Btn_SaveObject_Clicked(self, objtype):

        # Get the Drop Down List Selection Name
        ddlSelection = self.defaultOption.get()

        state = cmd.get_state()

        self.Set_Object_Variables(objtype)
        
        if ddlSelection == '' or self.Validate_ObjectSelection(ddlSelection, objtype, state):
            return
        
        Path = tkFileDialog.asksaveasfilename(filetypes=[('PDB File','*.pdb')],
                                              initialdir=self.savepath, title='Save the PDB File',
                                              initialfile=ddlSelection, defaultextension='.pdb')
        
        if len(Path) > 0:

            Path = os.path.normpath(Path)

            if General.validate_String(Path, '.pdb', True, False, True):
                self.DisplayMessage("  ERROR: Could not save the file because you entered an invalid name.", 2)
                return

            if self.top.ValidateSaveProject(Path, objtype):
                self.DisplayMessage("  ERROR: The file can only be saved at its default location", 2)
                return
            
            try:
                cmd.save(Path, ddlSelection, state)
                Name = os.path.basename(os.path.splitext(Path)[0])

                cmd.load(Path, Name, state=1)
                cmd.refresh()
                
                if ddlSelection != Name:
                    # as if the object was renamed, delete the object
                    cmd.delete(ddlSelection)
                
            except:
                self.DisplayMessage("  ERROR: An error occured while saving the object.", 1)
                return
            
            self.VarPath.set(os.path.normpath(Path))
            self.VarName.set(Name)
            self.VarProc.set('')
            self.top.SaveSessionFile = ''
            #self.VarMD5.set(General.hashfile(self.VarPath.get()))
            
            if objtype == 'Ligand':
                self.Reset_Ligand()
            
            self.DisplayMessage('  Successfully saved and loaded the object:  ' + self.VarName.get() + "'", 0)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:55,代码来源:IOFile.py

示例5: Btn_LoadObject_Clicked

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Btn_LoadObject_Clicked(self, objtype):
        
        self.Set_Object_Variables(objtype)
        
        SupportedFormats = self.Get_SupportedFormats(objtype)
        
        Path = tkFileDialog.askopenfilename(filetypes=SupportedFormats,
                                            initialdir=self.savepath, title='Select a file to Load')
        # Path = self.top.root.master.splitlist(Path)
        if len(Path) > 0:
        
            Path = os.path.normpath(Path)
            
            if General.validate_String(Path, '', True, False, True):
                self.DisplayMessage("  ERROR: Could not load the file because it has an invalid name.", 2)
                return

            if Path == self.VarPath.get():
                self.DisplayMessage("  Loading skipped. File is the same as the one already loaded.", 2)
                return
            
            try:
                Name = os.path.basename(os.path.splitext(Path)[0])

                cmd.load(Path, Name, state=1)
                cmd.refresh()
                
                if self.Validate_ObjectSelection(Name, objtype, 1):
                    return
                                        
            except:
                self.DisplayMessage("  ERROR: An error occured while loading the file.", 1)
                return
            
            self.VarPath.set(Path)
            self.VarName.set(Name)
            self.VarProc.set('')
            self.top.SaveSessionFile = ''

            if objtype == 'Ligand':
                self.Reset_Ligand()

            if self.ForceSaveObject(Path,Name,objtype):
                self.VarPath.set('')
                self.VarName.set('')
            
            #self.VarMD5.set(General.hashfile(self.VarPath.get()))

            self.DisplayMessage("  Successfully loaded the object: '" + self.VarName.get() + "'", 0)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:51,代码来源:IOFile.py

示例6: Btn_ExtractLigand_Clicked

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Btn_ExtractLigand_Clicked(self):
                
        state = cmd.get_state()

        # Get the Drop Down List Selection Name
        ddlSelection = self.defaultOption.get()
        
        if ddlSelection == '' or self.Validate_ObjectSelection(ddlSelection, 'Ligand', state):
            return
        
        LigandPath = tkFileDialog.asksaveasfilename(filetypes=[('PDB File','*.pdb')],
                                                    initialdir=self.top.FlexAIDLigandProject_Dir, title='Save the PDB File', 
                                                    initialfile=ddlSelection, defaultextension='.pdb')
        
        if len(LigandPath) > 0:
            
            LigandPath = os.path.normpath(LigandPath)

            if General.validate_String(LigandPath, '.pdb', True, False, True):
                self.DisplayMessage("  ERROR: Could not save the file because you entered an invalid name.", 2)
                return

            if self.top.ValidateSaveProject(LigandPath, 'Ligand'):
                self.DisplayMessage("  ERROR: The file can only be saved at its default location", 2)
                return

            try:
                cmd.save(LigandPath, ddlSelection, state)
                LigandName = os.path.basename(os.path.splitext(LigandPath)[0])

                cmd.extract(self.ExtractObject, ddlSelection)
                cmd.set_name(self.ExtractObject, LigandName)
                
                if ddlSelection != LigandName:
                    # as if the object was renamed, delete the object
                    cmd.delete(ddlSelection)
                
            except:
                self.DisplayMessage("  ERROR: An error occured while extracting the ligand object.", 1)
                return
            
            self.LigandPath.set(os.path.normpath(LigandPath))
            self.LigandName.set(LigandName)
            #self.LigandMD5.set(General.hashfile(self.LigandPath.get()))

            self.Reset_Ligand()
            
            self.DisplayMessage('  Successfully extracted the ligand:  ' + self.LigandName.get() + "'", 0)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:50,代码来源:IOFile.py

示例7: Btn_CreatePartition

# 需要导入模块: import General [as 别名]
# 或者: from General import validate_String [as 别名]
    def Btn_CreatePartition(self):

        DestFile = ''
        Output = self.Step3Output.get()
        
        if General.validate_String(Output, '', False, False, True):
            self.DisplayMessage("  ERROR: Could not save the partition file because you entered an invalid name.", 2)
            return

        auto_zoom = cmd.get("auto_zoom")

        if Output != '':
            
            if not self.Vertex:
                self.top.DisplayMessage("  ERROR: Cannot save an empty cleft. Add spheres that include volume of the parent.", 1)
                return
            
            if General_cmd.object_Exists(Output):
                answer = tkMessageBox.askquestion("Question", 
                                                  message="An object with that name already exists. Would you like to overwrite it?",
                                                  icon='warning')
                if str(answer) == 'no':
                    return
                
            try:
                cmd.set("auto_zoom", 0)
                
                DestFile = os.path.join(self.top.GetCleftTempProject_Dir, Output + '.pdb')
                self.top.Manage.copy_TempPartition(self.TempPartition, DestFile)
                
                cmd.load(DestFile, Output, state=1)
                cmd.refresh()
                
                cmd.hide('everything', Output)
                cmd.refresh()

                cmd.show('surface', Output)
                cmd.refresh()
                
                partition_rgb = self.top.Default.SetPartitionColor(self.Cleft.CleftName)
                
                if len(partition_rgb):
                
                    cmd.color('partition', Output)
                    cmd.refresh()

                    cmd.delete(self.PartitionDisplay)
                    cmd.refresh()
                    
                    Cleft = CleftObj.CleftObj()
                    Cleft.CleftFile = DestFile
                    Cleft.CleftName = self.Step3Output.get()
                    Cleft.PartitionParent = self.Cleft
                    Cleft.Partition = True
                    Cleft.UTarget = self.Cleft.UTarget
                    Cleft.Set_CleftMD5()
                    Cleft.Color = General.rgb_to_hex(partition_rgb)
                    
                    self.top.Default.TempBindingSite.Add_Cleft(Cleft)
                    self.top.CopySession = False

                    # Put the partition cleft over its parent
                    General_cmd.Oscillate(self.Cleft.CleftName, 0.0)

                    self.Reset_Step1()
                    
                else:
                    self.top.DisplayMessage("  ERROR: Cleft '" + self.Cleft.CleftName + "' could not be found to set partition color", 1)

            except:
                self.top.DisplayMessage("  ERROR: Could not create partition object: File not found.", 1)
                
        else:
            self.top.DisplayMessage("  ERROR: Could not create partition object: Output is null.", 1)
            
        cmd.set("auto_zoom", auto_zoom)
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:78,代码来源:CropCleft.py


注:本文中的General.validate_String方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。