make service even when config is None

This commit is contained in:
Dmitry Belyaev 2020-03-07 16:14:47 +03:00
parent 41cc6b4159
commit 9aad7e1910
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
1 changed files with 4 additions and 3 deletions

View File

@ -44,20 +44,21 @@ class GoogleCalendarService():
return service
@staticmethod
def from_config(config):
def from_config(config=None):
"""make service Resource from config dict
Arguments:
config -- dict() config with keys:
(optional) service_account: - service account filename
if key not in dict then default credentials will be used
( https://developers.google.com/identity/protocols/application-default-credentials )
( https://developers.google.com/identity/protocols/application-default-credentials )
-- None: default credentials will be used
Returns:
service Resource
"""
if 'service_account' in config:
if (not config is None) and 'service_account' in config:
service = GoogleCalendarService.from_srv_acc_file(config['service_account'])
else:
service = GoogleCalendarService.default()