:param target_type: string, either image, dockertar, ostree or dockerfile
774032
def get_instance(target_type, **kwargs):
        
        if target_type in TARGET_TYPES:
            cls = TARGET_TYPES[target_type]
            try:
                return cls(**kwargs)
            except Exception:
                logger.error("Please make sure that you picked the correct target type: "
                             "--target-type CLI option.")
                raise

        raise ColinException(
            "Unknown target type '{}'. Please make sure that you picked the correct target type: "
            "--target-type CLI option.".format(target_type))
889374
def targets(self):
        
        logging.info('Performing analysis with {at} targets folder'.format(at=self.analysistype))
        if self.pipeline:
            for sample in self.runmetadata:
                setattr(sample, self.analysistype, GenObject())
                if sample.general.bestassemblyfile != 'NA':
                    sample[self.analysistype].runanalysis = True
                    # Set attributes
                    try:
                        sample[self.analysistype].targetpath = \
                            os.path.join(self.targetpath, self.analysistype, sample.mash.closestrefseqgenus, '')
                    except AttributeError:
                        sample[self.analysistype].targetpath = \
                            os.path.join(self.targetpath, self.analysistype, sample.general.closestrefseqgenus, '')
                    # There is a relatively strict databasing scheme necessary for the custom targets. Eventually,
                    # there will be a helper script to combine individual files into a properly formatted combined file
                    try:
                        sample[self.analysistype].baitfile = glob(os.path.join(sample[self.analysistype].targetpath,
                                                                               '*.fasta'))[0]
                    # If the fasta file is missing, raise a custom error
                    except IndexError:
                        # Combine any .tfa files in the directory into a combined targets .fasta file
                        tfafiles = glob(os.path.join(sample[self.analysistype].targetpath, '*.tfa'))
                        if tfafiles:
                            combinetargets(tfafiles, sample[self.analysistype].targetpath)
                        try:
                            self.baitfile = glob(os.path.join(sample[self.analysistype].targetpath, '*.fasta'))[0]
                        except IndexError as e:
                            # noinspection PyPropertyAccess
                            e.args = [
                                'Cannot find the combined fasta file in {path}. Please note that the file must have a '
                                '.fasta extension'.format(path=sample[self.analysistype].targetpath)]
                            if os.path.isdir(sample[self.analysistype].targetpath):
                                raise
                            else:
                                sample[self.analysistype].runanalysis = False

                else:
                    sample[self.analysistype].runanalysis = False
            for sample in self.runmetadata:
                if sample.general.bestassemblyfile != 'NA' and sample[self.analysistype].runanalysis:
                    # Set the necessary attributes
                    sample[self.analysistype].outputdir = os.path.join(sample.run.outputdirectory, self.analysistype)
                    sample[self.analysistype].logout = os.path.join(sample[self.analysistype].outputdir, 'logout.txt')
                    sample[self.analysistype].logerr = os.path.join(sample[self.analysistype].outputdir, 'logerr.txt')
                    sample[self.analysistype].baitedfastq = \
                        os.path.join(sample[self.analysistype].outputdir,
                                     '{at}_targetMatches.fastq.gz'.format(at=self.analysistype))
        else:
            # There is a relatively strict databasing scheme necessary for the custom targets. Eventually, there will
            # be a helper script to combine individual files into a properly formatted combined file
            try:
                self.baitfile = glob(os.path.join(self.targetpath, '*.fasta'))[0]
            # If the fasta file is missing, raise a custom error
            except IndexError:
                # Combine any .tfa files in the directory into a combined targets .fasta file
                tfafiles = glob(os.path.join(self.targetpath, '*.tfa'))
                if tfafiles:
                    combinetargets(tfafiles, self.targetpath)
                try:
                    self.baitfile = glob(os.path.join(self.targetpath, '*.fasta'))[0]
                except IndexError as e:
                    # noinspection PyPropertyAccess
                    e.args = ['Cannot find the combined fasta file in {path}. Please note that the file must have a '
                              '.fasta extension'.format(path=self.targetpath)]
                    raise
            # Set all the necessary attributes
            for sample in self.runmetadata:
                setattr(sample, self.analysistype, GenObject())
                # Set attributes
                sample[self.analysistype].runanalysis = True
                sample[self.analysistype].baitfile = self.baitfile
                sample[self.analysistype].hashfile = self.hashfile
                sample[self.analysistype].hashcall = self.hashcall
                sample[self.analysistype].targetpath = self.targetpath
                sample[self.analysistype].outputdir = os.path.join(sample.run.outputdirectory, self.analysistype)
                sample[self.analysistype].logout = os.path.join(sample[self.analysistype].outputdir, 'logout.txt')
                sample[self.analysistype].logerr = os.path.join(sample[self.analysistype].outputdir, 'logerr.txt')
                sample[self.analysistype].baitedfastq = \
                    os.path.join(sample[self.analysistype].outputdir,
                                 '{at}_targetMatches.fastq.gz'.format(at=self.analysistype))
641260
def targets_to_stage(self, source_targets, ps):
        """"""

        result = []

        # Traverse the dependencies, if needed.
        if ps.get('install-dependencies') == ['on']:
            source_targets = self.collect_targets(source_targets)

        # Filter the target types, if needed.
        included_types = ps.get('install-type')
        for r in source_targets:
            ty = r.type()
            if ty:
                # Do not stage searched libs.
                if ty != "SEARCHED_LIB":
                    if included_types:
                        if self.include_type(ty, included_types):
                            result.append(r)
                    else:
                        result.append(r)
            elif not included_types:
                # Don't install typeless target if there is an explicit list of
                # allowed types.
                result.append(r)

        return result
127344
def _source_roots_for_target(target):
    
    def root_package_prefix(source_file):
      source = os.path.dirname(source_file)
      return os.path.join(get_buildroot(), target.target_base, source), source.replace(os.sep, '.')
    return {root_package_prefix(source) for source in target.sources_relative_to_source_root()}
201466
def type(self, mpath):
        
        try:
            return self.stat(mpath)["type"]
        except errors.MantaResourceNotFoundError:
            return None
        except errors.MantaAPIError:
            _, ex, _ = sys.exc_info()
            if ex.code in ('ResourceNotFound', 'DirectoryDoesNotExist'):
                return None
            else:
                raise
1293519
def process_prop(prop_type: PT, value, build_context):
    """"""
    if prop_type in (PT.Target, PT.TargetList):
        return hashify_targets(value, build_context)
    elif prop_type in (PT.File, PT.FileList):
        return hashify_files(value)
    return value
1240237
def _target_classes(self, target):
    
    target_classes = set()
    contents = ClasspathUtil.classpath_contents((target,), self.runtime_classpath)
    for f in contents:
      classname = ClasspathUtil.classname_for_rel_classfile(f)
      if classname:
        target_classes.add(classname)
    return target_classes
314965
def build(self, link_type, path):
        super(HeadLink, self).build()
        
        self.target = path
        self.link_type = link_type
        self.autoclosing = True
403180
def main_target_alternative (self, target):
        
        assert isinstance(target, AbstractTarget)
        target.project ().add_alternative (target)
        return target
170827
def _get_conversion_type(self, convert_to=None):
        '''

        '''
        acceptable = ['singularity', 'docker']

        # Default is to convert to opposite kind
        conversion = "singularity"
        if self.name == "singularity":
            conversion = "docker"

        # Unless the user asks for a specific type
        if convert_to is not None and convert_to in acceptable:
            conversion = convert_to
        return conversion
607585
def type_file(p_type = provider_type)
      if TypeGenerator::CORE_TYPES.include?(p_type)
        type_file = "puppet/type/#{p_type}.rb"
      else
        type_file = File.join(type_dir, "#{p_type}.rb")
      end
      type_file
    end
993322
def path_type(path, target):
    
    if os.path.isfile(path) and target == "file":
        return True
    elif os.path.isdir(path) and target == "directory":
        return True
    else:
        print("Error: Path given is not a {}: {}".format(target, path))
    return False
516510
function byType(appName, type, callback) {
    var url = format('/%s/apps/%s/containers/%s/', deis.version, appName, type);
    commons.get(url, callback);
  }
977336
def _instantiate_target(self, target_adaptor):
    """"""
    target_cls = self._target_types[target_adaptor.type_alias]
    try:
      # Pop dependencies, which were already consumed during construction.
      kwargs = target_adaptor.kwargs()
      kwargs.pop('dependencies')

      # Instantiate.
      if issubclass(target_cls, AppBase):
        return self._instantiate_app(target_cls, kwargs)
      elif target_cls is RemoteSources:
        return self._instantiate_remote_sources(kwargs)
      return target_cls(build_graph=self, **kwargs)
    except TargetDefinitionException:
      raise
    except Exception as e:
      raise TargetDefinitionException(
          target_adaptor.address,
          'Failed to instantiate Target with type {}: {}'.format(target_cls, e))
682080
def typeOf(cls, expected_type): #pylint: disable=no-self-argument,invalid-name,no-self-use
        
        if isinstance(expected_type, type):
            options = {}
            options["target_type"] = expected_type
            return Matcher("__TYPE__", options)
        ErrorHandler.matcher_type_error(expected_type)
929428
function getFileTypeReg(type) {
  var map = [],
    ext = fis.config.get('project.fileType.' + type);
  if (type === 'text') {
    map = TEXT_FILE_EXTS;
  } else if (type === 'image') {
    map = IMAGE_FILE_EXTS;
  } else {
    fis.log.error('invalid file type [%s]', type);
  }
  if (ext && ext.length) {
    if (typeof ext === 'string') {
      ext = ext.split(/\s*,\s*/);
    }
    map = map.concat(ext);
  }
  map = map.join('|');
  return new RegExp('\\.(?:' + map + ')$', 'i');
}
979598
def clone_and_change_target_type(self, base, type):
        """"""
        assert isinstance(base, basestring)
        assert isinstance(type, basestring)
        target_types = []
        for t in self.target_types_and_names_:
            m = _re_match_type.match(t)
            assert m

            if m.group(1) == base:
                if m.group(2):
                    target_types.append(type + m.group(2))
                else:
                    target_types.append(type)
            else:
                target_types.append(t)

        return self.__class__(self.id_, self.composing_,
                              self.source_types_,
                              target_types,
                              self.requirements_)