Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:returns: list of all :class:`worksheets `
"""
if not sheet_property and not value:
return self._sheet_list
if sheet_property not in ['title', 'index', 'id']:
raise InvalidArgumentValue
elif sheet_property in ['index', 'id']:
value = int(value)
sheets = [x for x in self._sheet_list if getattr(x, sheet_property) == value]
if not len(sheets) > 0 or force_fetch:
self._fetch_sheets()
sheets = [x for x in self._sheet_list if getattr(x, sheet_property) == value]
if not len(sheets) > 0:
raise WorksheetNotFound()
return sheets
:returns: List of :class:`Worksheets `.
"""
if not sheet_property and not value:
return self._sheet_list
if sheet_property not in ['title', 'index', 'id']:
raise InvalidArgumentValue('sheet_property')
elif sheet_property in ['index', 'id']:
value = int(value)
sheets = [x for x in self._sheet_list if getattr(x, sheet_property) == value]
if not len(sheets) > 0 or force_fetch:
self._fetch_sheets()
sheets = [x for x in self._sheet_list if getattr(x, sheet_property) == value]
if not len(sheets) > 0:
raise WorksheetNotFound()
return sheets
def del_worksheet(self, worksheet):
"""Deletes the worksheet from this spreadsheet.
:param worksheet: The :class:`worksheets ` to be deleted.
"""
if worksheet not in self.worksheets():
raise WorksheetNotFound
request = {"deleteSheet": {'sheetId': worksheet.id}}
self.client.sheet.batch_update(self.id, request)
self._sheet_list.remove(worksheet)
def del_worksheet(self, worksheet):
"""Deletes a worksheet from a spreadsheet.
:param worksheet: The :class:`worksheets ` to be deleted.
"""
if worksheet not in self.worksheets():
raise WorksheetNotFound
request = {"deleteSheet": {'sheetId': worksheet.id}}
self.client.sh_batch_update(self.id, request, '', False)
self._sheet_list.remove(worksheet)