8000 Protocol timezone parameter now accepts strings (#364) · urshala/google-cloud-python@12a4e4c · GitHub
[go: up one dir, main page]

Skip to content

Commit 12a4e4c

Browse files
author
Alejandro Casanovas
committed
Protocol timezone parameter now accepts strings (googleapis#364)
1 parent d75ce17 commit 12a4e4c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

O365/connection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from requests_oauthlib import OAuth2Session
1515
from stringcase import pascalcase, camelcase, snakecase
1616
from tzlocal import get_localzone
17-
from pytz import UnknownTimeZoneError, UTC
17+
from pytz import UnknownTimeZoneError, UTC, timezone as get_timezone
1818

1919
from .utils import ME_RESOURCE, BaseTokenBackend, FileSystemTokenBackend, Token
2020

@@ -78,7 +78,7 @@ def __init__(self, *, protocol_url=None, api_version=None,
7878
:param function casing_function: the casing transform function to be
7979
used on api keywords (camelcase / pascalcase)
8080
:param str protocol_scope_prefix: prefix url for scopes
81-
:param pytz.UTC timezone: preferred timezone, defaults to the
81+
:param pytz.UTC or str timezone: preferred timezone, defaults to the
8282
system timezone
8383
:raises ValueError: if protocol_url or api_version are not supplied
8484
"""
@@ -92,6 +92,8 @@ def __init__(self, *, protocol_url=None, api_version=None,
9292
self.default_resource = default_resource or ME_RESOURCE
9393
self.use_default_casing = True if casing_function is None else False
9494
self.casing_function = casing_function or camelcase
95+
if timezone and isinstance(timezone, str):
96+
timezone = get_timezone(timezone)
9597
try:
9698
self.timezone = timezone or get_localzone() # pytz timezone
9799
except UnknownTimeZoneError as e:

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,8 @@ global_address_list = account.directory()
830830
q = global_address_list.new_query('display_name')
831831
q.startswith('George Best')
832832

833-
print(global_address_list.get_users(query=q))
833+
for user in global_address_list.get_users(query=q):
834+
print(user)
834835
```
835836

836837

0 commit comments

Comments
 (0)
0