A better file_get_contents
971974
private function getFileContent($url, $userAgent)
    {
        $opts = [
            'http' => [
                'method' => 'GET',
                'header' => [
                    'User-Agent: '. $userAgent
                ]
            ]
        ];

        $context = stream_context_create($opts);

        return file_get_contents($url, false, $context);
    }
228830
def read_content (self):
        """"""
        if self.is_directory():
            self.url_connection.cwd(self.filename)
            self.files = self.get_files()
            # XXX limit number of files?
            data = get_index_html(self.files)
        else:
            # download file in BINARY mode
            ftpcmd = "RETR %s" % self.filename
            buf = StringIO()
            def stor_data (s):
                """Helper method storing given data"""
                # limit the download size
                if (buf.tell() + len(s)) > self.max_size:
                    raise LinkCheckerError(_("FTP file size too large"))
                buf.write(s)
            self.url_connection.retrbinary(ftpcmd, stor_data)
            data = buf.getvalue()
            buf.close()
        return data
1218693
def load_file_contents(file_path, as_list=True):
    """"""
    abs_file_path = join(HERE, file_path)
    with open(abs_file_path, encoding='utf-8') as file_pointer:
        if as_list:
            return file_pointer.read().splitlines()
        return file_pointer.read()
886115
def fetch_contents(self, source):
        
        slides = []

        if type(source) is list:
            for entry in source:
                slides.extend(self.fetch_contents(entry))
        elif os.path.isdir(source):
            self.log(u"Entering %s" % source)
            entries = os.listdir(source)
            entries.sort()
            for entry in entries:
                slides.extend(self.fetch_contents(os.path.join(source, entry)))
        else:
            try:
                parser = Parser(os.path.splitext(source)[1], self.encoding,
                    self.extensions)
            except NotImplementedError:
                return slides

            self.log(u"Adding   %s (%s)" % (source, parser.format))

            try:
                with codecs.open(source, encoding=self.encoding) as file:
                    file_contents = file.read()
            except UnicodeDecodeError:
                self.log(u"Unable to decode source %s: skipping" % source,
                         'warning')
            else:
                inner_slides = re.split(r'<hr.+>', parser.parse(file_contents))
                for inner_slide in inner_slides:
                    slides.append(self.get_slide_vars(inner_slide, source))

        if not slides:
            self.log(u"Exiting  %s: no contents found" % source, 'notice')

        return slides
345264
def contents(self, maxlen=70):
        ""
        lines = []
        if len(self._files) == 0:
            print("Empty %s" % self.__class__.__name__)
            return

        fnames = [self._truncate_name(maxlen=maxlen, *k) for k in self._files]
        max_len = max([len(f) for f in fnames])
        for name,v in zip(fnames, self._files.values()):
            mime_type = v[1].get('mime_type', 'no mime type')
            lines.append('%s : %s' % (name.ljust(max_len), mime_type))
        print('\n'.join(lines))
1126371
public function getFileContents($sFile)
    {
        $sContents = null;
        if (file_exists($sFile) && is_readable($sFile)) {
            $sContents = file_get_contents($sFile);
        }

        return $sContents;
    }
800296
public static function get($file = false) {

        if ($file && self::isFile($file)) {

            return file_get_contents($file);
        }

        return false;
    }
87356
def file_contents(self, filename, binary=False):
        
        if binary:
            mode = 'rb'
        else:
            mode = 'r'
        try:
            with open(filename, mode) as f:
                return f.read()
        except (OSError, IOError) as e:
            raise FileReadError(str(e))
333965
def file_attribs(location,
                 mode=None,
                 owner=None,
                 group=None,
                 use_sudo=False,
                 recursive=True):
    """"""
    return dir_attribs(location=location,
                       mode=mode,
                       owner=owner,
                       group=group,
                       recursive=recursive,
                       use_sudo=False)
240175
private function getFileContents($files)
	{
		$content = '';
		$basePath = $this->basePath;

		array_walk($files,function(&$value, $key) use(&$content, $basePath){
			if(file_exists($basePath.$value))
			$content .= file_get_contents($basePath.$value);
		});
		return $content;
	}
1183012
def contents(self):
        """"""
        if not IS_PY2 and isinstance(self.byte_contents, bytes):
            return self.byte_contents.decode(
                self.encoding or locale.getpreferredencoding(False),
                errors=self.errors)
        return self.byte_contents
979227
public function getContents()
    {
        $sErrorLogPath = $this->getErrorLogPathWithName();

        $sLog = '';

        if ( is_file( $sErrorLogPath ) ) {
            $fErrorLog = fopen( $sErrorLogPath, "r" );

            while ( !feof( $fErrorLog ) ) {
                $sLog .= trim( fgets( $fErrorLog, 4096 ) ) . PHP_EOL;
            }

            fclose( $fErrorLog );
        }

        return $sLog;
    }
629624
public function getFileContent(File $file)
	{
		$filePath = $this->getFilesystemPath($file);
		$fileContent = file_get_contents($filePath);

		return $fileContent;
	}
227246
function file_get_contents($file)
		{
			$fd = fopen($file, 'rb');
			$content = fread($fd, filesize($file));
			fclose($fd);
			$this->file_loaded_size+= strlen($content);
			return $content;				
		}
546179
private function getFileContents($file) {
    if (file_exists($file) === FALSE) {
      return NULL;
    }

    $contents = file_get_contents($file);
    if ($contents === FALSE) {
      return NULL;
    }

    return $contents;
  }
135318
def _get_file_content(self, path):
        """"""
        with open(path, 'r') as file_:
            content = file_.read()
        return content
50967
def get_file(fn):
    """"""
    fn = os.path.join(os.path.dirname(__file__), 'data', fn)
    f = open(fn, 'rb')
    lines = [line.decode('utf-8').strip() for line in f.readlines()]
    return lines