def _GetGcsUris()

in utils/fix-audio-encoding/convert_from_gcs.py [0:0]


def _GetGcsUris(bucket, project_id, impersonated_service_account):
  """Returns a list of GCS uris for files in a bucket.

  Args:
      bucket: The GCS bucket.
      project_id: The project ID (not number) to use.
      impersonated_service_account: The service account to impersonate.

  Returns:
      The GCS uris.
  """
  uris, files = [], []
  storage_client = storage.Client(
      project=project_id,
      credentials=_GetClientCredentials(impersonated_service_account),
  )
  blobs = storage_client.list_blobs(bucket)
  for blob in blobs:
    # Blobs ending in slashes are actually directory paths.
    if not blob.name.endswith('/'):
      uris.append(_GetGcsUri(bucket, blob.name))
      files.append(blob.name)
  return uris, files