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

@ -25,22 +25,22 @@ def get_model_id(options):
"""
trello_api_url = 'https://api.trello.com/1/board/{}'.format(options.trello_board_id)
trello_api_url = "https://api.trello.com/1/board/{}".format(options.trello_board_id)
params = {
'key': options.trello_api_key,
'token': options.trello_token,
"key": options.trello_api_key,
"token": options.trello_token,
}
trello_response = requests.get(trello_api_url, params=params)
if trello_response.status_code != 200:
print('Error: Can\'t get the idModel. Please check the configuration')
print("Error: Can't get the idModel. Please check the configuration")
sys.exit(1)
board_info_json = trello_response.json()
return board_info_json['id']
return board_info_json["id"]
def get_webhook_id(options, id_model):
@ -55,27 +55,27 @@ def get_webhook_id(options, id_model):
"""
trello_api_url = 'https://api.trello.com/1/webhooks/'
trello_api_url = "https://api.trello.com/1/webhooks/"
data = {
'key': options.trello_api_key,
'token': options.trello_token,
'description': 'Webhook for Zulip integration (From Trello {} to Zulip)'.format(
"key": options.trello_api_key,
"token": options.trello_token,
"description": "Webhook for Zulip integration (From Trello {} to Zulip)".format(
options.trello_board_name,
),
'callbackURL': options.zulip_webhook_url,
'idModel': id_model,
"callbackURL": options.zulip_webhook_url,
"idModel": id_model,
}
trello_response = requests.post(trello_api_url, data=data)
if trello_response.status_code != 200:
print('Error: Can\'t create the Webhook:', trello_response.text)
print("Error: Can't create the Webhook:", trello_response.text)
sys.exit(1)
webhook_info_json = trello_response.json()
return webhook_info_json['id']
return webhook_info_json["id"]
def create_webhook(options):
@ -88,20 +88,20 @@ def create_webhook(options):
"""
# first, we need to get the idModel
print('Getting Trello idModel for the {} board...'.format(options.trello_board_name))
print("Getting Trello idModel for the {} board...".format(options.trello_board_name))
id_model = get_model_id(options)
if id_model:
print('Success! The idModel is', id_model)
print("Success! The idModel is", id_model)
id_webhook = get_webhook_id(options, id_model)
if id_webhook:
print('Success! The webhook ID is', id_webhook)
print("Success! The webhook ID is", id_webhook)
print(
'Success! The webhook for the {} Trello board was successfully created.'.format(
"Success! The webhook for the {} Trello board was successfully created.".format(
options.trello_board_name
)
)
@ -118,36 +118,36 @@ at <https://zulip.com/integrations/doc/trello>.
"""
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--trello-board-name', required=True, help='The Trello board name.')
parser.add_argument("--trello-board-name", required=True, help="The Trello board name.")
parser.add_argument(
'--trello-board-id',
"--trello-board-id",
required=True,
help=('The Trello board short ID. Can usually be found ' 'in the URL of the Trello board.'),
help=("The Trello board short ID. Can usually be found " "in the URL of the Trello board."),
)
parser.add_argument(
'--trello-api-key',
"--trello-api-key",
required=True,
help=(
'Visit https://trello.com/1/appkey/generate to generate '
'an APPLICATION_KEY (need to be logged into Trello).'
"Visit https://trello.com/1/appkey/generate to generate "
"an APPLICATION_KEY (need to be logged into Trello)."
),
)
parser.add_argument(
'--trello-token',
"--trello-token",
required=True,
help=(
'Visit https://trello.com/1/appkey/generate and under '
'`Developer API Keys`, click on `Token` and generate '
'a Trello access token.'
"Visit https://trello.com/1/appkey/generate and under "
"`Developer API Keys`, click on `Token` and generate "
"a Trello access token."
),
)
parser.add_argument(
'--zulip-webhook-url', required=True, help='The webhook URL that Trello will query.'
"--zulip-webhook-url", required=True, help="The webhook URL that Trello will query."
)
options = parser.parse_args()
create_webhook(options)
if __name__ == '__main__':
if __name__ == "__main__":
main()