gcs.py 476 B

1234567891011121314151617
  1. """ GCS support for remote file interactivity """
  2. try:
  3. import gcsfs
  4. except ImportError:
  5. raise ImportError("The gcsfs library is required to handle GCS files")
  6. def get_filepath_or_buffer(filepath_or_buffer, encoding=None,
  7. compression=None, mode=None):
  8. if mode is None:
  9. mode = 'rb'
  10. fs = gcsfs.GCSFileSystem()
  11. filepath_or_buffer = fs.open(filepath_or_buffer, mode)
  12. return filepath_or_buffer, None, compression, True