Return a ref context object given a location reference entry.
334147
def geo_context_from_ref(self, ref):
        """"""
        value = ref.get('value')
        if value:
            # Here we get the RefContext from the stashed geoloc dictionary
            rc = self.doc.geolocs.get(value['@id'])
            return rc
        return None
40075
def get_reference(self, refobj):
        
        c = cmds.listConnections("%s.referencenode" % refobj, d=False)
        return c[0] if c else None
1018810
def _add_referencer(registry):
    
    referencer = registry.queryUtility(IReferencer)
    if referencer is not None:
        return referencer
    ref = registry.settings['urireferencer.referencer']
    url = registry.settings['urireferencer.registry_url']
    r = DottedNameResolver()
    registry.registerUtility(r.resolve(ref)(url), IReferencer)
    return registry.queryUtility(IReferencer)
1010751
def fetchref(self, ref):
        """"""
        log.debug('[%s] Fetching ref: %s', self.name, ref)
        fetch_info = self.repo.remotes.origin.fetch(ref).pop()
        return fetch_info.ref
787358
def obj_deref(ref):
    """"""
    from indico_livesync.models.queue import EntryType
    if ref['type'] == EntryType.category:
        return Category.get_one(ref['category_id'])
    elif ref['type'] == EntryType.event:
        return Event.get_one(ref['event_id'])
    elif ref['type'] == EntryType.session:
        return Session.get_one(ref['session_id'])
    elif ref['type'] == EntryType.contribution:
        return Contribution.get_one(ref['contrib_id'])
    elif ref['type'] == EntryType.subcontribution:
        return SubContribution.get_one(ref['subcontrib_id'])
    else:
        raise ValueError('Unexpected object type: {}'.format(ref['type']))
315165
def get_context():
    """"""
    if not local_context._options:
        raise TelluricContextError("TelluricContext context not exists")
    else:
        log.debug("Got a copy of context %r options", local_context._options)
        return local_context._options.copy()
637817
def get(self, location_name):
        
        location_ref = location_helper(location_name, search_only=True)
        if location_ref:
            for location in self:
                if location.location_ref == location_ref:
                    return location
740755
def _get_ref(data, position, obj_end, opts, element_name):
    """"""
    collection, position = _get_string(
        data, position, obj_end, opts, element_name)
    oid, position = _get_oid(data, position, obj_end, opts, element_name)
    return DBRef(collection, oid), position
667760
def _make_context(self, entity):
        """"""
        loc_context = None
        time_context = None

        # Look for time and place contexts.
        for argument in entity["arguments"]:
            if argument["type"] == "place":
                entity_id = argument["value"]["@id"]
                loc_entity = self.concept_dict[entity_id]
                place = loc_entity.get("canonicalName")
                if not place:
                    place = loc_entity['text']
                geo_id = loc_entity.get('geoname_id')
                loc_context = RefContext(name=place, db_refs={"GEOID": geo_id})
            if argument["type"] == "time":
                entity_id = argument["value"]["@id"]
                temporal_entity = self.concept_dict[entity_id]
                text = temporal_entity['mentions'][0]['text']
                if len(temporal_entity.get("timeInterval", [])) < 1:
                    time_context = TimeContext(text=text)
                    continue
                time = temporal_entity["timeInterval"][0]
                start = datetime.strptime(time['start'], '%Y-%m-%dT%H:%M')
                end = datetime.strptime(time['end'], '%Y-%m-%dT%H:%M')
                duration = int(time['duration'])
                time_context = TimeContext(text=text, start=start, end=end,
                                           duration=duration)

        # Put context together
        context = None
        if loc_context or time_context:
            context = WorldContext(time=time_context, geo_location=loc_context)

        return context
878331
def _get_local_ref(region, ref_file, out_vcf_base):
    
    out_file = "{0}.fa".format(out_vcf_base)
    if not file_exists(out_file):
        with pysam.Fastafile(ref_file) as in_pysam:
            contig, start, end = region
            seq = in_pysam.fetch(contig, int(start), int(end))
            with open(out_file, "w") as out_handle:
                out_handle.write(">{0}-{1}-{2}\n{3}".format(contig, start, end,
                                                              str(seq)))
    with open(out_file) as in_handle:
        in_handle.readline()
        size = len(in_handle.readline().strip())
    return out_file, size
1219893
def _references(self, i, sequence=False):
        """"""

        value = ''

        c = next(i)
        if c == '\\':
            # \\
            if sequence and self.bslash_abort:
                raise PathNameException
            value = c
        elif c == '/':
            # \/
            if sequence:
                raise PathNameException
            i.rewind(1)
        else:
            # \a, \b, \c, etc.
            pass
        return value
1259518
def getreference(self, validate=True):
        """"""

        if self.offset is None: return None #nothing to test
        if self.ref:
            ref = self.doc[self.ref]
        else:
            ref = self.finddefaultreference()

        if not ref:
            raise UnresolvableTextContent("Default reference for textcontent not found!")
        elif not ref.hastext(self.cls):
            raise UnresolvableTextContent("Reference (ID " + str(ref.id) + ") has no such text (class=" + self.cls+")")
        elif validate and self.text() != ref.textcontent(self.cls).text()[self.offset:self.offset+len(self.data[0])]:
            raise UnresolvableTextContent("Reference (ID " + str(ref.id) + ", class=" + self.cls+") found but no text match at specified offset ("+str(self.offset)+")! Expected '" + self.text() + "', got '" + ref.textcontent(self.cls).text()[self.offset:self.offset+len(self.data[0])] +"'")
        else:
            #finally, we made it!
            return ref
200550
def get_context_first_matching_object(context, context_lookups):
    
    for key in context_lookups:
        context_object = context.get(key)
        if context_object:
            return key, context_object
    return None, None
434241
@Override
    public Object visitContextReference(ExcellentParser.ContextReferenceContext ctx) {
        String identifier = ctx.NAME().getText();
        return m_evalContext.resolveVariable(identifier);
    }
824513
def getContext(context):
    
    context = aq_parent(aq_base(context))
    if not context or IBrowserView.providedBy(context):
        return getSite()
    return context
241131
function mapLocalReference (node) {
    if ((node === undefined) || (node === null)) return undefined;
    var ref = _getFirstChildNS(node, 'Ref');
    if ((ref === undefined) || (ref === null)) return undefined;
    return getAttrValue(ref, 'id');
  }
204288
def spatialReference(self, value):
        """"""
        if isinstance(value, SpatialReference):
            self._spatialReference = value
        elif isinstance(value, int):
            self._spatialReference = SpatialReference(wkid=value)
        elif isinstance(value, str) and \
             str(value).isdigit():
            self._spatialReference = SpatialReference(wkid=int(value))
        elif isinstance(value, dict):
            wkid = None
            wkt = None
            if 'wkid' in value and \
               str(value['wkid']).isdigit():
                wkid = int(value['wkid'])
            if 'latestWkid' in value and \
               str(value['latestWkid']).isdigit():
                wkid = int(value['latestWkid'])
            if 'wkt' in value:
                wkt = value['wkt']
            self._spatialReference = SpatialReference(wkid=wkid,wkt=wkt)