Given a path (string or Path object) to a GTFSR feed file,
    return the corresponding GTFS feed (FeedMessage instance).
    If ``from_json``, then assume the feed file is in JSON format;
    otherwise, assume the feed file is in Protocol Buffer format.
186823
def read_gtfsr(path, *, from_json=False):
    
    path = Path(path)
    feed = gtfs_realtime_pb2.FeedMessage()

    with path.open('rb') as src:
        if from_json:
            feed = json_format.Parse(src.read(), feed)
        else:
            feed.ParseFromString(src.read())

    return feed
1343078
def get_from_archive(self, feed_id):
        
        file_path = self.feed_repository + '/' + str(feed_id) + '.xml'
        if not os.path.isfile(file_path):
            raise FeedArchiveNotFound()
        with open(file_path, 'r') as rec_file:
            return rec_file.read()
503544
def get_json_content(file_path):
    
    try:
        with open(file_path, 'r') as file:
            return json.load(file)
    except TypeError as err:
        print('Error: ', err)
        return None
744032
def get_as_string(self, s3_path, encoding='utf-8'):
        
        content = self.get_as_bytes(s3_path)
        return content.decode(encoding)
1367068
def get_transcript_format(transcript_content):
    
    try:
        sjson_obj = json.loads(transcript_content)
    except ValueError:
        # With error handling (set to 'ERROR_RAISE'), we will be getting
        # the exception if something went wrong in parsing the transcript.
        srt_subs = SubRipFile.from_string(transcript_content, error_handling=SubRipFile.ERROR_RAISE)
        if len(srt_subs) > 0:
            return TranscriptFormat.SRT
    return TranscriptFormat.SJSON
616871
def parse(self, fp, headersonly=True):
        """"""
        feedparser = FeedParser(self._class)
        feedparser._set_headersonly()

        try:
            mp = mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
        except:
            mp = fp

        data = ""

        # While parsing the header we can convert to us-ascii?
        while True:
            line = mp.readline()
            data = data + line.decode("us-ascii")
            if line == b"\n":
                break
        feedparser.feed(data) # mp[0:5000])
        return feedparser.close()
1261044
function _gpfReadNashorn (path) {
    var javaPath = java.nio.file.Paths.get(path);
    if (java.nio.file.Files.exists(javaPath)) {
        return new Promise(function (resolve, reject) {
            var javaInputStream = java.nio.file.Files.newInputStream(javaPath),
                iStreamReader = new _GpfStreamJavaReadable(javaInputStream),
                iWritableString = new _GpfStreamWritableString();
            return iStreamReader.read(iWritableString)
                .then(function () {
                    resolve(iWritableString.toString());
                })["catch"](reject);
        });
    }
    return Promise.reject(new Error("File not found")); // To be improved
}
1300414
def load_file_to_str(path):
    # type: (str) -> str
    
    with open(path, 'rt') as f:
        string = f.read().replace(linesep, '')
    if not string:
        raise LoadError('%s file is empty!' % path)
    return string
376685
def simple_parse_file(filename: str) -> Feed:
    """"""
    pairs = (
        (rss.parse_rss_file, _adapt_rss_channel),
        (atom.parse_atom_file, _adapt_atom_feed),
        (json_feed.parse_json_feed_file, _adapt_json_feed)
    )
    return _simple_parse(pairs, filename)
1081343
def get_json(self, path, watch=None):
        """"""
        data, _ = self.get(path, watch)
        return load_json(data) if data else None
945212
def to_json_file(self, json_file_path):
        
        with open(json_file_path, "w", encoding='utf-8') as writer:
            writer.write(self.to_json_string())
217303
def _read_info(info_path):
  """"""
  if not tf.io.gfile.exists(info_path):
    return None
  with tf.io.gfile.GFile(info_path) as info_f:
    return json.load(info_f)
484616
def load_from_json(file_path):
    """"""
    if os.path.exists(file_path):
        raw_data = open(file_path, 'rb').read()
        return json.loads(base64.decodestring(raw_data).decode('utf-8'))
288832
def get_json_path(self, path):
        
        return self.with_json_path(path, field='result').values_list('result', flat=True)
1326734
def jsonload(path, **kw):
    
    _kw = {}
    if not PY2:
        _kw['encoding'] = 'utf8'
    with io.open(path, **_kw) as fp:
        return json.load(fp, **kw)
899919
def read_file_to_string(path):
  """"""
  bytes_string = tf.gfile.Open(path, 'r').read()
  return dlutils.python_portable_string(bytes_string)
189723
def manifest_parse(self, path):
        ''''''
        print("fw: parsing manifests")
        content = open(path).read()
        return json.loads(content)