parameters: (self)
docstring: Substitutes variables in a .in file
docstring_summary: Substitutes variables in a .in file
docstring_tokens: Substitutes variables in a . in file
function: def run(self):
  		"Substitutes variables in a .in file"
  
  		if getattr(self.generator, 'is_copy', None):
  			for i, x in enumerate(self.outputs):
  				x.write(self.inputs[i].read('rb'), 'wb')
  				stat = os.stat(self.inputs[i].abspath()) # Preserve mtime of the copy
  				os.utime(self.outputs[i].abspath(), (stat.st_atime, stat.st_mtime))
  			self.force_permissions()
  			return None
  
  		if getattr(self.generator, 'fun', None):
  			ret = self.generator.fun(self)
  			if not ret:
  				self.force_permissions()
  			return ret
  
  		code = self.inputs[0].read(encoding=getattr(self.generator, 'encoding', 'latin-1'))
  		if getattr(self.generator, 'subst_fun', None):
  			code = self.generator.subst_fun(self, code)
  			if code is not None:
  				self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'latin-1'))
  			self.force_permissions()
  			return None
  
  		# replace all % by %% to prevent errors by % signs
  		code = code.replace('%', '%%')
  
  		# extract the vars foo into lst and replace @foo@ by %(foo)s
  		lst = []
  		def repl(match):
  			g = match.group
  			if g(1):
  				lst.append(g(1))
  				return "%%(%s)s" % g(1)
  			return ''
  		code = getattr(self.generator, 're_m4', re_m4).sub(repl, code)
  
  		try:
  			d = self.generator.dct
  		except AttributeError:
  			d = {}
  			for x in lst:
  				tmp = getattr(self.generator, x, '') or self.env[x] or self.env[x.upper()]
  				try:
  					tmp = ''.join(tmp)
  				except TypeError:
  					tmp = str(tmp)
  				d[x] = tmp
  
  		code = code % d
  		self.outputs[0].write(code, encoding=getattr(self.generator, 'encoding', 'latin-1'))
  		self.generator.bld.raw_deps[self.uid()] = lst
  
  		# make sure the signature is updated
  		try:
  			delattr(self, 'cache_sig')
  		except AttributeError:
  			pass
  
  		self.force_permissions()
function_tokens: def run ( self ) : if getattr ( self . generator , 'is_copy' , None ) : for i , x in enumerate ( self . outputs ) : x . write ( self . inputs [ i ] . read ( 'rb' ) , 'wb' ) stat = os . stat ( self . inputs [ i ] . abspath ( ) ) # Preserve mtime of the copy os . utime ( self . outputs [ i ] . abspath ( ) , ( stat . st_atime , stat . st_mtime ) ) self . force_permissions ( ) return None if getattr ( self . generator , 'fun' , None ) : ret = self . generator . fun ( self ) if not ret : self . force_permissions ( ) return ret code = self . inputs [ 0 ] . read ( encoding = getattr ( self . generator , 'encoding' , 'latin-1' ) ) if getattr ( self . generator , 'subst_fun' , None ) : code = self . generator . subst_fun ( self , code ) if code is not None : self . outputs [ 0 ] . write ( code , encoding = getattr ( self . generator , 'encoding' , 'latin-1' ) ) self . force_permissions ( ) return None # replace all % by %% to prevent errors by % signs code = code . replace ( '%' , '%%' ) # extract the vars foo into lst and replace @foo@ by %(foo)s lst = [ ] def repl ( match ) : g = match . group if g ( 1 ) : lst . append ( g ( 1 ) ) return "%%(%s)s" % g ( 1 ) return '' code = getattr ( self . generator , 're_m4' , re_m4 ) . sub ( repl , code ) try : d = self . generator . dct except AttributeError : d = { } for x in lst : tmp = getattr ( self . generator , x , '' ) or self . env [ x ] or self . env [ x . upper ( ) ] try : tmp = '' . join ( tmp ) except TypeError : tmp = str ( tmp ) d [ x ] = tmp code = code % d self . outputs [ 0 ] . write ( code , encoding = getattr ( self . generator , 'encoding' , 'latin-1' ) ) self . generator . bld . raw_deps [ self . uid ( ) ] = lst # make sure the signature is updated try : delattr ( self , 'cache_sig' ) except AttributeError : pass self . force_permissions ( )