Skip to content

Commit

Permalink
Merge pull request #1225 from burnash/fix/update-internal-properties
Browse files Browse the repository at this point in the history
Fix/update-internal-properties
  • Loading branch information
alifeee authored Jun 16, 2023
2 parents 20a2209 + a826044 commit c38c512
Show file tree
Hide file tree
Showing 6 changed files with 1,863 additions and 9 deletions.
12 changes: 8 additions & 4 deletions gspread/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ def update_title(self, title):
]
}

response = self.batch_update(body)
res = self.batch_update(body)
self._properties["title"] = title
return response
return res

def update_timezone(self, timezone):
"""Updates the current spreadsheet timezone.
Expand All @@ -698,7 +698,9 @@ def update_timezone(self, timezone):
]
}

return self.batch_update(body)
res = self.batch_update(body)
self._properties["timeZone"] = timezone
return res

def update_locale(self, locale):
"""Update the locale of the spreadsheet.
Expand All @@ -722,7 +724,9 @@ def update_locale(self, locale):
]
}

return self.batch_update(body)
res = self.batch_update(body)
self._properties["locale"] = locale
return res

def list_protected_ranges(self, sheetid):
"""Lists the spreadsheet's protected named ranges"""
Expand Down
25 changes: 21 additions & 4 deletions gspread/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1696,7 +1696,10 @@ def append_rows(

body = {"values": values}

return self.spreadsheet.values_append(range_label, params, body)
res = self.spreadsheet.values_append(range_label, params, body)
num_new_rows = len(values)
self._properties["gridProperties"]["rowCount"] += num_new_rows
return res

def insert_row(
self,
Expand Down Expand Up @@ -1804,7 +1807,10 @@ def insert_rows(

body = {"majorDimension": Dimension.rows, "values": values}

return self.spreadsheet.values_append(range_label, params, body)
res = self.spreadsheet.values_append(range_label, params, body)
num_new_rows = len(values)
self._properties["gridProperties"]["rowCount"] += num_new_rows
return res

def insert_cols(
self,
Expand Down Expand Up @@ -1866,7 +1872,10 @@ def insert_cols(

body = {"majorDimension": Dimension.cols, "values": values}

return self.spreadsheet.values_append(range_label, params, body)
res = self.spreadsheet.values_append(range_label, params, body)
num_new_cols = len(values)
self._properties["gridProperties"]["columnCount"] += num_new_cols
return res

def delete_row(self, index):
""".. deprecated:: 5.0
Expand Down Expand Up @@ -2002,7 +2011,15 @@ def delete_dimension(self, dimension, start_index, end_index=None):
]
}

return self.spreadsheet.batch_update(body)
res = self.spreadsheet.batch_update(body)
if end_index is None:
end_index = start_index
num_deleted = end_index - start_index + 1
if dimension == Dimension.rows:
self._properties["gridProperties"]["rowCount"] -= num_deleted
elif dimension == Dimension.cols:
self._properties["gridProperties"]["columnCount"] -= num_deleted
return res

def delete_rows(self, start_index, end_index=None):
"""Deletes multiple rows from the worksheet at the specified index.
Expand Down
Loading

0 comments on commit c38c512

Please sign in to comment.