

def __enter__(self):
    if self.source.is_gcs_source:
        from google.cloud.dataflow.io import gcsio
        self._file = gcsio.GcsIO().open(self.source.file_path, 'rb')
    else:
        self._file = open(self.source.file_path, 'rb')
    if (self.end_offset is None):
        self._file.seek(0, os.SEEK_END)
        self.end_offset = self._file.tell()
    if (self.start_offset is None):
        self.start_offset = 0
        self.current_offset = self.start_offset
    if (self.start_offset > 0):
        self._file.seek((self.start_offset - 1))
        self.current_offset -= 1
        line = self._file.readline()
        self.current_offset += len(line)
    else:
        self._file.seek(self.start_offset)
    self.range_tracker = range_trackers.OffsetRangeTracker(self.start_offset, self.end_offset)
    return self

dataset/ETHPy150Open GoogleCloudPlatform/DataflowPythonSDK/google/cloud/dataflow/io/fileio.py TextFileReader.__enter__/original