Lower ContextFieldExistence expressions into lower-level expressions.
327511
def lower_context_field_existence(ir_blocks, query_metadata_table):
    """"""
    def regular_visitor_fn(expression):
        """Expression visitor function that rewrites ContextFieldExistence expressions."""
        if not isinstance(expression, ContextFieldExistence):
            return expression

        location_type = query_metadata_table.get_location_info(expression.location).type

        # Since this function is only used in blocks that aren't ConstructResult,
        # the location check is performed using a regular ContextField expression.
        return BinaryComposition(
            u'!=',
            ContextField(expression.location, location_type),
            NullLiteral)

    def construct_result_visitor_fn(expression):
        """Expression visitor function that rewrites ContextFieldExistence expressions."""
        if not isinstance(expression, ContextFieldExistence):
            return expression

        location_type = query_metadata_table.get_location_info(expression.location).type

        # Since this function is only used in ConstructResult blocks,
        # the location check is performed using the special OutputContextVertex expression.
        return BinaryComposition(
            u'!=',
            OutputContextVertex(expression.location, location_type),
            NullLiteral)

    new_ir_blocks = []
    for block in ir_blocks:
        new_block = None
        if isinstance(block, ConstructResult):
            new_block = block.visit_and_update_expressions(construct_result_visitor_fn)
        else:
            new_block = block.visit_and_update_expressions(regular_visitor_fn)
        new_ir_blocks.append(new_block)

    return new_ir_blocks
189404
function EE(fn, context, once) {
  this.fn = fn;
  this.context = context;
  this.once = once || false;
}
695272
function(contexts) {

        if ( typeof(contexts) == 'undefined' ) {
            var contexts = {
                paths : {}
            }
        }

        self.contexts = contexts;

        if ( typeof(ContextHelper.initialized) != 'undefined' && ContextHelper.instance) {
            self = ContextHelper.instance;
        } else {
            ContextHelper.initialized = true;
            ContextHelper.instance = self
        }



        return self
    }
816600
protected void _generate(SarlField field, PyAppendable it, IExtraLanguageGeneratorContext context) {
		if (field.isStatic()) {
			// Static field
			generatePythonField(field, it, context);
		} else {
			final String key = this.qualifiedNameProvider.getFullyQualifiedName(field.getDeclaringType()).toString();
			final List<SarlField> fields = context.getMultimapValues(INSTANCE_VARIABLES_MEMENTO, key);
			fields.add(field);
		}
	}
821957
function buildElementsTree(contexts) {

	contexts = contexts || [document];

	var queriesArray = Object.keys(queries).map(function(key) {
		return queries[key];
	});

	var selector = queriesArray.map(function(query) {
		return query._selector;
	}).join(',');

	var elements = [];
	contexts.forEach(function(context) {
		for (var node = context.parentNode; node; node = node.parentNode) {
			// Skip nested contexts
			if (contexts.indexOf(node) !== -1) {
				return;
			}
		}
		if (context !== document && elementMatchesSelector(context, selector)) {
			elements.push(context);
		}
		elements.push.apply(elements, arrayFrom(context.querySelectorAll(selector)));
	});

	var tree = [];
	var treeCache = createCacheMap();

	elements.forEach(function(element) {

		if (element === documentElement) {
			return;
		}

		var treeNode = {
			_element: element,
			_children: [],
			_queries: [],
			_changes: [],
			_done: false,
		};

		var children = tree;
		for (var node = element.parentNode; node; node = node.parentNode) {
			if (treeCache.get(node)) {
				children = treeCache.get(node)._children;
				break;
			}
		}

		treeCache.set(element, treeNode);

		children.push(treeNode);

		queriesArray.forEach(function(query) {
			if (elementMatchesSelector(element, query._selector)) {
				treeNode._queries.push(query);
			}
		});

	});

	return tree;

}
1047820
def _context_names():
    """"""
    import inspect

    from renku.models import provenance
    from renku.models._jsonld import JSONLDMixin

    for name in dir(provenance):
        cls = getattr(provenance, name)
        if inspect.isclass(cls) and issubclass(cls, JSONLDMixin):
            yield name
1228937
function(fn, context){
      var cursor = this;
      while (cursor = cursor.handler)
        if (cursor.fn === fn && cursor.context === context)
          console.warn('duplicate fn & context pair');

      this.handler = {
        fn: fn,
        context: context,
        handler: this.handler
      };
    }
826765
def iterate_over_fields(cls):
        """"""
        for attr in dir(cls):
            clsattr = getattr(cls, attr)
            if isinstance(clsattr, BaseField):
                yield attr, clsattr
124496
function fixTemplateContext(template, fix) {
    var _template_r = template.r;
    template.r = function(contextStack) {
        var context = contextStack[contextStack.length-1];
        contextStack[contextStack.length-1] = fix(context);
        return _template_r.apply(this,arguments);
    };
}
626785
private Context translateDereference(WyilFile.Expr.Dereference lval, Expr rval, Context context) {
		Expr e = translateDereference(lval, context.getEnvironment());
		return context.assume(new Expr.Equal(e, rval));
	}
1261420
def generate_additional_context(self, matching_datasets):
        """"""
        top_tags = Tag.objects.filter(
            dataset__in=matching_datasets
        ).annotate(
            tag_count=Count('word')
        ).order_by('-tag_count')[:3]

        return {
            'top_tags': top_tags
        }
675143
function liftContextG(ctx, gen) {
  return liftContext(ctx, function() {
    return liftContextIterator(ctx, gen.apply(null, arguments));
  });
}
1255585
def __objecthasfields(bunchdt, data, commdct, idfobject, places=7, **kwargs):
    """"""
    for key, value in list(kwargs.items()):
        if not isfieldvalue(
                bunchdt, data, commdct,
                idfobject, key, value, places=places):
            return False
    return True
351892
private List<List<IType>> extractContextTypes( List<? extends IInvocableType>  funcTypes )
  {
    if( funcTypes != null )
    {
      ArrayList<List<IType>> returnList = new ArrayList<>();
      for( IInvocableType funcType : funcTypes )
      {
        for( int i = 0; i < funcType.getParameterTypes().length; i++ )
        {
          IType paramType = funcType.getParameterTypes()[i];
          if( i >= returnList.size() )
          {
            returnList.add( new ArrayList<>() );
          }
          List<IType> paramTypeList = returnList.get( i );
          if( !paramTypeList.contains( paramType ) )
          {
            paramTypeList.add( paramType );
          }
        }
      }
      return returnList;
    }
    else
    {
      return Collections.emptyList();
    }
  }
116432
private IContext findMultiwordsInContextStructure(IContext context) throws ContextPreprocessorException {
        for (Iterator<INode> i = context.getNodes(); i.hasNext(); ) {
            INode sourceNode = i.next();
            // sense disambiguation within the context structure
            // for all ACoLs in the source node
            for (Iterator<IAtomicConceptOfLabel> j = sourceNode.getNodeData().getACoLs(); j.hasNext(); ) {
                IAtomicConceptOfLabel synSource = j.next();
                // in all descendants and ancestors
                findMultiwordsAmong(sourceNode.getDescendants(), synSource);
                findMultiwordsAmong(sourceNode.getAncestors(), synSource);
            }
        }
        return context;
    }
541695
def eval_expr(expr, context):
    
    if isinstance(expr, list):
        rv = []
        for item in expr:
            rv.append(eval_expr(item, context))
        return rv
    if isinstance(expr, dict):
        rv = {}
        for k, v in expr.iteritems():
            rv[k] = eval_expr(v, context)
        kwargs = rv.pop("__kwargs", None)
        if kwargs:
            rv.update(kwargs)
        return rv
    if isinstance(expr, Expression):
        return expr.eval(context)
    return expr
960453
def leftcontext(self, size, placeholder=None, scope=None):
        """"""

        if size == 0: return [] #for efficiency

        context = []
        e = self
        while len(context) < size:
            e = e.previous(True,scope)
            if not e: break
            context.append(e)

        if placeholder:
            while len(context) < size:
                context.append(placeholder)

        context.reverse()
        return context