in jupyter-gcs-contents-manager/gcs_contents_manager.py [0:0]
def dir_exists(self, path):
try:
path = self._normalize_path(path)
if not path:
return self.bucket.exists()
dir_gcs_path = self._gcs_path(path)
if self.bucket.get_blob(dir_gcs_path):
# There is a regular file matching the specified directory.
#
# Would could have both a blob matching a directory path
# and other blobs under that path. In that case, we cannot
# treat the path as both a directory and a regular file,
# so we treat the regular file as overriding the logical
# directory.
return False
dir_contents = self.bucket.list_blobs(prefix=dir_gcs_path)
for _ in dir_contents:
return True
return False
except HTTPError as err:
raise err
except Exception as ex:
raise HTTPError(500, 'Internal server error: {}'.format(str(ex)))