Skip to content

Commit

Permalink
Support gspread 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dgilman committed Sep 18, 2022
1 parent 56d6707 commit c08c77c
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/requirements.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Sphinx==5.*
m2r2==0.3.2
m2r2==0.3.3
sphinxcontrib-trio==1.1.2
gspread==5.4.*
gspread==5.5.*
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ google-auth==2.11.0
# gspread
google-auth-oauthlib==0.5.3
# via gspread
gspread==5.4.0
gspread==5.5.0
# via -r docs/requirements.in
idna==3.4
# via requests
imagesize==1.4.1
# via sphinx
jinja2==3.1.2
# via sphinx
m2r2==0.3.2
m2r2==0.3.3
# via -r docs/requirements.in
markupsafe==2.1.1
# via jinja2
Expand Down
91 changes: 91 additions & 0 deletions gspread_asyncio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,47 @@ async def remove_permissions(self, value: str, role: str = "any"):
"""
return await self.agcm._call(self.ss.remove_permissions, value, role=role)

@_nowait
async def transfer_ownership(self, permission_id: str):
"""Transfer the ownership of this file to a new user.
It is necessary to first create the permission with the new owner's email address,
get the permission ID then use this method to transfer the ownership.
.. note::
You can list all permission using :meth:`gspread.spreadsheet.Spreadsheet.list_permissions`
.. warning::
You can only transfer ownership to a new user, you cannot transfer ownership to a group
or a domain email address.
:param str permission_id: New permission ID
:param bool nowait: (optional) If true, return a scheduled future
instead of waiting for the API call to complete.
.. versionadded:: 1.7
"""
return await self.agcm._call(self.ss.transfer_ownership, permission_id)

@_nowait
async def accept_ownership(self, permission_id: str):
"""Accept the pending ownership request on that file.
It is necessary to edit the permission with the pending ownership.
.. note::
You can only accept ownership transfer for the user currently being used.
.. versionadded:: 1.7
:param str permission_id: New permission ID
:param bool nowait: (optional) If true, return a scheduled future
instead of waiting for the API call to complete.
"""
return await self.agcm._call(self.ss.accept_ownership, permission_id)

@_nowait
async def reorder_worksheets(
self, worksheets_in_desired_order: "Iterable[AsyncioGspreadWorksheet]"
Expand Down Expand Up @@ -2025,6 +2066,7 @@ async def insert_cols(
values: List[List],
col: int = 1,
value_input_option: gspread.utils.ValueInputOption = gspread.utils.ValueInputOption.raw,
inherit_from_before: bool = False,
):
"""Adds multiple new cols to the worksheet at specified index and
populates them with values. Wraps
Expand All @@ -2037,6 +2079,17 @@ async def insert_cols(
rendered in the output. Possible values are ``RAW`` or
``USER_ENTERED``. See `ValueInputOption`_ in the Sheets API.
:type value_input_option: `gspread.utils.ValueInputOption`
:param bool inherit_from_before: (optional) If True, new columns will
inherit their properties from the previous column. Defaults to
False, meaning that new columns acquire the properties of the
column immediately after them.
.. warning::
`inherit_from_before` must be False if adding at the left edge
of a spreadsheet (`col=1`), and must be True if adding at the
right edge of the spreadsheet.
:param bool nowait: (optional) If true, return a scheduled future instead of waiting for the API call to complete.
.. _ValueInputOption: https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
Expand All @@ -2047,6 +2100,7 @@ async def insert_cols(
values,
col=col,
value_input_option=value_input_option,
inherit_from_before=inherit_from_before,
)

@_nowait
Expand All @@ -2069,6 +2123,7 @@ async def insert_row(
values: List,
index: int = 1,
value_input_option: gspread.utils.ValueInputOption = gspread.utils.ValueInputOption.raw,
inherit_from_before: bool = False,
):
"""Adds a row to the worksheet at the specified index
and populates it with values. Wraps
Expand All @@ -2084,6 +2139,17 @@ async def insert_row(
(optional) Determines how values should be
rendered in the output. See
`ValueInputOption`_ in the Sheets API.
:param bool inherit_from_before: (optional) If True, the new row will
inherit its properties from the previous row. Defaults to False,
meaning that the new row acquires the properties of the row
immediately after it.
.. warning::
`inherit_from_before` must be False when adding a row to the top
of a spreadsheet (`index=1`), and must be True when adding to
the bottom of the spreadsheet.
:param bool nowait: (optional) If true, return a scheduled future instead of waiting for the API call to complete.
.. _ValueInputOption: https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
Expand All @@ -2093,6 +2159,7 @@ async def insert_row(
values,
index=index,
value_input_option=value_input_option,
inherit_from_before=inherit_from_before,
)

@_nowait
Expand All @@ -2101,6 +2168,7 @@ async def insert_rows(
values: List[List],
row: int = 1,
value_input_option: gspread.utils.ValueInputOption = gspread.utils.ValueInputOption.raw,
inherit_from_before: bool = False,
):
"""Adds multiple rows to the worksheet at the specified index and
populates them with values.
Expand All @@ -2114,6 +2182,17 @@ async def insert_rows(
(optional) Determines how input data
should be interpreted. Possible values are ``RAW`` or
``USER_ENTERED``. See `ValueInputOption`_ in the Sheets API.
:param bool inherit_from_before: (optional) If True, the new row will
inherit its properties from the previous row. Defaults to False,
meaning that the new row acquires the properties of the row
immediately after it.
.. warning::
`inherit_from_before` must be False when adding a row to the top
of a spreadsheet (`index=1`), and must be True when adding to
the bottom of the spreadsheet.
:param bool nowait: (optional) If true, return a scheduled future instead of waiting for the API call to complete.
.. versionadded:: 1.1
Expand All @@ -2124,6 +2203,7 @@ async def insert_rows(
row=row,
value_input_option=value_input_option,
api_call_count=2,
inherit_from_before=inherit_from_before
)

async def list_dimension_group_columns(self) -> List[dict]:
Expand Down Expand Up @@ -2463,6 +2543,17 @@ async def update_note(self, cell: str, content: str) -> None:
async def update_title(self, title):
raise NotImplemented("This breaks ws caching, could be implemented later")

@_nowait
async def update_tab_color(self, color: dict):
"""Changes the worksheet's tab color.
:param dict color: The red, green and blue values of the color, between 0 and 1.
:param bool nowait: (optional) If true, return a scheduled future instead of waiting for the API call to complete.
.. versionadded:: 1.7.0
"""
return await self.agcm._call(self.ws.update_tab_color, color)

@property
def url(self) -> str:
""":returns: Worksheet URL.
Expand Down
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
requests==2.*
gspread==5.4.*
gspread==5.5.*
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ google-auth==2.11.0
# gspread
google-auth-oauthlib==0.5.3
# via gspread
gspread==5.4.0
gspread==5.5.0
# via -r requirements.in
idna==3.4
# via requests
Expand Down
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ google-auth==2.11.0
# gspread
google-auth-oauthlib==0.5.3
# via gspread
gspread==5.4.0
gspread==5.5.0
# via
# -r docs/requirements.in
# -r requirements.in
Expand All @@ -46,7 +46,7 @@ isort==5.10.1
# via -r requirements_dev.in
jinja2==3.1.2
# via sphinx
m2r2==0.3.2
m2r2==0.3.3
# via -r docs/requirements.in
markupsafe==2.1.1
# via jinja2
Expand Down

0 comments on commit c08c77c

Please sign in to comment.