sbsv2/raptor/python/raptor_data.py
branchwip
changeset 61 f520dfd22025
parent 60 28ee654acf42
child 191 3bfc260b6d61
equal deleted inserted replaced
60:28ee654acf42 61:f520dfd22025
   722 	def Apply(self, oldValue):
   722 	def Apply(self, oldValue):
   723 		try:
   723 		try:
   724 			value = os.environ[self.name]
   724 			value = os.environ[self.name]
   725 			
   725 			
   726 			if value:
   726 			if value:
   727 				# if this value ends in an un-escaped backslash, then it will be treated as a line continuation character in makefile
       
   728 				# parsing - un-escaped backslashes at the end of values are therefore escaped
       
   729 				if value.endswith('\\'):
       
   730 					# an odd number of backslashes means there's one to escape
       
   731 					count = len(value) - len(value.rstrip('\\'))
       
   732 					if count % 2:
       
   733 						value += '\\'
       
   734 	
       
   735 				# if this value is a "path" or a "tool" then we need to make sure
   727 				# if this value is a "path" or a "tool" then we need to make sure
   736 				# it is a proper absolute path in our preferred format.
   728 				# it is a proper absolute path in our preferred format.
   737 				if self.type == "path" or self.type == "tool":
   729 				if self.type == "path" or self.type == "tool":
   738 					try:
   730 					try:
   739 						path = generic_path.Path(value)
   731 						path = generic_path.Path(value)
   740 						value = str(path.Absolute())
   732 						value = str(path.Absolute())
   741 					except ValueError,e:
   733 					except ValueError,e:
   742 						raise BadToolValue("the environment variable %s is incorrect: %s" % (self.name, str(e)))
   734 						raise BadToolValue("the environment variable %s is incorrect: %s" % (self.name, str(e)))				
       
   735 				# if this value ends in an un-escaped backslash, then it will be treated as a line continuation character
       
   736 				# in makefile parsing - un-escaped backslashes at the end of values are therefore escaped
       
   737 				elif value.endswith('\\'):
       
   738 					# an odd number of backslashes means there's one to escape
       
   739 					count = len(value) - len(value.rstrip('\\'))
       
   740 					if count % 2:
       
   741 						value += '\\'	
   743 		except KeyError:
   742 		except KeyError:
   744 			if self.default != None:
   743 			if self.default != None:
   745 				value = self.default
   744 				value = self.default
   746 			else:
   745 			else:
   747 				raise BadToolValue("%s is not set in the environment and has no default" % self.name)
   746 				raise BadToolValue("%s is not set in the environment and has no default" % self.name)