Create an entry and object for given evidence if it does not exist.
172414
def get_or_create_evidence(self, citation: Citation, text: str) -> Evidence:
        """"""
        sha512 = hash_evidence(text=text, type=str(citation.type), reference=str(citation.reference))

        if sha512 in self.object_cache_evidence:
            evidence = self.object_cache_evidence[sha512]
            self.session.add(evidence)
            return evidence

        evidence = self.get_evidence_by_hash(sha512)

        if evidence is not None:
            self.object_cache_evidence[sha512] = evidence
            return evidence

        evidence = Evidence(
            text=text,
            citation=citation,
            sha512=sha512,
        )

        self.session.add(evidence)
        self.object_cache_evidence[sha512] = evidence
        return evidence
886036
def insert_before(self, key, new_item, instance=0):
        """"""
        self._insert_item(key, new_item, instance, False)
446929
def create(self, item, dry_run=None):
        """"""
        logger.debug('Creating new item. Item: {item} Path: {data_file}'.format(
            item=item,
            data_file=self.data_file
        ))

        items = load_file(self.client, self.bucket_name, self.data_file)
        items = append_item(self.namespace, self.version, item, items)
        save_file(self.client, self.bucket_name, self.data_file, items, dry_run=dry_run)

        return item
281057
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'type' in _dict:
            args['type'] = _dict.get('type')
        if 'frequency' in _dict:
            args['frequency'] = _dict.get('frequency')
        if 'arguments' in _dict:
            args['arguments'] = [
                QueryRelationsArgument._from_dict(x)
                for x in (_dict.get('arguments'))
            ]
        if 'evidence' in _dict:
            args['evidence'] = [
                QueryEvidence._from_dict(x) for x in (_dict.get('evidence'))
            ]
        return cls(**args)
501872
function(entry) {
        if (entry) {
            if (successCallback) {
                // create appropriate Entry object
                var fsName = entry.filesystemName || (entry.filesystem == window.PERSISTENT ? 'persistent' : 'temporary');
                fileSystems.getFs(fsName, function(fs) {
                    var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath, fs, entry.nativeURL) : new FileEntry(entry.name, entry.fullPath, fs, entry.nativeURL);
                    successCallback(result);
                });
            }
        }
        else {
            // no Entry object returned
            fail(FileError.NOT_FOUND_ERR);
        }
    }
39724
def append(self, value):
        """"""
        if self.asserted:
            raise RuntimeError("Fact already asserted")

        self._multifield.append(value)
72347
def checkAndCreate(self, key, payload):
        
        if key not in self:
            self[key] = payload
        return self[key]['id']
706700
def _insert_item(self, key, new_item, instance, is_after):
        """"""
        index = self._get_index_for_insert(key, instance)
        index = index + 1 if is_after else index
        self.__items = self.__items[:index] + new_item + self.__items[index:]
        # Make sure indexing works with new items
        for new_key, new_value in new_item:
            if new_key in self:
                value_list = [val for k, val in self.__items if k == new_key]
                dict_setitem(self, new_key, value_list)
            else:
                dict_setitem(self, new_key, [new_value])
781037
def handle_set_evidence(self, _, __, tokens: ParseResults) -> ParseResults:
        """"""
        self.evidence = tokens['value']
        return tokens
1302219
def _check_object_exists(self):
        
        if not DB.get_keys(self.key):
            raise KeyError("Object with key '{}' not exist".format(self.key))
269474
def create(self, key, value=None, dir=False, ttl=None, timeout=None):
        """"""
        return self.adapter.set(key, value, dir=dir, ttl=ttl,
                                prev_exist=False, timeout=timeout)
260441
public void storeSkipExisting(Entry entry) throws MissingParentException {
        try {
            store(entry);
        } catch (EntryAlreadyExistsException e) {
            LOGGER.debug("Entry already exists. Skipping.");
        }
    }
1084271
def create(data=None, id=None, message=None):
        

        return Error(
            data=data,
            id=id,
            message=message,
        )
446147
def create(self, ex):
    ""
    if ex.name in self:
      if ex.nexists: return
      raise ValueError('table_exists',ex.name)
    if any(c.pkey for c in ex.cols):
      if ex.pkey:
        raise sqparse2.SQLSyntaxError("don't mix table-level and column-level pkeys",ex)
      # todo(spec): is multi pkey permitted when defined per column?
      ex.pkey = sqparse2.PKeyX([c.name for c in ex.cols if c.pkey])
    if ex.inherits:
      # todo: what if child table specifies constraints etc? this needs work.
      if len(ex.inherits) > 1: raise NotImplementedError('todo: multi-table inherit')
      parent = self[ex.inherits[0]] = copy.deepcopy(self[ex.inherits[0]]) # copy so rollback works
      child = self[ex.name] = table.Table(ex.name, parent.fields, parent.pkey)
      parent.child_tables.append(child)
      child.parent_table = parent
    else:
      self[ex.name]=table.Table(ex.name,ex.cols,ex.pkey.fields if ex.pkey else [])
960521
def check(self):
        """"""
        # Make sure there is a schema key in dict
        if self._KEYS.SCHEMA not in self:
            self[self._KEYS.SCHEMA] = self.catalog.SCHEMA.URL
        # Make sure there is a name key in dict
        if (self._KEYS.NAME not in self or len(self[self._KEYS.NAME]) == 0):
            raise ValueError("Entry name is empty:\n\t{}".format(
                json.dumps(
                    self, indent=2)))
        return
749183
function(json){
  
  // Protect against forgetting the new keyword when calling the constructor
  if(!(this instanceof EvidenceReference)){
    return new EvidenceReference(json);
  }
  
  // If the given object is already an instance then just return it. DON'T copy it.
  if(GedcomX.ResourceReference.isInstance(json)){
    return json;
  }
  
  this.init(json);
}
884684
def if_not_exists(self):
        
        if self.model._has_counter:
            raise IfNotExistsWithCounterColumn('if_not_exists cannot be used with tables containing counter columns')
        clone = copy.deepcopy(self)
        clone._if_not_exists = True
        return clone