input:  filename and path.
            output: file contents.
193103
def open_file(self, access_mode="r"):
        
        try:
            with open(self, access_mode, encoding='utf-8') as file:
                return file.read()

        except IOError:
            print(self + " File not found.")
            sys.exit(0)
446323
def read_files(path):
    
    template = {}
    for file_name in os.listdir(path):
        with open(os.path.join(path, file_name), 'r') as f:
            template[file_name] = replace_whitespace(
                f.read(), insert=True)

    return template
942267
function getFileName(path) {
		var re = /([\w\.\-]+)$/i;
		var m = re.exec(path);
		return m ? m[1] : '';
	}
830479
def _get_contents(self):
        """"""
        def files():
            for value in super(GlobBundle, self)._get_contents():
                for path in glob.glob(value):
                    yield path
        return list(files())
301148
def parseArgs():
    """"""
    parser = argparse.ArgumentParser()
    parser.add_argument("name", help="the file you want to split")
    parser.add_argument("out1", help="the name of the first file you want to output")
    parser.add_argument("out2", help="the name of the second file you want to output")
    return parser.parse_args()
398330
def _get_file_from_url(url):
        """"""
        path = urlparse(url).path
        if not path:
            raise ValueError("Could not extract path from URL '{0}'".format(url))
        name = os.path.basename(path)
        if not name:
            raise ValueError("Could not extract file name from path '{0}'".format(path))
        return name
694600
def files(self):
        """"""
        contents = self.paths
        contents = (VenvFile(path.path) for path in contents if path.is_file)
        return contents
1258097
def get_file_contents(filename):
    
    data = None
    try:
        with open(filename) as pf:
            data = pf.read()
    except IOError:
        # File not found, return None
        pass
    return data
816050
function _getOutputFileName(path, extension) {
        var filename = path.split('/');
        filename = filename[filename.length - 1];
        filename = filename.split('.');
    
        // No extension found
        if (filename.length === 1) {
          return filename[0] + '.' + extension;
        }
    
        // Hidden file
        if (filename[0] === '') {
          filename = filename.slice(1);
          filename[0] = '.' + filename[0];
          if (filename.length === 1) {
            return filename[0] + '.' + extension;
          }
        }
    
        filename = filename.slice(0, -1);
        
        return filename + '.' + extension;
      }
831875
def _safe_read(path, length):
    """"""
    if not os.path.exists(os.path.join(HERE, path)):
        return ''
    file_handle = codecs.open(os.path.join(HERE, path), encoding='utf-8')
    contents = file_handle.read(length)
    file_handle.close()
    return contents
1085244
def generic_filename(path):
    '''
    
    '''

    for sep in common_path_separators:
        if sep in path:
            _, path = path.rsplit(sep, 1)
    return path
689398
def input_file(filename):
    
    if excluded(filename) or not filename_match(filename):
        return {}
    if options.verbose:
        message('checking ' + filename)
    options.counters['files'] = options.counters.get('files', 0) + 1
    errors = Checker(filename).check_all()
    if options.testsuite and not errors:
        message("%s: %s" % (filename, "no errors found"))
    return errors
944863
def fileinfo(path):
    '''
    
    '''
    cmd = 'mfsfileinfo ' + path
    ret = {}
    chunknum = ''
    out = __salt__['cmd.run_all'](cmd, python_shell=False)

    output = out['stdout'].splitlines()
    for line in output:
        if not line:
            continue
        if '/' in line:
            comps = line.split('/')

            chunknum = comps[0].strip().split(':')
            meta = comps[1].strip().split(' ')

            chunk = chunknum[0].replace('chunk ', '')
            loc = chunknum[1].strip()
            id_ = meta[0].replace('(id:', '')
            ver = meta[1].replace(')', '').replace('ver:', '')

            ret[chunknum[0]] = {
                'chunk': chunk,
                'loc': loc,
                'id': id_,
                'ver': ver,
            }
        if 'copy' in line:
            copyinfo = line.strip().split(':')
            ret[chunknum[0]][copyinfo[0]] = {
                'copy': copyinfo[0].replace('copy ', ''),
                'ip': copyinfo[1].strip(),
                'port': copyinfo[2],
            }
    return ret
431206
def get_file_contents(file_path):
  """"""
  full_path = os.path.join(package_dir, file_path)
  return open(full_path, 'r').read()
71875
def contents(self):
        """"""
        if not self._contents:
            if self._path:
                # Read file into memory so we don't run out of file descriptors
                f = open(self._path, "rb")
                self._contents = f.read()
                f.close()
        return self._contents
1256542
def get_input_files(dirname, *ext):
    
    filelist = [f for f in os.listdir(dirname) if
                os.path.splitext(f)[-1] in ext]
    return [os.path.join(dirname, f) for f in filelist]
871803
def str_from_file(path):
    
    with open(path) as f:
        s = f.read().strip()
    return s