Tells whether an artifact is flagged as optional or not.

    Args:
        chain (ChainOfTrust): the chain of trust object
        task_id (str): the id of the aforementioned task

    Returns:
        bool: True if artifact is optional
480709
def is_artifact_optional(chain, task_id, path):
    
    upstream_artifacts = chain.task['payload'].get('upstreamArtifacts', [])
    optional_artifacts_per_task_id = get_optional_artifacts_per_task_id(upstream_artifacts)
    return path in optional_artifacts_per_task_id.get(task_id, [])
199007
function verifyTasks() {
      if ( options.tasks.build ) {
        if ( isTypeString(options.tasks.build) ) {
          options.tasks.build = [options.tasks.build];
        }
        if ( util.isArray(options.tasks.build) ) {
          options.tasks.build.forEach(function( item ) {
            if ( !isTypeString(item) ) {
              errorOption('tasks.build', JSON.stringify(item));
            }
          });
        }
        else {
          errorOption('tasks.build', options.tasks.build);
        }
      }
      else {
        options.tasks.build = [];
      }
    }
1220245
def chain_present(name, table='filter', table_type=None, hook=None, priority=None, family='ipv4'):
    '''
    
    '''

    ret = {'name': name,
           'changes': {},
           'result': None,
           'comment': ''}

    chain_check = __salt__['nftables.check_chain'](table, name, family=family)
    if chain_check['result'] is True:
        ret['result'] = True
        ret['comment'] = ('nftables {0} chain is already exist in {1} table for {2}'
                          .format(name, table, family))
        return ret

    res = __salt__['nftables.new_chain'](
            table,
            name,
            table_type=table_type,
            hook=hook,
            priority=priority,
            family=family
    )

    if res['result'] is True:
        ret['changes'] = {'locale': name}
        ret['result'] = True
        ret['comment'] = ('nftables {0} chain in {1} table create success for {2}'
                          .format(name, table, family))
        return ret
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to create {0} chain in {1} table: {2} for {3}'.format(
            name,
            table,
            res['comment'].strip(),
            family
        )
        return ret
641780
def _should_sign_request_header(header_name):
    

    if header_name in {_HEADER_USER_AGENT, _HEADER_CACHE_CONTROL}:
        return True

    if re.match(_PATTERN_HEADER_PREFIX_BUNQ, header_name):
        return True

    return False
320524
def validators(*chained_validators):
    
    def validator_chain(match):  # pylint:disable=missing-docstring
        for chained_validator in chained_validators:
            if not chained_validator(match):
                return False
        return True
    return validator_chain
582326
private static Chain isKnownChain(String asymId, List<Chain> chains){

		for (int i = 0; i< chains.size();i++){
			Chain testchain =  chains.get(i);
			//System.out.println("comparing chainID >"+chainID+"< against testchain " + i+" >" +testchain.getName()+"<");
			if (asymId.equals(testchain.getId())) {
				//System.out.println("chain "+ chainID+" already known ...");
				return testchain;
			}
		}

		return null;
	}
1206205
function(chain) {
      var method = status > 0 ? "resolve" :
                   status < 0 ? "reject" :
                   null;
      if (method) for (var i in chain) {
        chain[i][method](result);
      }
    }
1139099
def has_next_async(self):
    
    if self._fut is None:
      self._fut = self._iter.getq()
    flag = True
    try:
      yield self._fut
    except EOFError:
      flag = False
    raise tasklets.Return(flag)
736259
def async_chain(chain, group=None, cached=Conf.CACHED, sync=Conf.SYNC, broker=None):
    
    if not group:
        group = uuid()[1]
    args = ()
    kwargs = {}
    task = chain.pop(0)
    if type(task) is not tuple:
        task = (task,)
    if len(task) > 1:
        args = task[1]
    if len(task) > 2:
        kwargs = task[2]
    kwargs['chain'] = chain
    kwargs['group'] = group
    kwargs['cached'] = cached
    kwargs['sync'] = sync
    kwargs['broker'] = broker or get_broker()
    async_task(task[0], *args, **kwargs)
    return group
81034
def task(self):
        
        # If we have no .task_id, this is a no-op to return None.
        if not self.task_id:
            return defer.succeed(None)
        return self.connection.getTaskInfo(self.task_id)
1236816
def enable_pow_mining(chain_class: Type[BaseChain]) -> Type[BaseChain]:
    
    if not chain_class.vm_configuration:
        raise ValidationError("Chain class has no vm_configuration")

    vm_configuration = _mix_in_pow_mining(chain_class.vm_configuration)
    return chain_class.configure(vm_configuration=vm_configuration)
1360497
function isChainable(version, method) {
    const data = getMethodData(version)
    return _.get(data, [getMainAlias(version, method), 'chainable'], false)
}
49833
def verify_valid_dependencies(self):
        

        unobserved_dependencies = set(self.tasks.keys())
        target_queue = []

        while len(unobserved_dependencies) > 0:
            target_queue = [unobserved_dependencies.pop()]

            while target_queue is not []:
                target_queue += unobserved_dependencies
1223890
def verify_docker_image_sha(chain, link):
    
    cot = link.cot
    task = link.task
    errors = []

    if isinstance(task['payload'].get('image'), dict):
        # Using pre-built image from docker-image task
        docker_image_task_id = task['extra']['chainOfTrust']['inputs']['docker-image']
        log.debug("Verifying {} {} against docker-image {}".format(
            link.name, link.task_id, docker_image_task_id
        ))
        if docker_image_task_id != task['payload']['image']['taskId']:
            errors.append("{} {} docker-image taskId isn't consistent!: {} vs {}".format(
                link.name, link.task_id, docker_image_task_id,
                task['payload']['image']['taskId']
            ))
        else:
            path = task['payload']['image']['path']
            # we need change the hash alg everywhere if we change, and recreate
            # the docker images...
            image_hash = cot['environment']['imageArtifactHash']
            alg, sha = image_hash.split(':')
            docker_image_link = chain.get_link(docker_image_task_id)
            upstream_sha = docker_image_link.cot['artifacts'].get(path, {}).get(alg)
            if upstream_sha is None:
                errors.append("{} {} docker-image docker sha {} is missing! {}".format(
                    link.name, link.task_id, alg,
                    docker_image_link.cot['artifacts'][path]
                ))
            elif upstream_sha != sha:
                errors.append("{} {} docker-image docker sha doesn't match! {} {} vs {}".format(
                    link.name, link.task_id, alg, sha, upstream_sha
                ))
            else:
                log.debug("Found matching docker-image sha {}".format(upstream_sha))
    else:
        prebuilt_task_types = chain.context.config['prebuilt_docker_image_task_types']
        if prebuilt_task_types != "any" and link.task_type not in prebuilt_task_types:
            errors.append(
                "Task type {} not allowed to use a prebuilt docker image!".format(
                    link.task_type
                )
            )
    raise_on_errors(errors)
1136436
function has(tasks, when) {
  if (!tasks) {
    return false;
  }
  if (!when) {
    if (tasks.length) {
      return true;
    }
    return false;
  }
  return !!utils.classify(tasks)[when].length;
}
1105418
def stop_artifact_creation(self, id_or_uri, task_uri):
        
        data = {
            "taskUri": task_uri
        }

        uri = self.URI + '/' + extract_id_from_uri(id_or_uri) + self.STOP_CREATION_PATH

        return self._client.update(data, uri=uri)
1068119
boolean doWork(long txnId, TransactionTask task)
    {
        boolean retval = canAcceptWork();
        if (!retval) {
            return false;
        }
        MpRoSiteContext site;
        // Repair case
        if (m_busySites.containsKey(txnId)) {
            site = m_busySites.get(txnId);
        }
        else {
            if (m_idleSites.isEmpty()) {
                MpRoSiteContext newSite = new MpRoSiteContext(m_siteId,
                        m_backend,
                        m_catalogContext,
                        m_partitionId,
                        m_initiatorMailbox,
                        m_poolThreadFactory);
                m_idleSites.push(newSite);
                m_allSites.add(newSite);
            }
            site = m_idleSites.pop();
            m_busySites.put(txnId, site);
        }
        site.offer(task);
        return true;
    }