in google/generativeai/notebook/gspread_client.py [0:0]
def _open(self, sid: sheets_id.SheetsIdentifier):
"""Opens a Sheets document from `sid`.
Args:
sid: The identifier for the Sheets document.
Raises:
SpreadsheetNotFoundError: If the Sheets document cannot be found or
cannot be opened.
Returns:
A gspread.Worksheet instance representing the worksheet referred to by
`sid`.
"""
try:
if sid.name():
return self._client.open(sid.name())
if sid.key():
return self._client.open_by_key(str(sid.key()))
if sid.url():
return self._client.open_by_url(str(sid.url()))
except GSpreadException as exc:
raise SpreadsheetNotFoundError("Unable to find Sheets with {}".format(sid)) from exc
raise SpreadsheetNotFoundError("Invalid sheets_id.SheetsIdentifier")