Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _fetch_sheets(self, jsonsheet=None):
"""update sheets list"""
self._sheet_list = []
if not jsonsheet:
jsonsheet = self.client.open_by_key(self.id, returnas='json')
for sheet in jsonsheet.get('sheets'):
self._sheet_list.append(Worksheet(self, sheet))
:param title: A title of a new worksheet.
:param rows: Number of rows.
:param cols: Number of columns.
:param src_tuple: a tuple (spreadsheet id, worksheet id) specifying a worksheet to copy
:param src_worksheet: source worksheet to copy values from
:returns: a newly created :class:`worksheets `.
"""
if self.batch_mode:
raise RequestError("not supported in batch Mode")
jsheet = dict()
if src_tuple:
jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
wks = Worksheet(self, jsheet)
wks.title = title
elif src_worksheet:
if type(src_worksheet) != Worksheet:
raise InvalidArgumentValue("src_worksheet")
jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
wks = Worksheet(self, jsheet)
wks.title = title
else:
request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
jsheet['properties'] = result['replies'][0]['addSheet']['properties']
wks = Worksheet(self, jsheet)
self._sheet_list.append(wks)
return wks
:param cols: Number of columns.
:param src_tuple: a tuple (spreadsheet id, worksheet id) specifying a worksheet to copy
:param src_worksheet: source worksheet to copy values from
:returns: a newly created :class:`worksheets `.
"""
if self.batch_mode:
raise RequestError("not supported in batch Mode")
jsheet = dict()
if src_tuple:
jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
wks = Worksheet(self, jsheet)
wks.title = title
elif src_worksheet:
if type(src_worksheet) != Worksheet:
raise InvalidArgumentValue("src_worksheet")
jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
wks = Worksheet(self, jsheet)
wks.title = title
else:
request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
jsheet['properties'] = result['replies'][0]['addSheet']['properties']
wks = Worksheet(self, jsheet)
self._sheet_list.append(wks)
return wks
jsheet = dict()
if src_tuple:
jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
wks = Worksheet(self, jsheet)
wks.title = title
elif src_worksheet:
if type(src_worksheet) != Worksheet:
raise InvalidArgumentValue("src_worksheet")
jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
wks = Worksheet(self, jsheet)
wks.title = title
else:
request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
jsheet['properties'] = result['replies'][0]['addSheet']['properties']
wks = Worksheet(self, jsheet)
self._sheet_list.append(wks)
return wks