def run( self ): #将LOC GFG DLOC等这些变量定义到当前模块 project.init( project_create.__module__ ) self.__dict = { "project_name" : "", "project_directory" : "" } self.__project_name = "" self.__projectconfig= os.path.join( PPATH, "project.config" ) default_directory = os.path.expanduser( "~\\My Documents\\" ) self.__input = None self.__terr = StringTemple( "", {} ) #请求输入队列 self.__iqueue = Queue( 0, [ #( <property>, <status message>, <caption>, <init input>, [<callback>] ) #input project name ( "project_name", LOC["CREATE_PROJECT"] + ">" + LOC[ "INPUT_PROJECT_NAME" ], LOC["INPUT_PROJECT_NAME"], "", None ), #input project directory ( "project_directory", LOC["CREATE_PROJECT"] + ">" + LOC[ "INPUT_PROJECT_DIR" ], LOC["INPUT_PROJECT_DIR"], ( lambda : os.path.join( len( CFG.get( "work_space") ) and CFG.get("work_space") or default_directory, self["project_name"] ).replace("\\","/") ), [ self.__createProjectDestory, self.__createProjectConfig, self.__openProject ] ) ] ) self.__showInputPanel()
def run( self ): project.init( project_release.__module__ ) self.__folders = self.window.folders() self.__projectpath = self.__folders[0] self.__config = None self.__files = [] self.__releasepath = "" self.__error = "" MESSAGE( LOC["RELEASE_PROJECT"] ) for func, msg, errmsg in [ ( self.__getProjectConfigFile, "" , LOC["INVALID_PROJECT_CONFIG"] ), ( self.__releaseConfirm , "" , "" ), ( self.__getProjectConfig , LOC["GET_PROJECT_CONFIG"] , LOC["GET_PROJECT_CONFIG_FAIL"] ), ( self.__checkProjectConfig , LOC["CHECK_PROJECT_CONFIG"], LOC["INVALID_PROJECT_CONFIG"] ), ( self.__createReleaseDir , LOC["CREATE_RELEASE_DIR"] , LOC["CREATE_RELEASE_DIR_FAIL"] ), ( self.__copyFileToRelease , LOC["COPY_FILE_TO_RELEASE"], LOC["COPY_FILE_TO_RELEASE_FAIL"] ), ( self.__replaceTag , LOC["REPLACE_TAG"] , LOC["REPLACE_TAG_FAIL"] ), ( self.__openReleaseDir , "" , "") ]: MESSAGE( msg ) try: if func(): break except Exception, e: sublime.error_message( project_release.FAIL_MESSAGE_FORMAT % ( LOC["RELEASE_PROJECT_FAIL"], errmsg ) ) if self.__releasepath: shutil.rmtree( self.__releasepath, True ) #DEBUG MESSAGE( "REAL-ERROR: " + str(e), c = DEBUG ) return None