Skip to content

Commit 06a7958

Browse files
author
Dominik Neise
committed
black -l 80
1 parent 7086f7f commit 06a7958

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1105
-323
lines changed

docs/source/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,13 @@
182182
# Grouping the document tree into LaTeX files. List of tuples
183183
# (source start file, target name, title, author, documentclass [howto/manual]).
184184
latex_documents = [
185-
("index", "sc2reader.tex", u"sc2reader Documentation", u"Graylin Kim", "manual")
185+
(
186+
"index",
187+
"sc2reader.tex",
188+
u"sc2reader Documentation",
189+
u"Graylin Kim",
190+
"manual",
191+
)
186192
]
187193

188194
# The name of an image file (relative to this directory) to place at the top of
@@ -213,4 +219,6 @@
213219

214220
# One entry per manual page. List of tuples
215221
# (source start file, name, description, authors, manual section).
216-
man_pages = [("index", "sc2reader", u"sc2reader Documentation", [u"Graylin Kim"], 1)]
222+
man_pages = [
223+
("index", "sc2reader", u"sc2reader Documentation", [u"Graylin Kim"], 1)
224+
]

examples/sc2autosave.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ def reset(args):
391391
def setup(args):
392392
args.team_compare, args.player_compare = create_compare_funcs(args)
393393
args.action = sc2reader.utils.AttributeDict(
394-
type=args.action, run=shutil.copy if args.action == "COPY" else shutil.move
394+
type=args.action,
395+
run=shutil.copy if args.action == "COPY" else shutil.move,
395396
)
396397
if not os.path.exists(args.source):
397398
msg = "Source does not exist: {0}.\n\nScript Aborted."
@@ -432,13 +433,19 @@ def main():
432433
parser = argparse.ArgumentParser(
433434
description="Automatically copy new replays to directory",
434435
fromfile_prefix_chars="@",
435-
formatter_class=sc2reader.scripts.utils.Formatter.new(max_help_position=35),
436+
formatter_class=sc2reader.scripts.utils.Formatter.new(
437+
max_help_position=35
438+
),
436439
epilog="And that's all folks",
437440
)
438441

439442
required = parser.add_argument_group("Required Arguments")
440-
required.add_argument("source", type=str, help="The source directory to poll")
441-
required.add_argument("dest", type=str, help="The destination directory to copy to")
443+
required.add_argument(
444+
"source", type=str, help="The source directory to poll"
445+
)
446+
required.add_argument(
447+
"dest", type=str, help="The destination directory to copy to"
448+
)
442449

443450
general = parser.add_argument_group("General Options")
444451
general.add_argument(

examples/sc2store.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ class Player(Base):
150150

151151
def __init__(self, player, db):
152152
try:
153-
self.person = db.query(Person).filter(Person.name == player.name).one()
153+
self.person = (
154+
db.query(Person).filter(Person.name == player.name).one()
155+
)
154156
except NoResultFound as e:
155157
self.person = Person()
156158
self.person.name = player.name

generate_build_data.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ def generate_build_data(balance_data_path):
3232
command_index = int(command_index_str)
3333

3434
# Pad potential gaps in command indices with empty strings
35-
while len(ability_lookup[ability_name]) <= command_index:
35+
while (
36+
len(ability_lookup[ability_name]) <= command_index
37+
):
3638
ability_lookup[ability_name].append("")
3739

3840
command_name = (
39-
command_id if command_id != "Execute" else ability_name
41+
command_id
42+
if command_id != "Execute"
43+
else ability_name
4044
)
41-
ability_lookup[ability_name][command_index] = command_name
45+
ability_lookup[ability_name][
46+
command_index
47+
] = command_name
4248

4349
unit_id = root.get("id")
4450

@@ -74,7 +80,9 @@ def generate_build_data(balance_data_path):
7480
command_index = int(command_index_str)
7581

7682
# Pad potential gaps in command indices with empty strings
77-
while len(ability_lookup[build_ability_name]) <= command_index:
83+
while (
84+
len(ability_lookup[build_ability_name]) <= command_index
85+
):
7886
ability_lookup[build_ability_name].append("")
7987

8088
build_command_name = "Build{}".format(built_unit_id)
@@ -118,7 +126,8 @@ def generate_build_data(balance_data_path):
118126

119127
# Pad potential gaps in command indices with empty strings
120128
while (
121-
len(ability_lookup[train_ability_name]) <= command_index
129+
len(ability_lookup[train_ability_name])
130+
<= command_index
122131
):
123132
ability_lookup[train_ability_name].append("")
124133

@@ -133,11 +142,14 @@ def generate_build_data(balance_data_path):
133142

134143
# Pad potential gaps in command indices with empty strings
135144
while (
136-
len(ability_lookup[train_ability_name]) <= command_index
145+
len(ability_lookup[train_ability_name])
146+
<= command_index
137147
):
138148
ability_lookup[train_ability_name].append("")
139149

140-
train_command_name = "Train{}".format(trained_unit_name)
150+
train_command_name = "Train{}".format(
151+
trained_unit_name
152+
)
141153
ability_lookup[train_ability_name][
142154
command_index
143155
] = train_command_name
@@ -160,10 +172,15 @@ def generate_build_data(balance_data_path):
160172
command_index = int(command_index_str)
161173

162174
# Pad potential gaps in command indices with empty strings
163-
while len(ability_lookup[research_ability_name]) <= command_index:
175+
while (
176+
len(ability_lookup[research_ability_name])
177+
<= command_index
178+
):
164179
ability_lookup[research_ability_name].append("")
165180

166-
research_command_name = "Research{}".format(researched_upgrade_id)
181+
research_command_name = "Research{}".format(
182+
researched_upgrade_id
183+
)
167184
ability_lookup[research_ability_name][
168185
command_index
169186
] = research_command_name
@@ -175,7 +192,9 @@ def generate_build_data(balance_data_path):
175192
sorted(abilities.items(), key=lambda x: int(x[0]))
176193
)
177194

178-
unit_lookup = dict((unit_name, unit_name) for _, unit_name in sorted_units.items())
195+
unit_lookup = dict(
196+
(unit_name, unit_name) for _, unit_name in sorted_units.items()
197+
)
179198

180199
return sorted_units, sorted_abilities, unit_lookup, ability_lookup
181200

new_units.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
print("")
2626

2727
ABIL_LOOKUP = dict()
28-
for entry in pkgutil.get_data("sc2reader.data", "ability_lookup.csv").split("\n"):
28+
for entry in pkgutil.get_data("sc2reader.data", "ability_lookup.csv").split(
29+
"\n"
30+
):
2931
if not entry:
3032
continue
3133
str_id, abilities = entry.split(",", 1)

sc2reader/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
:copyright: (c) 2011 by Graylin Kim.
1919
:license: MIT, see LICENSE for more details.
2020
"""
21-
from __future__ import absolute_import, print_function, unicode_literals, division
21+
from __future__ import (
22+
absolute_import,
23+
print_function,
24+
unicode_literals,
25+
division,
26+
)
2227

2328
__version__ = "0.8.0"
2429

@@ -95,7 +100,9 @@ def useDoubleCache(cache_dir, cache_max_size=0, **options):
95100
A limited number of remote resources are cached in memory for faster access times.
96101
All remote resources are saved to the file system for faster access times.
97102
"""
98-
setFactory(factories.DoubleCachedSC2Factory(cache_dir, cache_max_size, **options))
103+
setFactory(
104+
factories.DoubleCachedSC2Factory(cache_dir, cache_max_size, **options)
105+
)
99106

100107

101108
# Allow environment variables to activate caching

sc2reader/constants.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, unicode_literals, division
2+
from __future__ import (
3+
absolute_import,
4+
print_function,
5+
unicode_literals,
6+
division,
7+
)
38

49
# These are found in Repack-MPQ/fileset.{locale}#Mods#Core.SC2Mod#{locale}.SC2Data/LocalizedData/Editor/EditorCategoryStrings.txt
510
# EDSTR_CATEGORY_Race
@@ -46,9 +51,27 @@
4651

4752

4853
GAME_SPEED_FACTOR = {
49-
"WoL": {"Slower": 0.6, "Slow": 0.8, "Normal": 1.0, "Fast": 1.2, "Faster": 1.4},
50-
"HotS": {"Slower": 0.6, "Slow": 0.8, "Normal": 1.0, "Fast": 1.2, "Faster": 1.4},
51-
"LotV": {"Slower": 0.2, "Slow": 0.4, "Normal": 0.6, "Fast": 0.8, "Faster": 1.0},
54+
"WoL": {
55+
"Slower": 0.6,
56+
"Slow": 0.8,
57+
"Normal": 1.0,
58+
"Fast": 1.2,
59+
"Faster": 1.4,
60+
},
61+
"HotS": {
62+
"Slower": 0.6,
63+
"Slow": 0.8,
64+
"Normal": 1.0,
65+
"Fast": 1.2,
66+
"Faster": 1.4,
67+
},
68+
"LotV": {
69+
"Slower": 0.2,
70+
"Slow": 0.4,
71+
"Normal": 0.6,
72+
"Fast": 0.8,
73+
"Faster": 1.0,
74+
},
5275
}
5376

5477
GATEWAY_CODES = {
@@ -107,7 +130,9 @@
107130
import json
108131
import pkgutil
109132

110-
attributes_json = pkgutil.get_data("sc2reader.data", "attributes.json").decode("utf8")
133+
attributes_json = pkgutil.get_data("sc2reader.data", "attributes.json").decode(
134+
"utf8"
135+
)
111136
attributes_dict = json.loads(attributes_json)
112137
LOBBY_PROPERTIES = dict()
113138
for key, value in attributes_dict.get("attributes", dict()).items():

sc2reader/data/__init__.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, unicode_literals, division
2+
from __future__ import (
3+
absolute_import,
4+
print_function,
5+
unicode_literals,
6+
division,
7+
)
38

49
import json
510
import pkgutil
@@ -18,7 +23,9 @@
1823

1924
ABIL_LOOKUP = dict()
2025
for entry in (
21-
pkgutil.get_data("sc2reader.data", "ability_lookup.csv").decode("utf8").split("\n")
26+
pkgutil.get_data("sc2reader.data", "ability_lookup.csv")
27+
.decode("utf8")
28+
.split("\n")
2229
):
2330
if not entry:
2431
continue
@@ -27,7 +34,9 @@
2734

2835
UNIT_LOOKUP = dict()
2936
for entry in (
30-
pkgutil.get_data("sc2reader.data", "unit_lookup.csv").decode("utf8").split("\n")
37+
pkgutil.get_data("sc2reader.data", "unit_lookup.csv")
38+
.decode("utf8")
39+
.split("\n")
3140
):
3241
if not entry:
3342
continue
@@ -37,7 +46,9 @@
3746
unit_data = pkgutil.get_data("sc2reader.data", "unit_info.json").decode("utf8")
3847
unit_lookup = json.loads(unit_data)
3948

40-
command_data = pkgutil.get_data("sc2reader.data", "train_commands.json").decode("utf8")
49+
command_data = pkgutil.get_data("sc2reader.data", "train_commands.json").decode(
50+
"utf8"
51+
)
4152
train_commands = json.loads(command_data)
4253

4354

@@ -275,7 +286,13 @@ class Ability(object):
275286
""" Represents an in-game ability """
276287

277288
def __init__(
278-
self, id, name=None, title=None, is_build=False, build_time=0, build_unit=None
289+
self,
290+
id,
291+
name=None,
292+
title=None,
293+
is_build=False,
294+
build_time=0,
295+
build_unit=None,
279296
):
280297
#: The internal integer id representing this ability.
281298
self.id = id
@@ -432,7 +449,9 @@ def load_build(expansion, version):
432449
int_id_base = int(int_id_base, 10) << 5
433450

434451
abils = ABIL_LOOKUP[str_id]
435-
real_abils = [(i, abil) for i, abil in enumerate(abils) if abil.strip() != ""]
452+
real_abils = [
453+
(i, abil) for i, abil in enumerate(abils) if abil.strip() != ""
454+
]
436455

437456
if len(real_abils) == 0:
438457
real_abils = [(0, str_id)]
@@ -469,7 +488,20 @@ def load_build(expansion, version):
469488

470489
# Load LotV Data
471490
lotv_builds = dict()
472-
for version in ("base", "44401", "47185", "48258", "53644", "54724", "59587", "70154"):
491+
for version in (
492+
"base",
493+
"44401",
494+
"47185",
495+
"48258",
496+
"53644",
497+
"54724",
498+
"59587",
499+
"70154",
500+
):
473501
lotv_builds[version] = load_build("LotV", version)
474502

475-
datapacks = builds = {"WoL": wol_builds, "HotS": hots_builds, "LotV": lotv_builds}
503+
datapacks = builds = {
504+
"WoL": wol_builds,
505+
"HotS": hots_builds,
506+
"LotV": lotv_builds,
507+
}

sc2reader/decoders.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, unicode_literals, division
2+
from __future__ import (
3+
absolute_import,
4+
print_function,
5+
unicode_literals,
6+
division,
7+
)
38

49
from io import BytesIO
510

@@ -63,7 +68,9 @@ def __init__(self, contents, endian):
6368
self._unpack_int = struct.Struct(str(self.endian + "I")).unpack
6469
self._unpack_short = struct.Struct(str(self.endian + "H")).unpack
6570
self._unpack_longlong = struct.Struct(str(self.endian + "Q")).unpack
66-
self._unpack_bytes = lambda bytes: bytes if self.endian == ">" else bytes[::-1]
71+
self._unpack_bytes = (
72+
lambda bytes: bytes if self.endian == ">" else bytes[::-1]
73+
)
6774

6875
def done(self):
6976
""" Returns true when all bytes have been decoded """
@@ -265,7 +272,9 @@ def read_bytes(self, count):
265272
lo_mask, hi_mask = self._bit_masks[self._bit_shift]
266273
for next_byte in struct.unpack(str("B") * count, data):
267274
temp_buffer.write(
268-
struct.pack(str("B"), prev_byte & hi_mask | next_byte & lo_mask)
275+
struct.pack(
276+
str("B"), prev_byte & hi_mask | next_byte & lo_mask
277+
)
269278
)
270279
prev_byte = next_byte
271280

sc2reader/engine/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, print_function, unicode_literals, division
2+
from __future__ import (
3+
absolute_import,
4+
print_function,
5+
unicode_literals,
6+
division,
7+
)
38

49
import sys
510
from sc2reader.engine.engine import GameEngine

0 commit comments

Comments
 (0)