Retrieve a relation label from the store.
326658
def get(self, cid1, cid2, annotator_id):
        '''
        '''
        t = (cid1, cid2, annotator_id)
        for k, v in self.kvl.scan(self.TABLE, (t, t)):
            return self._label_from_kvlayer(k, v)
990057
public Label getLabelByName(String name) {
        for (Label label : labels) {
            if (name.equals(label.getName())) {
                return label;
            }
        }
        return null;
    }
1249403
def get_album(self, object_id, relation=None, **kwargs):
        
        return self.get_object("album", object_id, relation=relation, **kwargs)
15708
def wait_for_relation(service_name, relation_name, timeout=120):
    """"""
    start_time = time.time()
    while True:
        relation = unit_info(service_name, 'relations').get(relation_name)
        if relation is not None and relation['state'] == 'up':
            break
        if time.time() - start_time >= timeout:
            raise RuntimeError('timeout waiting for relation to be up')
        time.sleep(SLEEP_AMOUNT)
923625
def store_relation(self, src, name, dst):
        '''  '''
        self.__require_string__(name)
        #print('storing relation', src, name, dst)
        # make sure both items are stored
        self.store_item(src).link(name, self.store_item(dst))
139966
def handle_label_relation(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        subject_node_dsl = self.ensure_node(tokens[SUBJECT])
        description = tokens[OBJECT]

        if self.graph.has_node_description(subject_node_dsl):
            raise RelabelWarning(
                line_number=self.get_line_number(),
                line=line,
                position=position,
                node=self.graph.node,
                old_label=self.graph.get_node_description(subject_node_dsl),
                new_label=description
            )

        self.graph.set_node_description(subject_node_dsl, description)
        return tokens
625287
def label(self, id):
        
        if self.ontology is not None:
            label = self.ontology.label(id)
            if label is not None:
                return label
        if self.subject_label_map is not None and id in self.subject_label_map:
            return self.subject_label_map[id]
        return None
303205
def by_label(self, label):
        """"""
        # don't use .first(), so that MultipleResultsFound can be raised
        try:
            return self.filter_by(label=label).one()
        except sa.orm.exc.NoResultFound:
            return None
1085109
def get_relation_type(self, relation):
        
        route_values = {}
        if relation is not None:
            route_values['relation'] = self._serialize.url('relation', relation, 'str')
        response = self._send(http_method='GET',
                              location_id='f5d33bc9-5b49-4a3c-a9bd-f3cd46dd2165',
                              version='5.1-preview.2',
                              route_values=route_values)
        return self._deserialize('WorkItemRelationType', response)
1292581
def query(self, label):
        
        try:
            return True, self.cache[label]
        except KeyError, e:
            return False, 0
401010
def get_label(key):
    
    if key in rel:
        if mpl.rcParams['text.usetex']:
            return rel[key]['label_latex']
        else:
            return rel[key]['label_mpl']
    else:
        return key
960147
def _get_current_label(self):
        """"""
        if len(self._last) == 0:
            raise StopIteration
        return self._last[:self._last.find(":")]
740396
def get_label(self, queryset, query_data):
        
        if query_data.get('label', False):
            return query_data['label']

        try:
            return queryset.model.__name__
        except AttributeError:
            return query_data['queryset'].model.__name__
413072
def get_value(self, label):
     
    for (key, value) in self.items:
      if key == label:
        return value
1370871
function(name, options) {
    const self = this
    const utils = self.store.utils

    // called every time before a parent query occures, with an include of this relation.
    // maybee the conditions of the parent query will contain variables whilch will let us
    // query this relation simultaneously.
    // e.g. Parent.find(99).include('children')
    //      with from: 'id' to: 'parent_id'
    //      99 => is the id!
    options.loadFromConditions =
      options.loadFromConditions ||
      function(parentCollection, parentConditions, include) {
        include = include || {}
        const conditions = utils.parentConditionsToConditions(
          parentConditions || [],
          options.from,
          options.to
        )
        if (!conditions) return

        return defaultFetch(parentCollection, conditions, include)
      }

    // called every time we need to fetch data for that relation
    options.loadFromRecords =
      options.loadFromRecords ||
      function(parentCollection, include, existingCollection) {
        include = include || {}

        const conditions = utils.recordsToConditions(
          parentCollection,
          options.from,
          options.to
        )
        if (!conditions) return Promise.resolve([]) // not enough info to form conditions. Better return an empty result instead of loading the whole dataset!

        return defaultFetch(
          parentCollection,
          conditions,
          include,
          existingCollection
        ).then(function(result) {
          // add the result to corresponding record
          parentCollection.forEach(function(record) {
            record.relations[name] = options.filterCache(record, result)
          })

          return result
        })
      }

    function defaultFetch(
      parentCollection,
      conditions,
      include,
      existingCollection
    ) {
      const relationCache = parentCollection.getInternal('relation_cache') || {}

      // return cached result, if available!
      if (relationCache[options.name]) {
        const result = relationCache[options.name]
        if (!result.then) return Promise.resolve(relationCache[options.name])
        return result
      }

      const query = options.model.where(conditions)
      if (options.conditions) query.where(options.conditions) // conditions on the relation
      if (options.scope) query[options.scope].apply(query, include.args) // scope on the relation
      if (include.conditions) query.where(include.conditions) // nested conditions via `where({relation_name: {...conditions...}})`
      if (include.children) query.include(include.children) // nested includes via `include({relation_name: {nested_relation_name: { ... }}})`
      if (include.scope) query[include.scope].apply(query, include.args) // scope defined via `include({relation_name: {$scope: 'myscope'}})`
      if (existingCollection) {
        const existingConditions = existingCollection.getInternal('conditions')
        const existingIncludes = existingCollection.getInternal('includes')

        if (existingIncludes) query.addInternal('includes', existingIncludes)
        if (existingConditions) {
          // add only new conditions
          const intConditions = query.getInternal('conditions')
          query.addInternal(
            'conditions',
            existingConditions.filter(function(c) {
              if (options.to.indexOf(c.attribute) !== -1) return false // ignore conditions with the target id field. existinCollection will automatically add such an id.

              var match = false
              intConditions.forEach(function(intC) {
                if (options.model.store.utils.compareObjects(c, intC, true))
                  match = true
              })
              return !match
            })
          )
        }

        utils.assignInternals(query, existingCollection, {
          exclude: ['relation', 'relation_to']
        })
      }

      const promise = query.then(function(result) {
        // overwrite cache result
        relationCache[options.name] = result
        return result
      })

      // store the promise in the cache object
      relationCache[options.name] = promise
      parentCollection.setInternal('relation_cache', relationCache)

      return promise
    }

    // called with every parent and child record. returns true/false for matching relations
    options.filterCache =
      options.filterCache ||
      function(parentRecord, records) {
        if (options.model) {
          const chain = options.model.chain()

          if (records) {
            if (!Array.isArray(records)) records = [records]
            const relatedRecords = records.filter(function(record) {
              var match = true

              options.from.forEach(function(key, index) {
                const opposite = options.to[index]
                const val1 = parentRecord[key]
                const val2 = record[opposite]
                if (!utils.checkFieldEquality(val1, val2)) match = false
              })
              return match
            })

            chain.add(relatedRecords) // add all child records
            chain._exists() // set this collection as existing (all records fetched from the datastore!)
          }

          chain.setInternal('relation', options) // add the parent relation of this collection
          chain.setInternal('relation_to', parentRecord) // + the parent record

          return chain
        }

        throw new Error('You need to implement your own `filterCache` function!')
      }

    options.getFromCache = function(parentRecord, include, existingCollection) {
      const parentCollection =
        parentRecord.__chainedModel ||
        parentRecord.model.chain().add(parentRecord)

      return options
        .loadFromRecords(parentCollection, include || {}, existingCollection)
        .then(function(result) {
          if (!result) return null
          return options.filterCache(parentRecord, result)
        })
    }

    return options
  }
775992
def relation_get(attribute=None, unit=None, rid=None):
    """"""
    _args = ['relation-get', '--format=json']
    if rid:
        _args.append('-r')
        _args.append(rid)
    _args.append(attribute or '-')
    if unit:
        _args.append(unit)
    try:
        return json.loads(subprocess.check_output(_args).decode('UTF-8'))
    except ValueError:
        return None
    except CalledProcessError as e:
        if e.returncode == 2:
            return None
        raise
23957
def label(self):
        ""
        if self._label:
            return self._label
        else:
            if len(self):
                label = get_ndmapping_label(self, 'label')
                return '' if label is None else label
            else:
                return ''