Skip to content

Commit d1335ca

Browse files
committed
format with black and line-length=100
1 parent 84b0c27 commit d1335ca

File tree

8 files changed

+267
-372
lines changed

8 files changed

+267
-372
lines changed

challonge/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
from challonge import (
2-
tournaments,
3-
matches,
4-
participants,
5-
attachments)
1+
from challonge import tournaments, matches, participants, attachments
62
from challonge.api import (
73
set_credentials,
84
get_credentials,
95
set_timezone,
106
get_timezone,
117
fetch,
12-
ChallongeException)
8+
ChallongeException,
9+
)

challonge/api.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,15 @@ def fetch(method, uri, params_prefix=None, **params):
7474
url = "https://%s/%s.json" % (CHALLONGE_API_URL, uri)
7575

7676
try:
77-
response = request(
78-
method,
79-
url,
80-
auth=get_credentials(),
81-
**r_data)
77+
response = request(method, url, auth=get_credentials(), **r_data)
8278
response.raise_for_status()
8379
except HTTPError:
8480
if response.status_code != 422:
8581
response.raise_for_status()
8682
# wrap up application-level errors
8783
doc = response.json()
8884
if doc.get("errors"):
89-
raise ChallongeException(*doc['errors'])
85+
raise ChallongeException(*doc["errors"])
9086

9187
return response
9288

@@ -113,12 +109,13 @@ def _parse(data):
113109
to_parse = dict(d)
114110
for k, v in to_parse.items():
115111
if k in {
116-
"name",
117-
"display_name",
118-
"display_name_with_invitation_email_address",
119-
"username",
120-
"challonge_username"}:
121-
continue # do not test type of fields which are always strings
112+
"name",
113+
"display_name",
114+
"display_name_with_invitation_email_address",
115+
"username",
116+
"challonge_username",
117+
}:
118+
continue # do not test type of fields which are always strings
122119
if isinstance(v, TEXT_TYPE):
123120
try:
124121
dt = iso8601.parse_date(v)
@@ -142,7 +139,7 @@ def _prepare_params(dirty_params, prefix=None):
142139
objects.
143140
144141
"""
145-
if prefix and prefix.endswith('[]'):
142+
if prefix and prefix.endswith("[]"):
146143
keys = []
147144
values = []
148145
for k, v in dirty_params.items():

challonge/attachments.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
def index(tournament, match):
55
"""Retrieve a set of attachments created for a specific match."""
6-
return api.fetch_and_parse(
7-
"GET",
8-
"tournaments/%s/matches/%s/attachments" % (tournament, match))
6+
return api.fetch_and_parse("GET", "tournaments/%s/matches/%s/attachments" % (tournament, match))
97

108

119
def create(tournament, match, **params):
@@ -14,14 +12,15 @@ def create(tournament, match, **params):
1412
"POST",
1513
"tournaments/%s/matches/%s/attachments" % (tournament, match),
1614
"match_attachment",
17-
**params)
15+
**params
16+
)
1817

1918

2019
def show(tournament, match, attachment):
2120
"""Retrieve a single match attachment record."""
2221
return api.fetch_and_parse(
23-
"GET",
24-
"tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment))
22+
"GET", "tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment)
23+
)
2524

2625

2726
def update(tournament, match, attachment, **params):
@@ -30,11 +29,12 @@ def update(tournament, match, attachment, **params):
3029
"PUT",
3130
"tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment),
3231
"match_attachment",
33-
**params)
32+
**params
33+
)
3434

3535

3636
def destroy(tournament, match, attachment):
3737
"""Delete a match attachment."""
3838
api.fetch(
39-
"DELETE",
40-
"tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment))
39+
"DELETE", "tournaments/%s/matches/%s/attachments/%s" % (tournament, match, attachment)
40+
)

challonge/matches.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,31 @@
33

44
def index(tournament, **params):
55
"""Retrieve a tournament's match list."""
6-
return api.fetch_and_parse(
7-
"GET",
8-
"tournaments/%s/matches" % tournament,
9-
**params)
6+
return api.fetch_and_parse("GET", "tournaments/%s/matches" % tournament, **params)
107

118

129
def show(tournament, match_id, **params):
1310
"""Retrieve a single match record for a tournament."""
1411
return api.fetch_and_parse(
15-
"GET",
16-
"tournaments/%s/matches/%s" % (tournament, match_id),
17-
**params)
12+
"GET", "tournaments/%s/matches/%s" % (tournament, match_id), **params
13+
)
1814

1915

2016
def update(tournament, match_id, **params):
2117
"""Update/submit the score(s) for a match."""
22-
api.fetch(
23-
"PUT",
24-
"tournaments/%s/matches/%s" % (tournament, match_id),
25-
"match",
26-
**params)
18+
api.fetch("PUT", "tournaments/%s/matches/%s" % (tournament, match_id), "match", **params)
2719

2820

2921
def reopen(tournament, match_id):
3022
"""Reopens a match that was marked completed, automatically resetting matches that follow it."""
31-
api.fetch(
32-
"POST",
33-
"tournaments/%s/matches/%s/reopen" % (tournament, match_id))
23+
api.fetch("POST", "tournaments/%s/matches/%s/reopen" % (tournament, match_id))
3424

3525

3626
def mark_as_underway(tournament, match_id):
3727
"""Sets "underway_at" to the current time and highlights the match in the bracket"""
38-
api.fetch(
39-
"POST",
40-
"tournaments/%s/matches/%s/mark_as_underway" % (tournament, match_id))
28+
api.fetch("POST", "tournaments/%s/matches/%s/mark_as_underway" % (tournament, match_id))
4129

4230

4331
def unmark_as_underway(tournament, match_id):
4432
"""Clears "underway_at" and unhighlights the match in the bracket"""
45-
api.fetch(
46-
"POST",
47-
"tournaments/%s/matches/%s/unmark_as_underway" % (tournament, match_id))
48-
33+
api.fetch("POST", "tournaments/%s/matches/%s/unmark_as_underway" % (tournament, match_id))

challonge/participants.py

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,16 @@
33

44
def index(tournament):
55
"""Retrieve a tournament's participant list."""
6-
return api.fetch_and_parse(
7-
"GET",
8-
"tournaments/%s/participants" % tournament)
6+
return api.fetch_and_parse("GET", "tournaments/%s/participants" % tournament)
97

108

119
def create(tournament, name, **params):
1210
"""Add a participant to a tournament."""
1311
params.update({"name": name})
1412

1513
return api.fetch_and_parse(
16-
"POST",
17-
"tournaments/%s/participants" % tournament,
18-
"participant",
19-
**params)
14+
"POST", "tournaments/%s/participants" % tournament, "participant", **params
15+
)
2016

2117

2218
def bulk_add(tournament, names, **params):
@@ -33,18 +29,15 @@ def bulk_add(tournament, names, **params):
3329
params.update({"name": names})
3430

3531
return api.fetch_and_parse(
36-
"POST",
37-
"tournaments/%s/participants/bulk_add" % tournament,
38-
"participants[]",
39-
**params)
32+
"POST", "tournaments/%s/participants/bulk_add" % tournament, "participants[]", **params
33+
)
4034

4135

4236
def show(tournament, participant_id, **params):
4337
"""Retrieve a single participant record for a tournament."""
4438
return api.fetch_and_parse(
45-
"GET",
46-
"tournaments/%s/participants/%s" % (tournament, participant_id),
47-
**params)
39+
"GET", "tournaments/%s/participants/%s" % (tournament, participant_id), **params
40+
)
4841

4942

5043
def update(tournament, participant_id, **params):
@@ -53,21 +46,18 @@ def update(tournament, participant_id, **params):
5346
"PUT",
5447
"tournaments/%s/participants/%s" % (tournament, participant_id),
5548
"participant",
56-
**params)
49+
**params
50+
)
5751

5852

5953
def check_in(tournament, participant_id):
6054
"""Checks a participant in."""
61-
api.fetch(
62-
"POST",
63-
"tournaments/%s/participants/%s/check_in" % (tournament, participant_id))
55+
api.fetch("POST", "tournaments/%s/participants/%s/check_in" % (tournament, participant_id))
6456

6557

6658
def undo_check_in(tournament, participant_id):
6759
"""Marks a participant as having not checked in."""
68-
api.fetch(
69-
"POST",
70-
"tournaments/%s/participants/%s/undo_check_in" % (tournament, participant_id))
60+
api.fetch("POST", "tournaments/%s/participants/%s/undo_check_in" % (tournament, participant_id))
7161

7262

7363
def destroy(tournament, participant_id):
@@ -80,9 +70,7 @@ def destroy(tournament, participant_id):
8070
forfeiting his/her remaining matches.
8171
8272
"""
83-
api.fetch(
84-
"DELETE",
85-
"tournaments/%s/participants/%s" % (tournament, participant_id))
73+
api.fetch("DELETE", "tournaments/%s/participants/%s" % (tournament, participant_id))
8674

8775

8876
def randomize(tournament):

challonge/tournaments.py

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ def index(**params):
88

99
def create(name, url, tournament_type="single elimination", **params):
1010
"""Create a new tournament."""
11-
params.update({
12-
"name": name,
13-
"url": url,
14-
"tournament_type": tournament_type,
15-
})
11+
params.update(
12+
{
13+
"name": name,
14+
"url": url,
15+
"tournament_type": tournament_type,
16+
}
17+
)
1618

1719
return api.fetch_and_parse("POST", "tournaments", "tournament", **params)
1820

@@ -45,10 +47,7 @@ def process_check_ins(tournament, **params):
4547
3) Transitions the tournament state from 'checking_in' to 'checked_in'
4648
4749
"""
48-
return api.fetch_and_parse(
49-
"POST",
50-
"tournaments/%s/process_check_ins" % tournament,
51-
**params)
50+
return api.fetch_and_parse("POST", "tournaments/%s/process_check_ins" % tournament, **params)
5251

5352

5453
def abort_check_in(tournament, **params):
@@ -61,10 +60,7 @@ def abort_check_in(tournament, **params):
6160
2) Transitions the tournament state from 'checking_in' or 'checked_in' to 'pending'
6261
6362
"""
64-
return api.fetch_and_parse(
65-
"POST",
66-
"tournaments/%s/abort_check_in" % tournament,
67-
**params)
63+
return api.fetch_and_parse("POST", "tournaments/%s/abort_check_in" % tournament, **params)
6864

6965

7066
def open_for_predictions(tournament, **params):
@@ -74,10 +70,7 @@ def open_for_predictions(tournament, **params):
7470
'prediction_method' must be set to 1 (exponential scoring) or 2 (linear scoring) to use this option.
7571
7672
"""
77-
return api.fetch_and_parse(
78-
"POST",
79-
"tournaments/%s/open_for_predictions" % tournament,
80-
**params)
73+
return api.fetch_and_parse("POST", "tournaments/%s/open_for_predictions" % tournament, **params)
8174

8275

8376
def start(tournament, **params):
@@ -86,21 +79,15 @@ def start(tournament, **params):
8679
The tournament must have at least 2 participants.
8780
8881
"""
89-
return api.fetch_and_parse(
90-
"POST",
91-
"tournaments/%s/start" % tournament,
92-
**params)
82+
return api.fetch_and_parse("POST", "tournaments/%s/start" % tournament, **params)
9383

9484

9585
def finalize(tournament, **params):
9686
"""Finalize a tournament that has had all match scores submitted,
9787
rendering its results permanent.
9888
9989
"""
100-
return api.fetch_and_parse(
101-
"POST",
102-
"tournaments/%s/finalize" % tournament,
103-
**params)
90+
return api.fetch_and_parse("POST", "tournaments/%s/finalize" % tournament, **params)
10491

10592

10693
def reset(tournament, **params):
@@ -110,7 +97,4 @@ def reset(tournament, **params):
11097
tournament again.
11198
11299
"""
113-
return api.fetch_and_parse(
114-
"POST",
115-
"tournaments/%s/reset" % tournament,
116-
**params)
100+
return api.fetch_and_parse("POST", "tournaments/%s/reset" % tournament, **params)

0 commit comments

Comments
 (0)