parameters: (self, template)
return_statement: return template_wrapper
docstring: Returns a function object for use within the sandbox for the given
          TemplateFunction instance..
  
          When a moz.build file contains a reference to a template call, the
          sandbox needs a function to execute. This is what this method returns.
          That function creates a new sandbox for execution of the template.
          After the template is executed, the data from its execution is merged
          with the context of the calling sandbox.
docstring_summary: Returns a function object for use within the sandbox for the given
          TemplateFunction instance..
docstring_tokens: Returns a function object for use within the sandbox for the given TemplateFunction instance ..
function: def _create_template_wrapper(self, template):
          """Returns a function object for use within the sandbox for the given
          TemplateFunction instance..
  
          When a moz.build file contains a reference to a template call, the
          sandbox needs a function to execute. This is what this method returns.
          That function creates a new sandbox for execution of the template.
          After the template is executed, the data from its execution is merged
          with the context of the calling sandbox.
          """
          def template_wrapper(*args, **kwargs):
              context = TemplateContext(
                  template=template.name,
                  allowed_variables=self._context._allowed_variables,
                  config=self._context.config)
              context.add_source(self._context.current_path)
              for p in self._context.all_paths:
                  context.add_source(p)
  
              sandbox = MozbuildSandbox(context, metadata={
                  # We should arguably set these defaults to something else.
                  # Templates, for example, should arguably come from the state
                  # of the sandbox from when the template was declared, not when
                  # it was instantiated. Bug 1137319.
                  'functions': self.metadata.get('functions', {}),
                  'special_variables': self.metadata.get('special_variables', {}),
                  'subcontexts': self.metadata.get('subcontexts', {}),
                  'templates': self.metadata.get('templates', {})
              }, finder=self._finder)
  
              template.exec_in_sandbox(sandbox, *args, **kwargs)
  
              # This is gross, but allows the merge to happen. Eventually, the
              # merging will go away and template contexts emitted independently.
              klass = self._context.__class__
              self._context.__class__ = TemplateContext
              # The sandbox will do all the necessary checks for these merges.
              for key, value in context.items():
                  if isinstance(value, dict):
                      self[key].update(value)
                  elif isinstance(value, (list, HierarchicalStringList)):
                      self[key] += value
                  else:
                      self[key] = value
              self._context.__class__ = klass
  
              for p in context.all_paths:
                  self._context.add_source(p)
  
          return template_wrapper
function_tokens: def _create_template_wrapper ( self , template ) : def template_wrapper ( * args , * * kwargs ) : context = TemplateContext ( template = template . name , allowed_variables = self . _context . _allowed_variables , config = self . _context . config ) context . add_source ( self . _context . current_path ) for p in self . _context . all_paths : context . add_source ( p ) sandbox = MozbuildSandbox ( context , metadata = { # We should arguably set these defaults to something else. # Templates, for example, should arguably come from the state # of the sandbox from when the template was declared, not when # it was instantiated. Bug 1137319. 'functions' : self . metadata . get ( 'functions' , { } ) , 'special_variables' : self . metadata . get ( 'special_variables' , { } ) , 'subcontexts' : self . metadata . get ( 'subcontexts' , { } ) , 'templates' : self . metadata . get ( 'templates' , { } ) } , finder = self . _finder ) template . exec_in_sandbox ( sandbox , * args , * * kwargs ) # This is gross, but allows the merge to happen. Eventually, the # merging will go away and template contexts emitted independently. klass = self . _context . __class__ self . _context . __class__ = TemplateContext # The sandbox will do all the necessary checks for these merges. for key , value in context . items ( ) : if isinstance ( value , dict ) : self [ key ] . update ( value ) elif isinstance ( value , ( list , HierarchicalStringList ) ) : self [ key ] += value else : self [ key ] = value self . _context . __class__ = klass for p in context . all_paths : self . _context . add_source ( p ) return template_wrapper