Esempio n. 1
0
    def getSectionAttributes(self, cSection, cNamespaceStrip=None):
        '''
		This Method Gets The File Sections And Process Them To Extract The Sections Attributes As A Dictionnary.

		@param cSection: Provided Section To Retrieve Attributes From. ( String )
		@return: Current Section Attributes. ( Dictionary Or None )
		'''

        if self.cFileSections is None:
            self.cFileSections = self.getSections()

        attributesList = None
        try:
            attributesList = {}
            for cAttribute in self.cFileSections[cSection]:
                if cAttribute.startswith("--"):
                    attributesList["nComment"] = cAttribute.strip("--")
                # sIBL V2 Format Support.
                elif cAttribute.startswith(";"):
                    attributesList["nComment"] = cAttribute.strip(";")
                else:
                    cAttributeTokens = cAttribute.split("=")
                    if cNamespaceStrip:
                        attributesList[cAttributeTokens[0].strip(
                        )] = cAttributeTokens[1].strip().strip("\"")
                    else:
                        attributesList[
                            cSection + "|" + cAttributeTokens[0].strip(
                            )] = cAttributeTokens[1].strip().strip("\"")

        except Exception, cError:
            sIBL_Exceptions.sIBL_Exceptions_Feedback(
                cError,
                "Exception In sIBL_Parser.getSectionAttributes() Method | '%s'"
                % cError.cValue, True)
Esempio n. 2
0
def sIBL_Framework_Executable( argv = None ):
	'''
	This Definition Is sIBL_Framework Main() Definition.

	@param argv: Command Line Arguments ( None )
	'''

	settings, args = sIBL_GetCommandLineParameters( argv )

	if settings.cVerbosityLevel is not None :
		sIBL_Common.sIBL_SetVerbosity_Level( settings.cVerbosityLevel )

	if settings.cAboutValue is False :
		if settings.sIBLFile is None :
			try:
				raise sIBL_Exceptions.Command_Line_Error( "An Input .sIBL File Is Required !" )
			except sIBL_Exceptions.Command_Line_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1

		if not os.path.isfile( settings.sIBLFile ):
			try:
				raise sIBL_Exceptions.File_Exist_Error( "Input .IBL File Does Not Exist !" )
			except sIBL_Exceptions.File_Exist_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1
Esempio n. 3
0
	def getSections( self, cSectionsOnly = None ):
		'''
		This Method Gets The File Content And Process It To Extract The Sections As A Dictionnary.

		@return: Current File Sections. ( Dictionary Or None )
		'''

		cLogger.debug( "> Reading Sections From : '%s'.", self.filePath )
		try :
			if re.search( "^\[Header\]|^\[Template\]|^\[sIBL_GUI\]", self.cFileContent[0] ) :
				self.cFileSections = {}
				cSectionAttributes = []
				for cLine in self.cFileContent:
					if re.search( "^\[.*\]", cLine ):
						cSectionKey = re.search( "(?<=^\[)(.*)(?=\])", cLine )
						cSectionKey = cSectionKey.group( 0 )
						cSectionAttributes = []
					else:
						if re.search( "^\n", cLine ) or re.search( "^\r\n", cLine ) :
							cSectionAttributes.append( "" )
						else :
							cSectionAttributes.append( cLine.rstrip() )

					if cSectionsOnly :
						self.cFileSections[cSectionKey] = ""
					else :
						self.cFileSections[cSectionKey] = cSectionAttributes
			else:
				try:
					raise sIBL_Exceptions.File_Content_Error( "Provided File '%s' Seems Incompatible With sIBL_Parser !" % self.filePath )
				except sIBL_Exceptions.File_Content_Error, cError:
					sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Parser.getSections() Method | '%s'" % cError.cValue )
					return self.cFileSections
		except Exception, cError:
			sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Parser.getSections() Method | '%s'" % cError.cValue, True )
Esempio n. 4
0
def sIBL_GetExtraAttributeComponents(cAttributeValue, cKey):
    '''
	This Definition Gets Extra Section Attributes Components As A Dictionnary.

	@return: Current Attribute Components. ( Dictionary Or None )
	'''
    if cAttributeValue is not None:
        cLogger.debug("> Current Attribute Values : '%s'.", cAttributeValue)
        cLogger.debug("> Current Seeked Key : '%s'.", cKey)

        allTokens = None
        if "|" in cAttributeValue:
            cAttributeTokens = cAttributeValue.split("|")
            allTokens = {}
            allTokens["Attribute Link Name"] = cAttributeTokens[0].strip()
            allTokens["Value"] = cAttributeTokens[1].strip()
            allTokens["Type"] = cAttributeTokens[2].strip()
            if len(cAttributeTokens) == 4:
                allTokens["Attribute Name"] = cAttributeTokens[3].strip()
            else:
                allTokens["Attribute Name"] = None
            cLogger.debug("> Current Key Value : '%s'.", allTokens[cKey])
            return allTokens[cKey]
        else:
            try:
                raise sIBL_Exceptions.Invalid_Attribute_Error(
                    "Provided Attribute Is Not And Extra Attribute")
            except sIBL_Exceptions.File_Content_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Parser.sIBL_GetExtraAttributeComponents() Method | '%s'"
                    % cError.cValue)
                return allTokens
Esempio n. 5
0
def sIBL_GetExtraAttributeComponents( cAttributeValue, cKey ):
	'''
	This Definition Gets Extra Section Attributes Components As A Dictionnary.

	@return: Current Attribute Components. ( Dictionary Or None )
	'''
	if cAttributeValue is not None :
		cLogger.debug( "> Current Attribute Values : '%s'.", cAttributeValue )
		cLogger.debug( "> Current Seeked Key : '%s'.", cKey )

		allTokens = None
		if "|" in cAttributeValue :
			cAttributeTokens = cAttributeValue.split( "|" )
			allTokens = {}
			allTokens["Attribute Link Name"] = cAttributeTokens[0].strip()
			allTokens["Value"] = cAttributeTokens[1].strip()
			allTokens["Type"] = cAttributeTokens[2].strip()
			if len( cAttributeTokens ) == 4:
				allTokens["Attribute Name"] = cAttributeTokens[3].strip()
			else:
				allTokens["Attribute Name"] = None
			cLogger.debug( "> Current Key Value : '%s'.", allTokens[cKey] )
			return allTokens[cKey]
		else :
			try:
				raise sIBL_Exceptions.Invalid_Attribute_Error( "Provided Attribute Is Not And Extra Attribute" )
			except sIBL_Exceptions.File_Content_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Parser.sIBL_GetExtraAttributeComponents() Method | '%s'" % cError.cValue )
				return allTokens
Esempio n. 6
0
	def getSectionAttributes( self, cSection, cNamespaceStrip = None ):
		'''
		This Method Gets The File Sections And Process Them To Extract The Sections Attributes As A Dictionnary.

		@param cSection: Provided Section To Retrieve Attributes From. ( String )
		@return: Current Section Attributes. ( Dictionary Or None )
		'''

		if self.cFileSections is None :
			self.cFileSections = self.getSections()

		attributesList = None
		try :
			attributesList = {}
			for cAttribute in self.cFileSections[cSection]:
				if cAttribute.startswith( "--" ):
					attributesList["nComment"] = cAttribute.strip( "--" )
				# sIBL V2 Format Support.
				elif cAttribute.startswith( ";" ):
					attributesList["nComment"] = cAttribute.strip( ";" )
				else:
					cAttributeTokens = cAttribute.split( "=" )
					if cNamespaceStrip :
						attributesList[cAttributeTokens[0].strip()] = cAttributeTokens[1].strip().strip( "\"" )
					else :
						attributesList[cSection + "|" + cAttributeTokens[0].strip()] = cAttributeTokens[1].strip().strip( "\"" )

		except Exception, cError:
			sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Parser.getSectionAttributes() Method | '%s'" % cError.cValue, True )
Esempio n. 7
0
def sIBL_Framework_Executable(argv=None):
    '''
	This Definition Is sIBL_Framework Main() Definition.

	@param argv: Command Line Arguments ( None )
	'''

    settings, args = sIBL_GetCommandLineParameters(argv)

    if settings.cVerbosityLevel is not None:
        sIBL_Common.sIBL_SetVerbosity_Level(settings.cVerbosityLevel)

    if settings.cAboutValue is False:
        if settings.sIBLFile is None:
            try:
                raise sIBL_Exceptions.Command_Line_Error(
                    "An Input .sIBL File Is Required !")
            except sIBL_Exceptions.Command_Line_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Framework Main() Definition | '%s'" %
                    cError.cValue)
                return 1

        if not os.path.isfile(settings.sIBLFile):
            try:
                raise sIBL_Exceptions.File_Exist_Error(
                    "Input .IBL File Does Not Exist !")
            except sIBL_Exceptions.File_Exist_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Framework Main() Definition | '%s'" %
                    cError.cValue)
                return 1
	def deleteLocalReleaseFile( self ):
		'''
		This Method Deletes The Local Change Log.
		'''

		try:
			cLogger.debug( "> Deleting Local Change Log : '%s'.", self.cLocalReleasesFile )

			os.remove( self.cLocalReleasesFile )

		except Exception, cError:
			sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Online_Update.deleteLocalReleaseFile() Method | '%s' Deleting Failed" % self.cLocalReleasesFile, True )
Esempio n. 9
0
    def deleteLocalReleaseFile(self):
        '''
		This Method Deletes The Local Change Log.
		'''

        try:
            cLogger.debug("> Deleting Local Change Log : '%s'.",
                          self.cLocalReleasesFile)

            os.remove(self.cLocalReleasesFile)

        except Exception, cError:
            sIBL_Exceptions.sIBL_Exceptions_Feedback(
                cError,
                "Exception In sIBL_Online_Update.deleteLocalReleaseFile() Method | '%s' Deleting Failed"
                % self.cLocalReleasesFile, True)
Esempio n. 10
0
	def getCollectionContent( self ) :
		'''
		This Method Gets sIBL Collection Content As A Dictionary.

		@return: Collection Content ( Dictionary Or None )
		'''

		cRootDirectory = self.rDirectoryPath
		cCollection = None
		if os.path.exists( cRootDirectory ):
			cCollection = {}
			cDirectoryContent = os.listdir( cRootDirectory )
			for item in cDirectoryContent :
				itemPath = cRootDirectory + item
				if os.path.isdir( itemPath ):
					cLogger.debug( "> Current Directory : '%s' In '%s'.", itemPath, cRootDirectory )
				else :
					cLogger.debug( "> Current File : '%s' In '%s'.", itemPath, cRootDirectory )
				if os.path.isdir( itemPath ):
					cSubDirectoryContent = os.listdir( itemPath )
					isValidSIBL = False
					cSIBLFile = ""
					for subItem in cSubDirectoryContent :
						subItemPath = itemPath + "/" + subItem
						if os.path.isdir( subItemPath ):
							cLogger.debug( "> Current Directory : '%s' In '%s'.", subItemPath, itemPath )
						else:
							cLogger.debug( "> Current File : '%s' In '%s'.", subItemPath, itemPath )
						if ".ibl" in subItem :
							if os.path.getsize( subItemPath ) > 64 :
								isValidSIBL = True
								cSIBLFile = subItemPath
								break
							else :
								try:
									raise sIBL_Exceptions.File_Corrupted_Error( "'%s' Seem To Be Corrupted !" % ( subItemPath ) )
								except sIBL_Exceptions.File_Corrupted_Error, cError:
									sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Collection.getCollectionContent() Method | '%s'" % cError.cValue )
					if isValidSIBL :
						cCollection[item] = cSIBLFile
					else :
						try:
							raise sIBL_Exceptions.File_Exist_Error( "'%s' Doesn't Contain Any Valid .ibl file !" % ( itemPath ) )
						except sIBL_Exceptions.File_Exist_Error, cError:
							sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Collection.getCollectionContent() Method | '%s'" % cError.cValue )
Esempio n. 11
0
    def getSections(self, cSectionsOnly=None):
        '''
		This Method Gets The File Content And Process It To Extract The Sections As A Dictionnary.

		@return: Current File Sections. ( Dictionary Or None )
		'''

        cLogger.debug("> Reading Sections From : '%s'.", self.filePath)
        try:
            if re.search("^\[Header\]|^\[Template\]|^\[sIBL_GUI\]",
                         self.cFileContent[0]):
                self.cFileSections = {}
                cSectionAttributes = []
                for cLine in self.cFileContent:
                    if re.search("^\[.*\]", cLine):
                        cSectionKey = re.search("(?<=^\[)(.*)(?=\])", cLine)
                        cSectionKey = cSectionKey.group(0)
                        cSectionAttributes = []
                    else:
                        if re.search("^\n", cLine) or re.search(
                                "^\r\n", cLine):
                            cSectionAttributes.append("")
                        else:
                            cSectionAttributes.append(cLine.rstrip())

                    if cSectionsOnly:
                        self.cFileSections[cSectionKey] = ""
                    else:
                        self.cFileSections[cSectionKey] = cSectionAttributes
            else:
                try:
                    raise sIBL_Exceptions.File_Content_Error(
                        "Provided File '%s' Seems Incompatible With sIBL_Parser !"
                        % self.filePath)
                except sIBL_Exceptions.File_Content_Error, cError:
                    sIBL_Exceptions.sIBL_Exceptions_Feedback(
                        cError,
                        "Exception In sIBL_Parser.getSections() Method | '%s'"
                        % cError.cValue)
                    return self.cFileSections
        except Exception, cError:
            sIBL_Exceptions.sIBL_Exceptions_Feedback(
                cError,
                "Exception In sIBL_Parser.getSections() Method | '%s'" %
                cError.cValue, True)
Esempio n. 12
0
	def setLocalFile( self, cRemoteFile, cLocalFilePath ) :
		'''
		This Method Downloads A Remote File.

		@param cRemoteFile: Remote File To Download. ( String )
		@param cLocalFilePath: Local Target File. ( String )
		'''
		if not self.closeFTPConnection :
			try:
				cLogger.debug( "> Starting Remote File Download From '%s' To '%s' Local File.", cRemoteFile, cLocalFilePath )
				cLocalFile = open( cLocalFilePath, "wb" )
				self.cFTP.retrbinary( 'RETR ' + cRemoteFile, cLocalFile.write )
				cLocalFile.close()

				return True

			except Exception, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_FTP.setLocalFile() Method | '%s' Creation Failed !" % cLocalFilePath, True )
				return False
Esempio n. 13
0
	def setConnection( self, cHost, cPort ) :
		'''
		This Method Initializes The FTP Connection.

		@param cHost: FTP Host. ( String )
		@param cPort: FTP Connection Port. ( Int )
		@return: Connection State ( Boolean )
		'''

		if not self.closeFTPConnection :
			self.setProgressMessage( "Connecting To '%s'" % cHost, cWaitTime = 0.75 )

			try :
				self.cFTP.connect( cHost, cPort )
			except Exception, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_FTP.setConnection() Method | '%s' Connection Failed !" % cHost, True )
				self.setProgressMessage( "Connection On '%s' Failed !" % cHost )
				return False

			return True
Esempio n. 14
0
	def setLocalDirectory( self, cLocalDirectory ) :
		'''
		This Method Creates A Local Directory.

		@param cLocalDirectory: Local Directory To Create. ( String )
		@return: Success Of The Creation ( Boolean )
		'''

		if not self.closeFTPConnection :
			if not os.path.exists( cLocalDirectory ):
				try:
					cLogger.debug( "> Creating Directory Tree : '%s'.", cLocalDirectory )
					os.makedirs( cLocalDirectory )
					return True
				except Exception, cError:
					sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_FTP.setLocalDirectory() Method | '%s' Creation Failed !" % cLocalDirectory )
					return False
			else:
				cLogger.debug( "> '%s' Directory Tree Already Exist, Skipping Creation !", cLocalDirectory )
				return True
Esempio n. 15
0
	def setLogin( self, cLogin, cPassword ) :
		'''
		This Method Logs The User To FTP.

		@param cLogin: Connection Login. ( String )
		@param cPassword: Connection Password. ( String )
		@return: Login State ( Boolean )
		'''

		if not self.closeFTPConnection :
			cLogger.debug( "> Login : '******'.", cLogin )
			cLogger.debug( "> Password : '******'.", cPassword )

			self.setProgressMessage( "Login On FTP !", cWaitTime = 0.75 )

			try :
				self.cFTP.login( cLogin, cPassword )
			except Exception, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_FTP.setConnection() Method | Login Failed !", True )
				self.setProgressMessage( "Login Failed !" )
				return False

			return True
Esempio n. 16
0
	def recursiveWalker( self, cFilter = None ):
		'''
		This Method Gets Root Directory Files List As A Dictionnary.

		@return: Files List. ( Dictionary Or None )
		'''
		if cFilter :
			cLogger.debug( "> Current Filter : '%s'.", cFilter )

		cRootDirectory = self.rDirectoryPath
		cFiles = None
		if os.path.exists( cRootDirectory ):
			cFiles = {}
			for root, dirs, files in os.walk( cRootDirectory, topdown = False ):
				for item in files:
					cLogger.debug( "> Current File : '%s' In '%s'.", item, cRootDirectory )
					cItemPath = os.path.join( root, item ).replace( "\\", "/" )
					if os.path.isfile( cItemPath ):
						if cFilter :
							if not cFilter in cItemPath :
								continue
						cFileTokens = os.path.splitext( item )
						if cFileTokens[0] in cFiles:
							cPathTags = cItemPath.replace( cRootDirectory, "" ).replace( "/", "_" ).replace( item, "" )
							cItemName = cPathTags + cFileTokens[0]
							cLogger.debug( "> Adding '%s' With Path : '%s' To File List.", cItemName, cItemPath )
							cFiles[cItemName] = cItemPath
						else:
							cLogger.debug( "> Adding '%s' With Path : '%s' To File List.", cFileTokens[0], cItemPath )
							cFiles[cFileTokens[0]] = cItemPath
		else :
			try:
				raise sIBL_Exceptions.Directory_Exist_Error( "'%s' Is Not A Valid Directory !" % ( cRootDirectory ) )
			except sIBL_Exceptions.Directory_Exist_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Recursive_Walker.recursiveWalker() Method | '%s'" % cError.cValue )
				return cFiles
Esempio n. 17
0
			except sIBL_Exceptions.Command_Line_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1

		if not os.path.isfile( settings.sIBLFile ):
			try:
				raise sIBL_Exceptions.File_Exist_Error( "Input .IBL File Does Not Exist !" )
			except sIBL_Exceptions.File_Exist_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1

		if settings.cTemplateFile is None :
			try:
				raise sIBL_Exceptions.Command_Line_Error( "An Input Template File Is Required !" )
			except sIBL_Exceptions.Command_Line_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1

		if not os.path.isfile( settings.cTemplateFile ):
			try:
				raise sIBL_Exceptions.File_Exist_Error( "Input Template File Does Not Exist !" )
			except sIBL_Exceptions.File_Exist_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
				return 1

		if settings.oKeys is not None :
			oKeys = sIBL_GetOverrideKeys( settings.oKeys )
			if oKeys is None :
				return 1
		else :
			cLogger.warning( "> No Override Keys Provided, Using \"'%s'\" Template Default Values !", os.path.basename( settings.cTemplateFile ) )
Esempio n. 18
0
def sIBL_Framework( sIBLFile, cTemplateFile, cOutputFile, cOverrideKeys ):
	'''
	This Definition Outputs The Loader Script File By Processing The sIBL File And The Template File.

	@param sIBLFile: Current sIBL File Path. ( String )
	@param cTemplateFile: Current Template File Path. ( String )
	@param cOutputFile: Current Loader Script Output Path. ( String )
	@param cOverrideKeys: Current Provided Override Keys. ( String )
	@return: Error State Of The Output And Output File Path. ( Boolean, String )
	'''

	sIBLPath = os.path.abspath( os.path.dirname( sIBLFile ) ).replace( "\\", "/" ) + "/"
	cLogger.debug( "> Current sIBLPath : '%s'.", sIBLPath )

	# Get sIBL File Concatened Sections Attributes.
	cLogger.debug( "> ------ Parsing '%s' File ------", "sIBL" )
	cSIBLFile = sIBL_Parser.sIBL_Parser( sIBLFile )

	if cSIBLFile is  None :
		return False, None
	cSIBLFileSections = cSIBLFile.getSections()

	# If .IBL File Seem Corrupted Or Invalid.
	if cSIBLFileSections is None :
		return False, None

	cSIBLSectionsAttributes = {}
	cDynamicLights = []
	for cSection in cSIBLFileSections.keys():
		cLogger.debug( "> Current sIBL File Section : '%s'.", cSection )
		if not "Light" in cSection :
			cSIBLSectionsAttributes.update( cSIBLFile.getSectionAttributes( cSection ) )
		else :
			# Dynamic Lights Attributes
			cLightAttributes = cSIBLFile.getSectionAttributes( cSection, True )
			cDynamicLights.append( cSection )
			cDynamicLights.append( cLightAttributes["LIGHTname"] )
			cLightColorTokens = cLightAttributes["LIGHTcolor"].split( "," )
			for cColor in cLightColorTokens:
				cDynamicLights.append( cColor )
			cDynamicLights.append( cLightAttributes["LIGHTmulti"] )
			cDynamicLights.append( cLightAttributes["LIGHTu"] )
			cDynamicLights.append( cLightAttributes["LIGHTv"] )

			cLogger.debug( "> Dynamic Lights : '%s'.", cDynamicLights )

	# Preparing The Dynamic Lights String
	cDynamicLightsString = ""
	for cComponent in cDynamicLights :
		cDynamicLightsString = cDynamicLightsString + cComponent + "|"

	# Adding The Dynamic Lights String
	if cDynamicLightsString == "" :
		cDynamicLightsString = "-1"
	else :
		cDynamicLightsString = cDynamicLightsString[:-1]

	cSIBLSectionsAttributes[sIBL_Parser.sIBL_CompoundNamespace( "Lights", "DynamicLights" )] = cDynamicLightsString

	# Get Template File Sections.
	cLogger.debug( "> ------ Parsing '%s' File ------", "Template" )
	cTemplateFile = sIBL_Parser.sIBL_Parser( cTemplateFile )

	if cTemplateFile is None :
		return False, None
	cTemplateFileSections = cTemplateFile.getSections()

	# If Template File Seem Corrupted Or Invalid.
	if cTemplateFileSections is None :
		return False, None

	# Get Template File Concatened Sections Attributes And Values.
	cTemplateSectionsAttributesStore = {}

	for cKey in cTemplateFileSections.keys():
		if cKey != "Script" :
			cLogger.debug( "> Current Template File Processed Section : '%s'.", cKey )
			if cKey == "sIBL File Attributes" :
				cTemplateSectionsAttributesStore.update( cTemplateFile.getSectionAttributes( cKey, True ) )
			else :
				cTemplateSectionsAttributesStore.update( cTemplateFile.getSectionAttributes( cKey ) )

	# Get A Copy Of Template File Concatened Sections Attributes In Order To Update It.
	cTemplateSectionsAttributes = cTemplateSectionsAttributesStore.copy()

	# Update Template File Attributes With sIBL File Ones.
	for cKey in cTemplateSectionsAttributes:
		if cKey in cSIBLSectionsAttributes :
			# Updating Path To The File.
			if "file" in cKey:
				cTemplateSectionsAttributes[cKey] = sIBLPath + cSIBLSectionsAttributes[cKey]
			else :
				cTemplateSectionsAttributes[cKey] = cSIBLSectionsAttributes[cKey]
		else :
			# Need An Number Here More Than A String Here, Or Typed Variables Script Will Need To Write Cast Functions.
			cTemplateSectionsAttributes[cKey] = "-1"
			# cTemplateSectionsAttributes[cKey] = "\"Not Available\""

	# Get Default Values, Types And Update Template Attributes With Default Values.
	cTemplateSectionsAttributesValues = {}
	cTemplateSectionsAttributesTypes = {}
	for cKey in cTemplateSectionsAttributesStore:
		if "|" in cTemplateSectionsAttributesStore[cKey] :
			cTemplateSectionsAttributesValues[cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents( cTemplateSectionsAttributesStore[cKey], "Value" )
			cTemplateSectionsAttributesTypes[cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents( cTemplateSectionsAttributesStore[cKey], "Type" )
			cTemplateSectionsAttributesStore[cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents( cTemplateSectionsAttributesStore[cKey], "Attribute Link Name" )

	cTemplateSectionsAttributes.update( cTemplateSectionsAttributesValues )

	# Manually Updating Template Attributes With Override Keys (Manual In Order To Not Transmit Erroneus Keys).
	if cOverrideKeys is not None :
		for cKey in cOverrideKeys :
			if cKey in cTemplateSectionsAttributes :
				cTemplateSectionsAttributes[cKey] = cOverrideKeys[cKey]
			else :
				try:
					raise sIBL_Exceptions.Invalid_Key_Error( "Invalid cKey Provided ! : '%s'" % cKey )
				except sIBL_Exceptions.Invalid_Key_Error, cError:
					sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Framework Main() Definition | '%s'" % cError.cValue )
					return False, None
Esempio n. 19
0
							cLogger.debug( "> Current File : '%s' In '%s'.", subItemPath, itemPath )
						if ".ibl" in subItem :
							if os.path.getsize( subItemPath ) > 64 :
								isValidSIBL = True
								cSIBLFile = subItemPath
								break
							else :
								try:
									raise sIBL_Exceptions.File_Corrupted_Error( "'%s' Seem To Be Corrupted !" % ( subItemPath ) )
								except sIBL_Exceptions.File_Corrupted_Error, cError:
									sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Collection.getCollectionContent() Method | '%s'" % cError.cValue )
					if isValidSIBL :
						cCollection[item] = cSIBLFile
					else :
						try:
							raise sIBL_Exceptions.File_Exist_Error( "'%s' Doesn't Contain Any Valid .ibl file !" % ( itemPath ) )
						except sIBL_Exceptions.File_Exist_Error, cError:
							sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Collection.getCollectionContent() Method | '%s'" % cError.cValue )
		else :
			try:
				raise sIBL_Exceptions.Directory_Exist_Error( "'%s' Is Not A Valid Directory !" % ( cRootDirectory ) )
			except sIBL_Exceptions.Directory_Exist_Error, cError:
				sIBL_Exceptions.sIBL_Exceptions_Feedback ( cError, "Exception In sIBL_Collection.getCollectionContent() Method | '%s'" % cError.cValue )
				return cCollection

		return cCollection

#***********************************************************************************************
#***	Python End
#***********************************************************************************************
Esempio n. 20
0
def sIBL_Framework(sIBLFile, cTemplateFile, cOutputFile, cOverrideKeys):
    '''
	This Definition Outputs The Loader Script File By Processing The sIBL File And The Template File.

	@param sIBLFile: Current sIBL File Path. ( String )
	@param cTemplateFile: Current Template File Path. ( String )
	@param cOutputFile: Current Loader Script Output Path. ( String )
	@param cOverrideKeys: Current Provided Override Keys. ( String )
	@return: Error State Of The Output And Output File Path. ( Boolean, String )
	'''

    sIBLPath = os.path.abspath(os.path.dirname(sIBLFile)).replace("\\",
                                                                  "/") + "/"
    cLogger.debug("> Current sIBLPath : '%s'.", sIBLPath)

    # Get sIBL File Concatened Sections Attributes.
    cLogger.debug("> ------ Parsing '%s' File ------", "sIBL")
    cSIBLFile = sIBL_Parser.sIBL_Parser(sIBLFile)

    if cSIBLFile is None:
        return False, None
    cSIBLFileSections = cSIBLFile.getSections()

    # If .IBL File Seem Corrupted Or Invalid.
    if cSIBLFileSections is None:
        return False, None

    cSIBLSectionsAttributes = {}
    cDynamicLights = []
    for cSection in cSIBLFileSections.keys():
        cLogger.debug("> Current sIBL File Section : '%s'.", cSection)
        if not "Light" in cSection:
            cSIBLSectionsAttributes.update(
                cSIBLFile.getSectionAttributes(cSection))
        else:
            # Dynamic Lights Attributes
            cLightAttributes = cSIBLFile.getSectionAttributes(cSection, True)
            cDynamicLights.append(cSection)
            cDynamicLights.append(cLightAttributes["LIGHTname"])
            cLightColorTokens = cLightAttributes["LIGHTcolor"].split(",")
            for cColor in cLightColorTokens:
                cDynamicLights.append(cColor)
            cDynamicLights.append(cLightAttributes["LIGHTmulti"])
            cDynamicLights.append(cLightAttributes["LIGHTu"])
            cDynamicLights.append(cLightAttributes["LIGHTv"])

            cLogger.debug("> Dynamic Lights : '%s'.", cDynamicLights)

    # Preparing The Dynamic Lights String
    cDynamicLightsString = ""
    for cComponent in cDynamicLights:
        cDynamicLightsString = cDynamicLightsString + cComponent + "|"

    # Adding The Dynamic Lights String
    if cDynamicLightsString == "":
        cDynamicLightsString = "-1"
    else:
        cDynamicLightsString = cDynamicLightsString[:-1]

    cSIBLSectionsAttributes[sIBL_Parser.sIBL_CompoundNamespace(
        "Lights", "DynamicLights")] = cDynamicLightsString

    # Get Template File Sections.
    cLogger.debug("> ------ Parsing '%s' File ------", "Template")
    cTemplateFile = sIBL_Parser.sIBL_Parser(cTemplateFile)

    if cTemplateFile is None:
        return False, None
    cTemplateFileSections = cTemplateFile.getSections()

    # If Template File Seem Corrupted Or Invalid.
    if cTemplateFileSections is None:
        return False, None

    # Get Template File Concatened Sections Attributes And Values.
    cTemplateSectionsAttributesStore = {}

    for cKey in cTemplateFileSections.keys():
        if cKey != "Script":
            cLogger.debug("> Current Template File Processed Section : '%s'.",
                          cKey)
            if cKey == "sIBL File Attributes":
                cTemplateSectionsAttributesStore.update(
                    cTemplateFile.getSectionAttributes(cKey, True))
            else:
                cTemplateSectionsAttributesStore.update(
                    cTemplateFile.getSectionAttributes(cKey))

    # Get A Copy Of Template File Concatened Sections Attributes In Order To Update It.
    cTemplateSectionsAttributes = cTemplateSectionsAttributesStore.copy()

    # Update Template File Attributes With sIBL File Ones.
    for cKey in cTemplateSectionsAttributes:
        if cKey in cSIBLSectionsAttributes:
            # Updating Path To The File.
            if "file" in cKey:
                cTemplateSectionsAttributes[
                    cKey] = sIBLPath + cSIBLSectionsAttributes[cKey]
            else:
                cTemplateSectionsAttributes[cKey] = cSIBLSectionsAttributes[
                    cKey]
        else:
            # Need An Number Here More Than A String Here, Or Typed Variables Script Will Need To Write Cast Functions.
            cTemplateSectionsAttributes[cKey] = "-1"
            # cTemplateSectionsAttributes[cKey] = "\"Not Available\""

    # Get Default Values, Types And Update Template Attributes With Default Values.
    cTemplateSectionsAttributesValues = {}
    cTemplateSectionsAttributesTypes = {}
    for cKey in cTemplateSectionsAttributesStore:
        if "|" in cTemplateSectionsAttributesStore[cKey]:
            cTemplateSectionsAttributesValues[
                cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents(
                    cTemplateSectionsAttributesStore[cKey], "Value")
            cTemplateSectionsAttributesTypes[
                cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents(
                    cTemplateSectionsAttributesStore[cKey], "Type")
            cTemplateSectionsAttributesStore[
                cKey] = sIBL_Parser.sIBL_GetExtraAttributeComponents(
                    cTemplateSectionsAttributesStore[cKey],
                    "Attribute Link Name")

    cTemplateSectionsAttributes.update(cTemplateSectionsAttributesValues)

    # Manually Updating Template Attributes With Override Keys (Manual In Order To Not Transmit Erroneus Keys).
    if cOverrideKeys is not None:
        for cKey in cOverrideKeys:
            if cKey in cTemplateSectionsAttributes:
                cTemplateSectionsAttributes[cKey] = cOverrideKeys[cKey]
            else:
                try:
                    raise sIBL_Exceptions.Invalid_Key_Error(
                        "Invalid cKey Provided ! : '%s'" % cKey)
                except sIBL_Exceptions.Invalid_Key_Error, cError:
                    sIBL_Exceptions.sIBL_Exceptions_Feedback(
                        cError,
                        "Exception In sIBL_Framework Main() Definition | '%s'"
                        % cError.cValue)
                    return False, None
Esempio n. 21
0
                raise sIBL_Exceptions.File_Exist_Error(
                    "Input .IBL File Does Not Exist !")
            except sIBL_Exceptions.File_Exist_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Framework Main() Definition | '%s'" %
                    cError.cValue)
                return 1

        if settings.cTemplateFile is None:
            try:
                raise sIBL_Exceptions.Command_Line_Error(
                    "An Input Template File Is Required !")
            except sIBL_Exceptions.Command_Line_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Framework Main() Definition | '%s'" %
                    cError.cValue)
                return 1

        if not os.path.isfile(settings.cTemplateFile):
            try:
                raise sIBL_Exceptions.File_Exist_Error(
                    "Input Template File Does Not Exist !")
            except sIBL_Exceptions.File_Exist_Error, cError:
                sIBL_Exceptions.sIBL_Exceptions_Feedback(
                    cError,
                    "Exception In sIBL_Framework Main() Definition | '%s'" %
                    cError.cValue)
                return 1

        if settings.oKeys is not None: