Skip to content

Commit 1f18ff7

Browse files
committed
Update README.rst and setup.py
1 parent 2a49356 commit 1f18ff7

File tree

13 files changed

+82
-115
lines changed

13 files changed

+82
-115
lines changed

README.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
What is sc2reader?
55
====================
66

7-
sc2reader is a python library for extracting information from various different Starcraft II resources. These resources currently include Replays, Maps, and Game Summaries; we have plans to add support for Battle.net profiles and would gladly accept adapters to the more entrenched SCII sites such as sc2ranks.
7+
sc2reader is a Python 3 library for extracting information from various different Starcraft II resources. These resources currently include Replays, Maps, and Game Summaries; we have plans to add support for Battle.net profiles and would gladly accept adapters to the more entrenched SCII sites such as sc2ranks.
88

99
There is a pressing need in the SC2 community for better statistics, better analytics, better tools for organizing and searching replays. Better websites for sharing replays and hosting tournaments. These tools can't be created without first being able to open up Starcraft II game files and analyze the data within. Our goal is to give anyone and everyone the power to construct their own tools, do their own analysis, and hack on their own Starcraft II projects under the open MIT license.
1010

@@ -195,26 +195,22 @@ The new GameHeartNormalizerplugin is registered by default.
195195
Installation
196196
================
197197

198-
sc2reader runs on any system with Python 2.6+, 3.2+, or PyPy installed.
198+
sc2reader runs on any system with Python 3.7+, or PyPy3 installed.
199199

200200

201201
From PyPI (stable)
202202
---------------------
203203

204204
Install from the latest release on PyPI with pip::
205205

206-
pip install sc2reader
207-
208-
or easy_install::
209-
210-
easy_install sc2reader
206+
python3 -m pip install sc2reader
211207

212208
or with setuptools (specify a valid x.x.x)::
213209

214210
wget http://pypi.python.org/packages/source/s/sc2reader/sc2reader-x.x.x.tar.gz
215211
tar -xzf sc2reader-x.x.x.tar.gz
216212
cd sc2reader-x.x.x
217-
python setup.py install
213+
python3 setup.py install
218214

219215
Releases to PyPi can be very delayed (sorry!), for the latest and greatest you are encouraged to install from Github upstream.
220216

@@ -235,7 +231,7 @@ or with setuptools::
235231
wget -O sc2reader-upstream.tar.gz https://github.com/ggtracker/sc2reader/tarball/upstream
236232
tar -xzf sc2reader-upstream.tar.gz
237233
cd sc2reader-upstream
238-
python setup.py install
234+
python3 setup.py install
239235

240236
.. _circle-ci: https://circleci.com/
241237
.. _coveralls.io: https://coveralls.io
@@ -250,7 +246,7 @@ Contributors should install from an active git repository using setuptools in `d
250246

251247
git clone https://github.com/ggtracker/sc2reader.git
252248
cd sc2reader
253-
python setup.py develop
249+
python3 setup.py develop
254250

255251
Please review the `CONTRIBUTING.md`_ file and get in touch with us before doing too much work. It'll make everyone happier in the long run.
256252

sc2reader/decoders.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,7 @@ def read_struct(self, datatype=None):
410410

411411
elif datatype == 0x05: # Struct
412412
entries = self.read_vint()
413-
data = {
414-
self.read_vint(): self.read_struct() for i in range(entries)
415-
}
413+
data = {self.read_vint(): self.read_struct() for i in range(entries)}
416414

417415
elif datatype == 0x06: # u8
418416
data = ord(self._buffer.read(1))

sc2reader/events/game.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,7 @@ def __init__(self, frame, pid, data):
630630
self.yaw = data["yaw"]
631631

632632
def __str__(self):
633-
return self._str_prefix() + "{} at ({}, {})".format(
634-
self.name, self.x, self.y
635-
)
633+
return self._str_prefix() + "{} at ({}, {})".format(self.name, self.x, self.y)
636634

637635

638636
@loggable
@@ -673,12 +671,15 @@ def __init__(self, frame, pid, data):
673671
self.custom_resource = self.resources[3] if len(self.resources) >= 4 else None
674672

675673
def __str__(self):
676-
return self._str_prefix() + " transfer {} minerals, {} gas, {} terrazine, and {} custom to {}".format(
677-
self.minerals,
678-
self.vespene,
679-
self.terrazine,
680-
self.custom_resource,
681-
self.recipient,
674+
return (
675+
self._str_prefix()
676+
+ " transfer {} minerals, {} gas, {} terrazine, and {} custom to {}".format(
677+
self.minerals,
678+
self.vespene,
679+
self.terrazine,
680+
self.custom_resource,
681+
self.recipient,
682+
)
682683
)
683684

684685

sc2reader/factories/plugins/replay.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,7 @@ def SelectionTracker(replay):
213213
person.selection_errors += 1
214214
if debug:
215215
logger.warn(
216-
"Error detected in deselection mode {}.".format(
217-
event.mask_type
218-
)
216+
"Error detected in deselection mode {}.".format(event.mask_type)
219217
)
220218

221219
person.selection = player_selections

sc2reader/factories/sc2factory.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,7 @@ def get_remote_cache_key(self, remote_resource):
259259
def load_remote_resource_contents(self, remote_resource, **options):
260260
cache_key = self.get_remote_cache_key(remote_resource)
261261
if not self.cache_has(cache_key):
262-
resource = super().load_remote_resource_contents(
263-
remote_resource, **options
264-
)
262+
resource = super().load_remote_resource_contents(remote_resource, **options)
265263
self.cache_set(cache_key, resource)
266264
else:
267265
resource = self.cache_get(cache_key)
@@ -363,9 +361,7 @@ class DoubleCachedSC2Factory(DictCachedSC2Factory, FileCachedSC2Factory):
363361
"""
364362

365363
def __init__(self, cache_dir, cache_max_size=0, **options):
366-
super().__init__(
367-
cache_max_size, cache_dir=cache_dir, **options
368-
)
364+
super().__init__(cache_max_size, cache_dir=cache_dir, **options)
369365

370366
def load_remote_resource_contents(self, remote_resource, **options):
371367
cache_key = self.get_remote_cache_key(remote_resource)

sc2reader/objects.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Team:
1919
"""
2020

2121
#: A unique hash identifying the team of players
22-
hash = ''
22+
hash = ""
2323

2424
#: The team number as recorded in the replay
2525
number = int()
@@ -29,7 +29,7 @@ class Team:
2929

3030
#: The result of the game for this team.
3131
#: One of "Win", "Loss", or "Unknown"
32-
result = ''
32+
result = ""
3333

3434
def __init__(self, number):
3535
self.number = number
@@ -385,10 +385,10 @@ class PlayerSummary:
385385
teamid = int()
386386

387387
#: The race the player played in the game.
388-
play_race = ''
388+
play_race = ""
389389

390390
#: The race the player picked in the lobby.
391-
pick_race = ''
391+
pick_race = ""
392392

393393
#: If the player is a computer
394394
is_ai = False
@@ -403,7 +403,7 @@ class PlayerSummary:
403403
subregion = int()
404404

405405
#: The player's region, such as us, eu, sea
406-
region = ''
406+
region = ""
407407

408408
#: unknown1
409409
unknown1 = int()
@@ -569,15 +569,15 @@ def __init__(self, contents):
569569
self.small_preview_type = data.read_uint32()
570570

571571
#: (Optional) Small map preview path; relative to root of map archive
572-
self.small_preview_path = ''
572+
self.small_preview_path = ""
573573
if self.small_preview_type == 2:
574574
self.small_preview_path = data.read_cstring()
575575

576576
#: Large map preview type: 0 = None, 1 = Minimap, 2 = Custom
577577
self.large_preview_type = data.read_uint32()
578578

579579
#: (Optional) Large map preview path; relative to root of map archive
580-
self.large_preview_path = ''
580+
self.large_preview_path = ""
581581
if self.large_preview_type == 2:
582582
self.large_preview_path = data.read_cstring()
583583

sc2reader/resources.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Replay(Resource):
4747
attributes = defaultdict(dict)
4848

4949
#: Fully qualified filename of the replay file represented.
50-
filename = ''
50+
filename = ""
5151

5252
#: Total number of frames in this game at 16 frames per second.
5353
frames = int()
@@ -59,27 +59,27 @@ class Replay(Resource):
5959
base_build = int()
6060

6161
#: The full version release string as seen on Battle.net
62-
release_string = ''
62+
release_string = ""
6363

6464
#: A tuple of the individual pieces of the release string
6565
versions = tuple()
6666

6767
#: The game speed: Slower, Slow, Normal, Fast, Faster
68-
speed = ''
68+
speed = ""
6969

7070
#: Deprecated, use :attr:`game_type` or :attr:`real_type` instead
71-
type = ''
71+
type = ""
7272

7373
#: The game type chosen at game creation: 1v1, 2v2, 3v3, 4v4, FFA
74-
game_type = ''
74+
game_type = ""
7575

7676
#: The real type of the replay as observed by counting players on teams.
7777
#: For outmatched games, the smaller team numbers come first.
7878
#: Example Values: 1v1, 2v2, 3v3, FFA, 2v4, etc.
79-
real_type = ''
79+
real_type = ""
8080

8181
#: The category of the game, Ladder and Private
82-
category = ''
82+
category = ""
8383

8484
#: A flag for public ladder games
8585
is_ladder = bool()
@@ -88,10 +88,10 @@ class Replay(Resource):
8888
is_private = bool()
8989

9090
#: The raw hash name of the s2ma resource as hosted on bnet depots
91-
map_hash = ''
91+
map_hash = ""
9292

9393
#: The name of the map the game was played on
94-
map_name = ''
94+
map_name = ""
9595

9696
#: A reference to the loaded :class:`Map` resource.
9797
map = None
@@ -127,7 +127,7 @@ class Replay(Resource):
127127
real_length = None
128128

129129
#: The region the game was played on: us, eu, sea, etc
130-
region = ''
130+
region = ""
131131

132132
#: An integrated list of all the game events
133133
events = list()
@@ -184,10 +184,10 @@ class Replay(Resource):
184184
#: A sha256 hash uniquely representing the combination of people in the game.
185185
#: Can be used in conjunction with date times to match different replays
186186
#: of the game game.
187-
people_hash = ''
187+
people_hash = ""
188188

189189
#: SC2 Expansion. One of 'WoL', 'HotS'
190-
expansion = ''
190+
expansion = ""
191191

192192
#: True of the game was resumed from a replay
193193
resume_from_replay = False
@@ -205,7 +205,7 @@ def __init__(
205205
load_level=4,
206206
engine=sc2reader.engine,
207207
do_tracker_events=True,
208-
**options
208+
**options,
209209
):
210210
super().__init__(replay_file, filename, **options)
211211
self.datapack = None
@@ -915,16 +915,16 @@ def __init__(self, map_file, filename=None, region=None, map_hash=None, **option
915915
super().__init__(map_file, filename, **options)
916916

917917
#: The localized (only enUS supported right now) map name.
918-
self.name = ''
918+
self.name = ""
919919

920920
#: The localized (only enUS supported right now) map author.
921-
self.author = ''
921+
self.author = ""
922922

923923
#: The localized (only enUS supported right now) map description.
924-
self.description = ''
924+
self.description = ""
925925

926926
#: The localized (only enUS supported right now) map website.
927-
self.website = ''
927+
self.website = ""
928928

929929
#: The unique hash used to identify this map on bnet's depots.
930930
self.hash = map_hash
@@ -1015,7 +1015,7 @@ class GameSummary(Resource):
10151015
"""
10161016

10171017
#: Game speed
1018-
game_speed = ''
1018+
game_speed = ""
10191019

10201020
#: Game length (real-time)
10211021
real_length = int()
@@ -1069,8 +1069,8 @@ def __init__(self, summary_file, filename=None, lang="enUS", **options):
10691069
self.localization_urls = dict()
10701070
self.lobby_properties = dict()
10711071
self.lobby_player_properties = dict()
1072-
self.game_type = ''
1073-
self.real_type = ''
1072+
self.game_type = ""
1073+
self.real_type = ""
10741074

10751075
# The first 16 bytes appear to be some sort of compression header
10761076
buffer = BitPackedDecoder(zlib.decompress(summary_file.read()[16:]))
@@ -1442,19 +1442,19 @@ class MapHeader(Resource):
14421442
"""**Experimental**"""
14431443

14441444
#: The name of the map
1445-
name = ''
1445+
name = ""
14461446

14471447
#: Hash of map file
1448-
map_hash = ''
1448+
map_hash = ""
14491449

14501450
#: Link to the map file
1451-
map_url = ''
1451+
map_url = ""
14521452

14531453
#: Hash of the map image
1454-
image_hash = ''
1454+
image_hash = ""
14551455

14561456
#: Link to the image of the map (.s2mv)
1457-
image_url = ''
1457+
image_url = ""
14581458

14591459
#: Localization dictionary, {language, url}
14601460
localization_urls = dict()

sc2reader/scripts/sc2attributes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ def get_choice(s2gs_key, old_value, new_value):
119119
# This way old/new values can be swapped and decision is remembered
120120
key = frozenset([s2gs_key, old_value, new_value])
121121
if key not in decisions:
122-
print(
123-
f"Naming conflict on {s2gs_key}: {old_value} != {new_value}"
124-
)
122+
print(f"Naming conflict on {s2gs_key}: {old_value} != {new_value}")
125123
print("Which do you want to use?")
126124
print(f" (o) Old value '{old_value}'")
127125
print(f" (n) New value '{new_value}'")

sc2reader/scripts/sc2parse.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ def main():
5757

5858
human_pids = {human.pid for human in replay.humans}
5959
event_pids = {
60-
event.player.pid
61-
for event in replay.events
62-
if getattr(event, "player", None)
60+
event.player.pid
61+
for event in replay.events
62+
if getattr(event, "player", None)
6363
}
6464
player_pids = {
6565
player.pid for player in replay.players if player.is_human
6666
}
6767
ability_pids = {
68-
event.player.pid
69-
for event in replay.events
70-
if "CommandEvent" in event.name
68+
event.player.pid
69+
for event in replay.events
70+
if "CommandEvent" in event.name
7171
}
7272
if human_pids != event_pids:
7373
print(
@@ -99,9 +99,7 @@ def main():
9999
)
100100
print(
101101
"Units were: {units}".format(
102-
units={
103-
obj.name for obj in replay.objects.values()
104-
}
102+
units={obj.name for obj in replay.objects.values()}
105103
)
106104
)
107105

0 commit comments

Comments
 (0)