black: Reformat without skipping string normalization.

This commit is contained in:
PIG208 2021-05-28 17:05:11 +08:00 committed by Tim Abbott
parent fba21bb00d
commit 6f3f9bf7e4
178 changed files with 5242 additions and 5242 deletions

View file

@ -18,12 +18,12 @@ except ImportError:
# at zulip/bots/gcal/
# NOTE: When adding more scopes, add them after the previous one in the same field, with a space
# seperating them.
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
SCOPES = "https://www.googleapis.com/auth/calendar.readonly"
# This file contains the information that google uses to figure out which application is requesting
# this client's data.
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Zulip Calendar Bot'
HOME_DIR = os.path.expanduser('~')
CLIENT_SECRET_FILE = "client_secret.json"
APPLICATION_NAME = "Zulip Calendar Bot"
HOME_DIR = os.path.expanduser("~")
def get_credentials() -> client.Credentials:
@ -36,7 +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()
@ -50,7 +50,7 @@ def get_credentials() -> client.Credentials:
credentials = tools.run_flow(flow, store, flags)
else: # Needed only for compatibility with Python 2.6
credentials = tools.run(flow, store)
print('Storing credentials to ' + credential_path)
print("Storing credentials to " + credential_path)
get_credentials()

View file

@ -20,15 +20,15 @@ from oauth2client.file import Storage
try:
from googleapiclient import discovery
except ImportError:
logging.exception('Install google-api-python-client')
logging.exception("Install google-api-python-client")
sys.path.append(os.path.join(os.path.dirname(__file__), '../../'))
sys.path.append(os.path.join(os.path.dirname(__file__), "../../"))
import zulip
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
CLIENT_SECRET_FILE = 'client_secret.json'
APPLICATION_NAME = 'Zulip'
HOME_DIR = os.path.expanduser('~')
SCOPES = "https://www.googleapis.com/auth/calendar.readonly"
CLIENT_SECRET_FILE = "client_secret.json"
APPLICATION_NAME = "Zulip"
HOME_DIR = os.path.expanduser("~")
# Our cached view of the calendar, updated periodically.
events = [] # type: List[Tuple[int, datetime.datetime, str]]
@ -61,28 +61,28 @@ google-calendar --calendar calendarID@example.calendar.google.com
parser.add_argument(
'--interval',
dest='interval',
"--interval",
dest="interval",
default=30,
type=int,
action='store',
help='Minutes before event for reminder [default: 30]',
metavar='MINUTES',
action="store",
help="Minutes before event for reminder [default: 30]",
metavar="MINUTES",
)
parser.add_argument(
'--calendar',
dest='calendarID',
default='primary',
"--calendar",
dest="calendarID",
default="primary",
type=str,
action='store',
help='Calendar ID for the calendar you want to receive reminders from.',
action="store",
help="Calendar ID for the calendar you want to receive reminders from.",
)
options = parser.parse_args()
if not (options.zulip_email):
parser.error('You must specify --user')
parser.error("You must specify --user")
zulip_client = zulip.init_from_options(options)
@ -98,14 +98,14 @@ 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()
return credentials
except client.Error:
logging.exception('Error while trying to open the `google-credentials.json` file.')
logging.exception("Error while trying to open the `google-credentials.json` file.")
except OSError:
logging.error("Run the get-google-credentials script from this directory first.")
@ -115,7 +115,7 @@ def populate_events() -> Optional[None]:
credentials = get_credentials()
creds = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=creds)
service = discovery.build("calendar", "v3", http=creds)
now = datetime.datetime.now(pytz.utc).isoformat()
feed = (
@ -125,7 +125,7 @@ def populate_events() -> Optional[None]:
timeMin=now,
maxResults=5,
singleEvents=True,
orderBy='startTime',
orderBy="startTime",
)
.execute()
)
@ -174,10 +174,10 @@ def send_reminders() -> Optional[None]:
key = (id, start)
if key not in sent:
if start.hour == 0 and start.minute == 0:
line = '%s is today.' % (summary,)
line = "%s is today." % (summary,)
else:
line = '%s starts at %s' % (summary, start.strftime('%H:%M'))
print('Sending reminder:', line)
line = "%s starts at %s" % (summary, start.strftime("%H:%M"))
print("Sending reminder:", line)
messages.append(line)
keys.add(key)
@ -185,12 +185,12 @@ def send_reminders() -> Optional[None]:
return
if len(messages) == 1:
message = 'Reminder: ' + messages[0]
message = "Reminder: " + messages[0]
else:
message = 'Reminder:\n\n' + '\n'.join('* ' + m for m in messages)
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)
dict(type="private", to=options.zulip_email, sender=options.zulip_email, content=message)
)
sent.update(keys)