black: Reformat skipping string normalization.
This commit is contained in:
parent
5580c68ae5
commit
fba21bb00d
178 changed files with 6562 additions and 4469 deletions
|
@ -7,7 +7,10 @@ from oauth2client.file import Storage
|
|||
|
||||
try:
|
||||
import argparse
|
||||
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() # type: Optional[argparse.Namespace]
|
||||
|
||||
flags = argparse.ArgumentParser(
|
||||
parents=[tools.argparser]
|
||||
).parse_args() # type: Optional[argparse.Namespace]
|
||||
except ImportError:
|
||||
flags = None
|
||||
|
||||
|
@ -22,6 +25,7 @@ CLIENT_SECRET_FILE = 'client_secret.json'
|
|||
APPLICATION_NAME = 'Zulip Calendar Bot'
|
||||
HOME_DIR = os.path.expanduser('~')
|
||||
|
||||
|
||||
def get_credentials() -> client.Credentials:
|
||||
"""Gets valid user credentials from storage.
|
||||
|
||||
|
@ -32,8 +36,7 @@ def get_credentials() -> client.Credentials:
|
|||
Credentials, the obtained credential.
|
||||
"""
|
||||
|
||||
credential_path = os.path.join(HOME_DIR,
|
||||
'google-credentials.json')
|
||||
credential_path = os.path.join(HOME_DIR, 'google-credentials.json')
|
||||
|
||||
store = Storage(credential_path)
|
||||
credentials = store.get()
|
||||
|
@ -49,4 +52,5 @@ def get_credentials() -> client.Credentials:
|
|||
credentials = tools.run(flow, store)
|
||||
print('Storing credentials to ' + credential_path)
|
||||
|
||||
|
||||
get_credentials()
|
||||
|
|
|
@ -38,7 +38,9 @@ sent = set() # type: Set[Tuple[int, datetime.datetime]]
|
|||
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
parser = zulip.add_default_arguments(argparse.ArgumentParser(r"""
|
||||
parser = zulip.add_default_arguments(
|
||||
argparse.ArgumentParser(
|
||||
r"""
|
||||
|
||||
google-calendar --calendar calendarID@example.calendar.google.com
|
||||
|
||||
|
@ -53,23 +55,29 @@ google-calendar --calendar calendarID@example.calendar.google.com
|
|||
revealed to local users through the command line.
|
||||
|
||||
Depends on: google-api-python-client
|
||||
"""))
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
parser.add_argument('--interval',
|
||||
dest='interval',
|
||||
default=30,
|
||||
type=int,
|
||||
action='store',
|
||||
help='Minutes before event for reminder [default: 30]',
|
||||
metavar='MINUTES')
|
||||
parser.add_argument(
|
||||
'--interval',
|
||||
dest='interval',
|
||||
default=30,
|
||||
type=int,
|
||||
action='store',
|
||||
help='Minutes before event for reminder [default: 30]',
|
||||
metavar='MINUTES',
|
||||
)
|
||||
|
||||
parser.add_argument('--calendar',
|
||||
dest = 'calendarID',
|
||||
default = 'primary',
|
||||
type = str,
|
||||
action = 'store',
|
||||
help = 'Calendar ID for the calendar you want to receive reminders from.')
|
||||
parser.add_argument(
|
||||
'--calendar',
|
||||
dest='calendarID',
|
||||
default='primary',
|
||||
type=str,
|
||||
action='store',
|
||||
help='Calendar ID for the calendar you want to receive reminders from.',
|
||||
)
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
|
@ -78,6 +86,7 @@ if not (options.zulip_email):
|
|||
|
||||
zulip_client = zulip.init_from_options(options)
|
||||
|
||||
|
||||
def get_credentials() -> client.Credentials:
|
||||
"""Gets valid user credentials from storage.
|
||||
|
||||
|
@ -89,8 +98,7 @@ def get_credentials() -> client.Credentials:
|
|||
Credentials, the obtained credential.
|
||||
"""
|
||||
try:
|
||||
credential_path = os.path.join(HOME_DIR,
|
||||
'google-credentials.json')
|
||||
credential_path = os.path.join(HOME_DIR, 'google-credentials.json')
|
||||
|
||||
store = Storage(credential_path)
|
||||
credentials = store.get()
|
||||
|
@ -110,8 +118,17 @@ def populate_events() -> Optional[None]:
|
|||
service = discovery.build('calendar', 'v3', http=creds)
|
||||
|
||||
now = datetime.datetime.now(pytz.utc).isoformat()
|
||||
feed = service.events().list(calendarId=options.calendarID, timeMin=now, maxResults=5,
|
||||
singleEvents=True, orderBy='startTime').execute()
|
||||
feed = (
|
||||
service.events()
|
||||
.list(
|
||||
calendarId=options.calendarID,
|
||||
timeMin=now,
|
||||
maxResults=5,
|
||||
singleEvents=True,
|
||||
orderBy='startTime',
|
||||
)
|
||||
.execute()
|
||||
)
|
||||
|
||||
events = []
|
||||
for event in feed["items"]:
|
||||
|
@ -172,14 +189,13 @@ def send_reminders() -> Optional[None]:
|
|||
else:
|
||||
message = 'Reminder:\n\n' + '\n'.join('* ' + m for m in messages)
|
||||
|
||||
zulip_client.send_message(dict(
|
||||
type = 'private',
|
||||
to = options.zulip_email,
|
||||
sender = options.zulip_email,
|
||||
content = message))
|
||||
zulip_client.send_message(
|
||||
dict(type='private', to=options.zulip_email, sender=options.zulip_email, content=message)
|
||||
)
|
||||
|
||||
sent.update(keys)
|
||||
|
||||
|
||||
# Loop forever
|
||||
for i in itertools.count():
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue