Return the contents of a file when given a path.
11985
def file_to_string(path):
    
    if not os.path.exists(path):
        ui.error(c.MESSAGES["path_missing"], path)
        sys.exit(1)

    with codecs.open(path, "r", "UTF-8") as contents:
        return contents.read()
272388
def read_file(fpath):
    """"""
    with io.open(os.path.join(PATH_BASE, fpath)) as f:
        return f.read()
557647
def find_in_path(path, file):
  """"""
  for p in path.split(os.pathsep):
    candidate = os.path.join(p, file)
    if os.path.exists(candidate) and os.path.isfile(candidate):
      return candidate
  return False
1033817
def parse_file_path(cls, file_path):
    """"""
    address = None
    pattern = cls.file_regex.match(file_path)
    if pattern:
      address = pattern.group(1)
    return address
298612
def get_file_content(url, comes_from=None):
    """"""
    match = _scheme_re.search(url)
    if match:
        scheme = match.group(1).lower()
        if (scheme == 'file' and comes_from
            and comes_from.startswith('http')):
            raise InstallationError(
                'Requirements file %s references URL %s, which is local'
                % (comes_from, url))
        if scheme == 'file':
            path = url.split(':', 1)[1]
            path = path.replace('\\', '/')
            match = _url_slash_drive_re.match(path)
            if match:
                path = match.group(1) + ':' + path.split('|', 1)[1]
            path = urllib.unquote(path)
            if path.startswith('/'):
                path = '/' + path.lstrip('/')
            url = path
        else:
            ## FIXME: catch some errors
            resp = urlopen(url)
            return geturl(resp), resp.read()
    try:
        f = open(url)
        content = f.read()
    except IOError:
        e = sys.exc_info()[1]
        raise InstallationError('Could not open requirements file: %s' % str(e))
    else:
        f.close()
    return url, content
100989
def _get_files(path):
        
        ret_val = []
        for root, _, files in os.walk(path):
            for f in files:
                ret_val.append(os.path.join(root, f))
        return ret_val
89638
function parseDirectory( path ) {

            return fs.readdirSync( path )

                .map( function( file ) {

                    var filePath = path + "/" + file;

                    if ( isIncludeFile( filePath ) ) return parseFile( filePath );
                    else if ( isDirectory( filePath ) ) return parseDirectory( filePath );

                    return null;
                } )

                .filter( function( value ) {

                    return value !== null;

                } );
        }
154992
def parse_files(self, req, name, field):
        """"""
        return get_value(req.files, name, field)
882430
def read_file(filepath: str) -> str:
    """"""
    # ? Check this is ok if absolute paths passed in
    filepath = os.path.expanduser(filepath)
    with open(filepath) as opened_file:  # type: IO
        file_read = opened_file.read()  # type: str
        return file_read
576412
def _file_read(path):
    '''
    
    '''
    content = False
    if os.path.exists(path):
        with salt.utils.files.fopen(path, 'r+') as fp_:
            content = salt.utils.stringutils.to_unicode(fp_.read())
        fp_.close()
    return content
1274722
def read(*paths):
    ''''''
    with open(os.path.join(os.path.dirname(__file__), *paths)) as fp:
        return fp.read()
1037365
def get_repo_content(path):
    
    path = Path(path)

    if zipfile.is_zipfile(str(path)):
        with zipfile.ZipFile(str(path)) as zz:
            filelist = [info.filename for info in zz.infolist()]
        iszip = True
    else:
        iszip = False
        filelist = [str(f) for f in path.glob('**/*') if f.is_file()]
    return namedtuple('repocontent', ['iszip', 'filelist'])(iszip, filelist)
899919
def read_file_to_string(path):
  """"""
  bytes_string = tf.gfile.Open(path, 'r').read()
  return dlutils.python_portable_string(bytes_string)
1038135
def contents(path = nil)
      contents = []

      object = find_object(path || '/')
      contents << path unless path.nil? || object.nil?
      if object.is_a? Grit::Tree
        (object.blobs + object.trees).each do |obj|
          contents += contents(path.nil? ? obj.basename : File.join(path, obj.basename))
        end
      end

      contents
    end
474977
def read(self, path, filename=None, offset=None, size=-1):
        
        storageScheme, key = self.getkey(path, filename=filename)

        if offset or (size > -1):
            if not offset:
                offset = 0
            if size > -1:
                sizeStr = offset + size - 1  # range header is inclusive
            else:
                sizeStr = ""
            headers = {"Range": "bytes=%d-%s" % (offset, sizeStr)}
            return key.get_contents_as_string(headers=headers)
        else:
            return key.get_contents_as_string()
63776
def items(self):
        """"""
        contents = self.paths
        contents = (
            VenvFile(path.path) if path.is_file else VenvDir(path.path)
            for path in contents
        )
        return contents
673747
def read_file(*path):
    """"""
    real_path = os.path.realpath(os.path.join(*path))
    with click.open_file(real_path, "r") as fp:
        return fp.read()