_________________________________ local context management
423331
function(context, args, stack) {
		var ctx = new Context(args[0], args[1] || context);
		stack.push(ctx);
		return ctx;
	}
898765
@Override
	public void updateContext() {

		if( this.changeStateInstruction == ChangeStateInstruction.DELETE ) {

			// Find the path of the instances to remove
			Set<String> pathOfInstancesToRemove = new HashSet<> ();
			if( this.instancePath != null ) {
				pathOfInstancesToRemove.add( this.instancePath );

			} else for( Map.Entry<String,String> entry : this.context.instancePathToComponentName.entrySet()) {
				if( this.componentName.equals( entry.getValue()))
					pathOfInstancesToRemove.add( entry.getKey());
			}

			// Now, delete the instances that need to eb erased
			List<String> keys = new ArrayList<>( this.context.instancePathToComponentName.keySet());
			for( String path : keys ) {
				for( String pathToRemove : pathOfInstancesToRemove ) {

					if( path.equals( pathToRemove )
							|| path.startsWith( pathToRemove + "/" ))
						this.context.instancePathToComponentName.remove( path );
				}
			}
		}
	}
87471
def _setup(self):
        ""
        self.example.error = None
        self.example.traceback = ''
        # inject function contexts from parent functions
        c = Context(parent=self.context)
        #for parent in reversed(self.example.parents):
        #    c._update_properties(locals_from_function(parent))
        self.context = c
        if self.is_root_runner:
            run.before_all.execute(self.context)
        self.example.before(self.context)
676750
private void updateContext(Container c ,int maxCtx, int ctxSteps, boolean keepCustomValues)
  {

    if(!keepCustomValues)
    {
      c.removeAllItems();
    }
    
    for (Integer i : PREDEFINED_CONTEXTS)
    {
      if (i < maxCtx)
      {
        c.addItem(i);
      }
    }

    for (int step = ctxSteps; step < maxCtx; step += ctxSteps)
    {
      c.addItem(step);
    }

    c.addItem(maxCtx);

  }
454732
def set_context(context):
    """"""
    try:
        handler = logging.getLogger().handlers[0]
    except IndexError:
        # logging is not initialized
        return
    if not isinstance(handler, StructuredHandler):
        return
    handler.acquire()
    try:
        handler.local.context = context
    finally:
        handler.release()
863624
def reduce_contexts(parent, local):

  """"""

  context = {}

  for k,v in parent.items():
    if type(v) == dict:
      d = v.copy()
      d.update(local.get(k,{}))
      context[k] = d
    elif type(v) == list:
      context[k] = v + ensure_list(local.get(k,[]))
    else:
      context[k] = local.get(k,v)

  for k in set(local.keys()) - set(parent.keys()):
    context[k] = local[k]

  return context
2411
def prepare(self, context):
		""""""
		if __debug__:
			log.debug("Assigning thread local request context.")
		
		self.local.context = context
311273
def _clear_context():
    '''
    
    '''
    for var in [x for x in __context__ if x.startswith('lxc.')]:
        log.trace('Clearing __context__[\'%s\']', var)
        __context__.pop(var, None)
827650
def inject_context(self, __context_dict__=None, **context):
        
        context = context or __context_dict__
        self.context_keys |= set(context.keys())
        for key, value in context.items():
            setattr(self, key, value)
        for command in self.subcommands.values():
            command.inject_context(context)
1372898
public static void enrichContext(Context context) {
		context.setPostProperty(Context.MEMORY_TOTAL, Runtime.getRuntime().totalMemory());
		context.setPostProperty(Context.MEMORY_FREE, Runtime.getRuntime().freeMemory());
		context.setPostProperty(Context.MEMORY_USED, Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
	}
968296
protected void setContext(Context context) throws CpoException {
    try {
      if (context == null) {
        context_ = new InitialContext();
      } else {
        context_ = context;
      }
    } catch (NamingException e) {
      throw new CpoException("Error setting Context", e);
    }
  }
662729
function Context() {
	/**
	 * @member {Object}
	 * @property {Object} client
	 * @property {Object<Call>} client.map - map from call name and call id
	 * @property {Array<Call>} client.list
	 * @property {Object} server
	 * @property {Object<Call>} server.map - map from call name and call id
	 * @property {Array<Call>} server.list
	 * @private
	 */
	this._calls = {
		client: {
			map: Object.create(null),
			list: []
		},
		server: {
			map: Object.create(null),
			list: []
		}
	}

	/**
	 * @member {Object}
	 * @property {Object} client
	 * @property {Object<Message>} client.map - map from message name and message id
	 * @property {Array<Message>} client.list
	 * @property {Object} server
	 * @property {Object<Message>} server.map - map from message name and message id
	 * @property {Array<Message>} server.list
	 * @private
	 */
	this._messages = {
		client: {
			map: Object.create(null),
			list: []
		},
		server: {
			map: Object.create(null),
			list: []
		}
	}
}
714132
static void releaseContext(SeaGlassContext context) {
        synchronized (contextMap) {
            List instances = (List) contextMap.get(context.getClass());

            if (instances == null) {
                instances = new ArrayList(5);
                contextMap.put(context.getClass(), instances);
            }

            instances.add(context);
        }
    }
236225
function setupContextMenu() {
  var enableContextMenuItem = contextMenu.Item({
    label: 'Enable For This URL',
    data: 'toggle',
    contentScript:
        "self.on('context', function(node) {" +
        "  var hasWtf = !!document.querySelector('.wtf_a');" +
        "  return !hasWtf ? 'Enable For This URL' : 'Disable For This URL';" +
        "});"
  });
  var resetSettingsContextMenuItem = contextMenu.Item({
    label: 'Reset Settings For This URL',
    data: 'reset'
  });
  var showUiContextMenuItem = contextMenu.Item({
    label: 'Show UI',
    data: 'show_ui'
  });
  var rootContextMenuItem = contextMenu.Menu({
    label: 'Tracing Framework',
    items: [
      enableContextMenuItem,
      resetSettingsContextMenuItem,
      contextMenu.Separator(),
      showUiContextMenuItem
    ],
    contentScript:
        "self.on('click', function(node, data) {" +
        "  self.postMessage(data);" +
        "});",
    onMessage: function(action) {
      switch (action) {
        case 'toggle':
          toggleInjectionForActiveTab();
          break;
        case 'reset':
          resetOptionsForActiveTab();
          break;
        case 'show_ui':
          showUi();
          break;
      }
    }
  });
}
1347014
function RootContext(argv, profileFilenames, view) {
  var self = {
      commands: COMMANDS, // Overwritten when interactive
      profileFilenames: profileFilenames,
      interactive: false,
      argv: argv,
      view: view,
      config: null,
      nick: null,
      privkey: null,
      hubClient: null,
      voxClient: null,
  };

  self.initWithConfig = function(config) {
    if (self.voxClient) {
      throw new Error('Already initialized!');
    }

    self.config = config;
    self.nick = config.nick;

    self.voxClient = new VoxClient({
        config: config,
        agentString: AGENT_STRING,
    });
    return self.voxClient.connect();
  }

  self.reinitWithConfig = function(config) {
    self.close();
    return self.initWithConfig(config);
  }

  self.close = function() {
    if (self.voxClient) {
      self.voxClient.close();
      self.voxClient = null;
    }
  }

  /**
   * Logs connection status events.
   */
  self.listenForConnectionStatusEvents = function() {
    self.voxClient.on('connect', function(info) {
      self.view.log(colors.cyan.dim('Connected: ' + info.interchangeUrl));
    });
    self.voxClient.on('disconnect', function(info) {
      self.view.log(colors.red.dim('Disconnected: ' + info.interchangeUrl));
    });
    self.voxClient.on('error', function(info) {
      self.view.log(colors.red.dim('Connection error: ' + info.interchangeUrl));
    });
    self.voxClient.on('reconnect_failed', function(info) {
      self.view.log(colors.red.dim('Reconnection failed: ' + info.interchangeUrl));
    });
  }

  self.printJson = function(obj_or_name, obj) {
    if (obj !== undefined) {
      self.view.log('%s %s', obj_or_name, JSON.stringify(obj));
    } else {
      self.view.log(JSON.stringify(obj_or_name));
    }
  }

  return self;
}
685113
function(context) {
      var varName,
          localVars = [];
      for (varName in context) {
        localVars.push('var ' + varName + ' = context.' + varName + ';');
      }
      return localVars.join('\n');
    }
413200
def reset_context(**options):
    """"""
    local_context._options = {}
    local_context._options.update(options)
    log.debug("New TelluricContext context %r created", local_context._options)