Converts several files to consumable types.
777081
def convert_multiple_sources_to_consumable_types (self, project, prop_set, sources):
        
        if __debug__:
            from .targets import ProjectTarget

            assert isinstance(project, ProjectTarget)
            assert isinstance(prop_set, property_set.PropertySet)
            assert is_iterable_typed(sources, virtual_target.VirtualTarget)
        if not self.source_types_:
            return list(sources)

        acceptable_types = set()
        for t in self.source_types_:
            acceptable_types.update(type.all_derived(t))

        result = []
        for source in sources:
            if source.type() not in acceptable_types:
                transformed = construct_types(
                    project, None,self.source_types_, prop_set, [source])
                # construct_types returns [prop_set, [targets]]
                for t in transformed[1]:
                    if t.type() in self.source_types_:
                        result.append(t)
                if not transformed:
                    project.manager().logger().log(__name__, "  failed to convert ", source)
            else:
                result.append(source)

        result = sequence.unique(result, stable=True)
        return result
163756
private Set<String> convertAbsToRelative(Collection<File> files) {
        Set<String> result = new HashSet<String>();
        for (File f : files) {
            String fAbsPath = PathUtils.fixPathString(f); //assumption here that f is a dir, and path will end in File.seperator
            if (fAbsPath.startsWith(rootAbsolutePath)) {
                String absPath = fAbsPath; // canonicalPath(f);
                absPath = absPath.substring(rootAbsolutePath.length());
                if ("\\".equals(File.separator)) {
                    absPath = absPath.replace('\\', '/');
                }
                //handle / case. (path will have been the same, so the substring created emptystring)
                if (absPath.length() == 0) {
                    absPath = "/";
                }
                result.add(absPath);
            } else
                throw new IllegalStateException(fAbsPath + " " + rootAbsolutePath);
        }
        return result;
    }
1296723
def fromfile(file, dtype, count, *args, **kwargs):
    """"""
    try:
        return numpy.fromfile(file, dtype=dtype, count=count, *args, **kwargs)
    except (TypeError, IOError):
        return numpy.frombuffer(file.read(count * numpy.dtype(dtype).itemsize),
                                dtype=dtype, count=count, *args, **kwargs)
1221068
function splitFilesIntoBatches(files, config) {
    // We need to specifiy a different parser for TS files
    const configTS = Object.assign({}, config);
    configTS.parser = 'typescript';

    const batches = [];

    batches.push({
        files: files.filter(fileName => fileMatchesExtension(fileName, EXTENSIONS.js)),
        config: config,
    });

    batches.push({
        files: files.filter(fileName => fileMatchesExtension(fileName, EXTENSIONS.ts)),
        config: configTS,
    });

    return batches;
}
529009
def _format_files(cls, files, kind):
        ''''''
        lines = []
        if files:
            lines.append('The following {kind} are contained in this DAP:'.format(kind=kind.title()))
            for f in files:
                lines.append('* ' + strip_prefix(f, kind).replace(os.path.sep, ' ').strip())
            return lines
        else:
            return ['No {kind} are contained in this DAP'.format(kind=kind.title())]
1206840
function mapFiles(files, relative, required) {
  if (!files) {
    return []
  }

  if (Array.isArray(files) === false) {
    files = [files]
  }

  return files.map(f => ({
    file: resolvePath(relative, f),
    required: required
  }))
}
193137
def hydrate_bundles(bundles_field, glob_match_error_behavior):
  """"""
  path_globs_with_match_errors = [
    pg.copy(glob_match_error_behavior=glob_match_error_behavior)
    for pg in bundles_field.path_globs_list
  ]
  snapshot_list = yield [Get(Snapshot, PathGlobs, pg) for pg in path_globs_with_match_errors]

  spec_path = bundles_field.address.spec_path

  bundles = []
  zipped = zip(bundles_field.bundles,
               bundles_field.filespecs_list,
               snapshot_list)
  for bundle, filespecs, snapshot in zipped:
    rel_spec_path = getattr(bundle, 'rel_path', spec_path)
    kwargs = bundle.kwargs()
    # NB: We `include_dirs=True` because bundle filesets frequently specify directories in order
    # to trigger a (deprecated) default inclusion of their recursive contents. See the related
    # deprecation in `pants.backend.jvm.tasks.bundle_create`.
    kwargs['fileset'] = _eager_fileset_with_spec(rel_spec_path,
                                                 filespecs,
                                                 snapshot,
                                                 include_dirs=True)
    bundles.append(BundleAdaptor(**kwargs))
  yield HydratedField('bundles', bundles)
540647
function convert(opts) {
	var input = opts.convert || opts.edit;
	if(typeof input !== "string") {
		throw new Error("no input file");
	}
	
	var bundle = new Bundle(input);
	
	do_compile(bundle, opts);
}
562584
function convertFileType (data) {
  data['type'] = 'string'
  data['media'] = { 'binaryEncoding': 'binary' }
  if (data.fileTypes) {
    data['media']['anyOf'] = []
    data.fileTypes.forEach(function (el) {
      data['media']['anyOf'].push({ 'mediaType': el })
    })
    delete data.fileTypes
  }
  return data
}
935961
def parse_files(self, req, name, field):
        """"""
        files = ((k, v) for k, v in req.POST.items() if hasattr(v, "file"))
        return core.get_value(MultiDict(files), name, field)
511586
def transform_file_output(result):
    
    from collections import OrderedDict
    new_result = []

    iterable = result if isinstance(result, list) else result.get('items', result)
    for item in iterable:
        new_entry = OrderedDict()

        entity_type = item['type']  # type property is added by transform_file_directory_result
        is_dir = entity_type == 'dir'

        new_entry['Name'] = item['name'] + '/' if is_dir else item['name']
        new_entry['Content Length'] = ' ' if is_dir else item['properties']['contentLength']
        new_entry['Type'] = item['type']
        new_entry['Last Modified'] = item['properties']['lastModified'] or ' '
        new_result.append(new_entry)
    return sorted(new_result, key=lambda k: k['Name'])
161330
function (files) {
  return files.reduce(function (filesMap, file) {
    let fileName = path.parse(file).name;
    filesMap[fileName] = readFile(file, 'utf8');

    return filesMap;
  }, {});
}
701367
def register(filetypes):
    
    def decorator(clazz):
        for ext in filetypes:
            checkers.setdefault(ext, []).append(clazz)
        return clazz
    return decorator
1135706
def FromFile(cls, filename, mime_type=None, auto_transfer=True,
                 gzip_encoded=False, **kwds):
        """"""
        path = os.path.expanduser(filename)
        if not os.path.exists(path):
            raise exceptions.NotFoundError('Could not find file %s' % path)
        if not mime_type:
            mime_type, _ = mimetypes.guess_type(path)
            if mime_type is None:
                raise exceptions.InvalidUserInputError(
                    'Could not guess mime type for %s' % path)
        size = os.stat(path).st_size
        return cls(open(path, 'rb'), mime_type, total_size=size,
                   close_stream=True, auto_transfer=auto_transfer,
                   gzip_encoded=gzip_encoded, **kwds)
1373271
def filename_items_for_filetype(filenames, filetype_info):
        """"""
        matched_files = []
        for pattern in filetype_info['file_patterns']:
            for filename in match_filenames(filenames, pattern):
                if filename in matched_files:
                    continue
                try:
                    filename_info = parse(
                        pattern, get_filebase(filename, pattern))
                except ValueError:
                    logger.debug("Can't parse %s with %s.", filename, pattern)
                    continue
                matched_files.append(filename)
                yield filename, filename_info
402344
def make_image_converters(self, image, configuration, harpoon_spec):
        """"""
        def convert_image(path, val):
            log.info("Converting %s", path)
            everything = path.configuration.root().wrapped()
            meta = Meta(everything, [])
            configuration.converters.started(path)

            base = path.configuration.root().wrapped()
            base.update(configuration.as_dict(ignore=["images"]))
            base.update(val.as_dict(ignore=["images"]))

            base["__image__"] = base
            everything["__image__"] = base

            base["harpoon"] = configuration["harpoon"]
            base["configuration"] = configuration
            return harpoon_spec.image_spec.normalise(meta.at("images").at(image), base)

        converter = Converter(convert=convert_image, convert_path=["images", image])
        configuration.add_converter(converter)

        def convert_tasks(path, val):
            spec = harpoon_spec.tasks_spec(available_actions)
            meta = Meta(path.configuration.root(), []).at("images").at(image).at("tasks")
            configuration.converters.started(path)
            tasks = spec.normalise(meta, val)
            for task in tasks.values():
                task.image = image
            return tasks

        converter = Converter(convert=convert_tasks, convert_path=["images", image, "tasks"])
        configuration.add_converter(converter)
1126647
def inject_into_files(scheme_file, files):
    """"""
    for file_ in files:
        rec = Recipient(file_)
        colorscheme = rec.get_colorscheme(scheme_file)
        rec.inject_scheme(colorscheme)
        rec.write()