Пример #1
0
    def load(self, path):
        if not path:
            path = self.path
            if not self.path: return False

        if not os.path.exists(path + '/' + _PROJECT_INFO_FILE): return False

        self._initPath(path)
        self._affirmDirectories()
        self.info = jsonHelper.tryLoadJSON(
            self.getBasePath(_PROJECT_INFO_FILE))

        if not os.path.exists(self.editorPath):
            os.makedirs(self.editorPath)
        self.config = jsonHelper.tryLoadJSON(
            self.getBasePath(_PROJECT_EDITOR_DIR + '/' + _PROJECT_CONFIG_FILE))
        if not self.config:
            self.config = {}
            self.saveConfig()

        # self.cacheManager.load( _GII_ENV_CONFIG_DIR, self.envConfigPath )
        # self.assetLibrary.load( _GII_ASSET_DIR, self.assetPath, self.path, self.envConfigPath )

        self.loaded = True
        signals.emitNow('project.preload', self)
        signals.emitNow('project.load', self)

        return True
Пример #2
0
	def load(self, path):
		if not path:
			path = self.path
			if not self.path: return False

		if not os.path.exists( path + '/' + _PROJECT_INFO_FILE ): return False

		self._initPath( path )
		self._affirmDirectories()
		self.info = jsonHelper.tryLoadJSON( self.getBasePath( _PROJECT_INFO_FILE ) )

		if not os.path.exists( self.editorPath ):
			os.makedirs( self.editorPath )
		self.config = jsonHelper.tryLoadJSON( self.getBasePath( _PROJECT_EDITOR_DIR + '/' + _PROJECT_CONFIG_FILE ) )
		if not self.config:
			self.config = {}
			self.saveConfig()

		# self.cacheManager.load( _GII_ENV_CONFIG_DIR, self.envConfigPath )
		# self.assetLibrary.load( _GII_ASSET_DIR, self.assetPath, self.path, self.envConfigPath )

		self.loaded = True
		signals.emitNow( 'project.preload', self )
		signals.emitNow( 'project.load', self )

		return True
Пример #3
0
	def load(self, path):
		path = os.path.realpath(path)
		
		self._initPath( path )
		self._affirmDirectories()
		os.chdir( path )

		sys.path.insert( 0, self.envLibPath )
		sys.path.insert( 0, self.getBinaryPath( 'python' ) ) #for python extension modules

		self.info   = jsonHelper.tryLoadJSON( self.getBasePath( _GII_INFO_FILE ) )
		self.config = jsonHelper.tryLoadJSON( self.getConfigPath( _GII_CONFIG_FILE ) )
		if not self.config:
			self.config = {}
			jsonHelper.trySaveJSON( self.config, self.getConfigPath( _GII_CONFIG_FILE ) )

		if not self.info:
			self.info = {
				'name' : 'name',
				'version' : [0,0,1],
			}
			jsonHelper.trySaveJSON( self.info, self.getBasePath( _GII_INFO_FILE ) )
			
		self.cacheManager.load( _GII_ENV_CONFIG_DIR, self.envConfigPath )
		self.assetLibrary.load( _GII_ASSET_DIR, self.assetPath, self.path, self.envConfigPath )

		#will trigger other module
		signals.emitNow( 'project.preload', self )
		signals.emitNow( 'project.load', self )
		
		logging.info( 'project loaded: %s' % path )

		return True
Пример #4
0
 def loadConfig(self):
     loaded = jsonHelper.tryLoadJSON(self.getPath(_GII_APP_CONFIG_FILE))
     if loaded:
         config = self.config
         for k, v in loaded.items():
             config[k] = v
     else:
         self.saveConfig()
Пример #5
0
	def loadConfig( self ):
		loaded = jsonHelper.tryLoadJSON( self.getPath( _GII_APP_CONFIG_FILE ) )
		if loaded:
			config = self.config
			for k, v in loaded.items():
				config[ k ] = v
		else:
			self.saveConfig()
Пример #6
0
    def load(self, basePath, absBasePath):
        self.cachePath = basePath + '/' + _GII_CACHE_PATH
        self.cacheAbsPath = absBasePath + '/' + _GII_CACHE_PATH
        self.cacheIndexPath = absBasePath + '/' + _GII_CACHE_INDEX_PATH
        self.affirmFolders()
        #load cache file index
        self.cacheFileTable = jsonHelper.tryLoadJSON(self.cacheIndexPath) or {}
        for path, node in self.cacheFileTable.items():
            node['touched'] = False

        return True
Пример #7
0
Файл: cache.py Проект: tommo/gii
	def load( self, basePath, absBasePath ):
		self.cachePath      = basePath + '/' + _GII_CACHE_PATH
		self.cacheAbsPath   = absBasePath + '/' + _GII_CACHE_PATH
		self.cacheIndexPath = absBasePath + '/' + _GII_CACHE_INDEX_PATH
		self.affirmFolders()
		#load cache file index
		self.cacheFileTable = jsonHelper.tryLoadJSON( self.cacheIndexPath ) or {}
		for path, node in self.cacheFileTable.items():
			node[ 'touched' ] = False

		return True
Пример #8
0
Файл: asset.py Проект: tommo/gii
	def loadAssetTable(self):

		logging.info( 'loading asset table from:' + self.assetIndexPath )
		
		if not os.path.exists( self.assetIndexPath ): return
		dataTable = jsonHelper.tryLoadJSON( self.assetIndexPath )

		if not dataTable: return False
		
		assetTable={}

		for path,data in dataTable.items():
			node = AssetNode(path, data.get('type').encode('utf-8'), 
					filePath = data.get( 'filePath', path ),
					fileTime = data.get( 'fileTime', 0 )
				)
			node.deployState  = data.get('deploy', None)
			node.groupType    = data.get( 'groupType', None )
			node.cacheFiles   = data.get('cacheFiles', {})
			node.objectFiles  = data.get('objectFiles', {})
			node.properties   = data.get('properties', {}) 
			node.modifyState  =	data.get('modifyState' ,  False )
			
			assetTable[path]  = node
			node.managerName  = data.get('manager')
			node.tags         = data.get('tags',[])
			node.tagCache     = None
			if node.groupType == None:
				if node.isType( 'folder' ):
					node.groupType = 'folder'
			
		#relink parent/dependency
		for path, node in assetTable.items():
			ppath = os.path.dirname(path)
			if not ppath:
				pnode = self.rootNode
			else:
				pnode = assetTable.get(ppath,None)
			if not pnode:
				continue
			pnode.addChild(node)
			data = dataTable[path]

			for key, dpath in data.get( 'dependency', {} ).items() :
				dnode = assetTable[dpath]
				if not dnode:
					logging.warn('missing dependency asset node', dpath )
					node.markModified()
				else:
					node.addDependency( key, dnode )

		self.assetTable=assetTable
		logging.info("asset library loaded")
Пример #9
0
    def loadAssetTable(self):

        logging.info('loading asset table from:' + self.assetIndexPath)

        if not os.path.exists(self.assetIndexPath): return
        dataTable = jsonHelper.tryLoadJSON(self.assetIndexPath)

        if not dataTable: return False

        assetTable = {}

        for path, data in dataTable.items():
            node = AssetNode(path,
                             data.get('type').encode('utf-8'),
                             filePath=data.get('filePath', path),
                             fileTime=data.get('fileTime', 0))
            node.deployState = data.get('deploy', None)
            node.groupType = data.get('groupType', None)
            node.cacheFiles = data.get('cacheFiles', {})
            node.objectFiles = data.get('objectFiles', {})
            node.properties = data.get('properties', {})
            node.modifyState = data.get('modifyState', False)

            assetTable[path] = node
            node.managerName = data.get('manager')
            node.tags = data.get('tags', [])
            node.tagCache = None
            if node.groupType == None:
                if node.isType('folder'):
                    node.groupType = 'folder'

        #relink parent/dependency
        for path, node in assetTable.items():
            ppath = os.path.dirname(path)
            if not ppath:
                pnode = self.rootNode
            else:
                pnode = assetTable.get(ppath, None)
            if not pnode:
                continue
            pnode.addChild(node)
            data = dataTable[path]

            for key, dpath in data.get('dependency', {}).items():
                dnode = assetTable[dpath]
                if not dnode:
                    logging.warn('missing dependency asset node', dpath)
                    node.markModified()
                else:
                    node.addDependency(key, dnode)

        self.assetTable = assetTable
        logging.info("asset library loaded")
Пример #10
0
Файл: asset.py Проект: tommo/gii
	def getMetaDataTable( self, createIfEmpty = True ):
		if self.isVirtual(): return None
		if self.metadata: return self.metadata
		dirname  = self.getAbsDir()
		metaDir  = dirname + '/' +GII_ASSET_META_DIR
		metaPath = metaDir + '/' + self.getName() + '.meta'
		if os.path.exists( metaPath ):
			data = jsonHelper.tryLoadJSON( metaPath )
			self.metadata = data or {}			
			return self.metadata
		elif  createIfEmpty:
			self.metadata = {}
			return self.metadata
		return None
Пример #11
0
 def getMetaDataTable(self, createIfEmpty=True):
     if self.isVirtual(): return None
     if self.metadata: return self.metadata
     dirname = self.getAbsDir()
     metaDir = dirname + '/' + GII_ASSET_META_DIR
     metaPath = metaDir + '/' + self.getName() + '.meta'
     if os.path.exists(metaPath):
         data = jsonHelper.tryLoadJSON(metaPath)
         self.metadata = data or {}
         return self.metadata
     elif createIfEmpty:
         self.metadata = {}
         return self.metadata
     return None
Пример #12
0
    def load(self, path):
        path = os.path.realpath(path)

        self._initPath(path)
        self._affirmDirectories()
        os.chdir(path)

        sys.path.insert(0, self.envLibPath)
        sys.path.insert(
            0, self.getBinaryPath('python'))  #for python extension modules

        self.info = jsonHelper.tryLoadJSON(self.getBasePath(_GII_INFO_FILE))
        self.config = jsonHelper.tryLoadJSON(
            self.getConfigPath(_GII_CONFIG_FILE))
        if not self.config:
            self.config = {}
            jsonHelper.trySaveJSON(self.config,
                                   self.getConfigPath(_GII_CONFIG_FILE))

        if not self.info:
            self.info = {
                'name': 'name',
                'version': [0, 0, 1],
            }
            jsonHelper.trySaveJSON(self.info, self.getBasePath(_GII_INFO_FILE))

        self.cacheManager.load(_GII_ENV_CONFIG_DIR, self.envConfigPath)
        self.assetLibrary.load(_GII_ASSET_DIR, self.assetPath, self.path,
                               self.envConfigPath)

        #will trigger other module
        signals.emitNow('project.preload', self)
        signals.emitNow('project.load', self)

        logging.info('project loaded: %s' % path)

        return True
Пример #13
0
	def findProject( path = None ):
		#TODO: return project info dict instead of path?
		path = os.path.abspath( path or '' )
		opath = None
		while path and not ( path in ( '', '/','\\' ) ):
			if   os.path.exists( path + '/' + _GII_ENV_CONFIG_DIR ) \
			and  os.path.exists( path + '/' + _GII_INFO_FILE ) :
				#get info
				info = jsonHelper.tryLoadJSON( path + '/' + _GII_INFO_FILE )
				info['path'] = path
				return info
			#go up level
			opath = path
			path = os.path.dirname( path )
			if path == opath: break
		return None
Пример #14
0
 def findProject(path=None):
     #TODO: return project info dict instead of path?
     path = os.path.abspath(path or '')
     opath = None
     while path and not (path in ('', '/', '\\')):
         if   os.path.exists( path + '/' + _GII_ENV_CONFIG_DIR ) \
         and  os.path.exists( path + '/' + _GII_INFO_FILE ) :
             #get info
             info = jsonHelper.tryLoadJSON(path + '/' + _GII_INFO_FILE)
             info['path'] = path
             return info
         #go up level
         opath = path
         path = os.path.dirname(path)
         if path == opath: break
     return None
Пример #15
0
 def loadSettings(self):
     loaded = jsonHelper.tryLoadJSON(
         self.getPath('data/' + _JUMA_PROJECT_DEFAULT_SETTINGS))
     if loaded:
         self.settings = loaded
Пример #16
0
	def loadSettings( self ):
		loaded = jsonHelper.tryLoadJSON( self.getPath( 'data/' + _JUMA_PROJECT_DEFAULT_SETTINGS ) )
		if loaded:
			self.settings = loaded