Skip to content

Commit aa038b7

Browse files
committed
Merge branch 'master' of git://github.com/alexhanh/sc2reader into alexhanh
2 parents 56b4542 + 090fe46 commit aa038b7

File tree

8 files changed

+448
-416
lines changed

8 files changed

+448
-416
lines changed

sc2reader/eventparsers.py

Lines changed: 194 additions & 194 deletions
Large diffs are not rendered by default.

sc2reader/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class ParseError(Exception):
2-
def __init__(self,message,replay,event,bytes):
2+
def __init__(self, message, replay, event, bytes):
33
self.message = message
44
self.replay = replay
55
self.event = event

sc2reader/objects.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
class Attribute(object):
22

3-
def __init__(self,data):
3+
def __init__(self, data):
44
#Unpack the data values and add a default name of unknown to be
55
#overridden by known attributes; acts as a flag for exclusion
6-
self.header,self.id,self.player,self.value,self.name = tuple(data+["Unknown"])
6+
self.header, self.id, self.player, self.value, self.name = tuple(data+["Unknown"])
77

88
#Clean the value of leading null bytes and decode it for easier and more
99
#readable comparisons in the decoding logic to follow
@@ -66,7 +66,7 @@ def __init__(self,data):
6666
elif self.id == 0x07D3:
6767
self.name = "Teams2v2"
6868
#Get the raw team number
69-
self.value = int(self.value[1:],16)
69+
self.value = int(self.value[1:], 16)
7070

7171
elif self.id == 0x07D4:
7272
self.name = "Teams3v3"
@@ -83,54 +83,54 @@ def __init__(self,data):
8383
#Get the raw team number
8484
self.value = int(self.value[1:])
8585

86-
#print "%s (%s) - %s - %s" % (self.name,self.id,self.player,self.value)
86+
#print "%s (%s) - %s - %s" % (self.name, self.id, self.player, self.value)
8787

8888
def __repr__(self):
8989
return str(self)
9090

9191
def __str__(self):
92-
return "%s: %s" % (self.name,self.value)
92+
return "%s: %s" % (self.name, self.value)
9393

9494

9595

9696

9797
class Event(object):
98-
def __init__(self,elapsedTime,eventType,eventCode,globalFlag,playerId,
99-
location=None,bytes=""):
100-
self.time,seconds = (elapsedTime,elapsedTime/16)
101-
self.timestr = "%s:%s" % (seconds/60,str(seconds%60).rjust(2,"0"))
102-
self.type = eventType
103-
self.code = eventCode
104-
self.local = (globalFlag == 0x0)
105-
self.player = playerId
98+
def __init__(self, elapsed_time, event_type, event_code, global_flag, player_id,
99+
location=None, bytes=""):
100+
self.time, seconds = (elapsed_time, elapsed_time/16)
101+
self.timestr = "%s:%s" % (seconds/60, str(seconds%60).rjust(2, "0"))
102+
self.type = event_type
103+
self.code = event_code
104+
self.local = (global_flag == 0x0)
105+
self.player = player_id
106106
self.location = location
107107
self.bytes = bytes
108108

109-
def __call__(self,elapsedTime,eventType,globalFlag,playerId,eventCode,bytes):
110-
self.time,seconds = (elapsedTime,elapsedTime/16)
111-
self.timestr = "%s:%s" % (seconds/60,str(seconds%60).rjust(2,"0"))
112-
self.type = eventType
113-
self.code = eventCode
114-
self.local = (globalFlag == 0x0)
115-
self.player = playerId
109+
def __call__(self, elapsed_time, event_type, global_flag, player_id, event_code, bytes):
110+
self.time, seconds = (elapsed_time, elapsed_time/16)
111+
self.timestr = "%s:%s" % (seconds/60, str(seconds%60).rjust(2, "0"))
112+
self.type = event_type
113+
self.code = event_code
114+
self.local = (global_flag == 0x0)
115+
self.player = player_id
116116
self.bytes = ""
117117
self.parse(bytes)
118118
return self
119119

120120
def __str__(self):
121-
return "%s - %s" % (self.timestr,self.name)
121+
return "%s - %s" % (self.timestr, self.name)
122122

123123
def __repr__(self):
124124
return str(self)
125125

126126
class Message(object):
127127

128-
def __init__(self,time,player,target,text):
129-
self.time,self.player,self.target,self.text = time,player,target,text
128+
def __init__(self, time, player, target, text):
129+
self.time, self.player, self.target, self.text = time, player, target, text
130130

131131
def __str__(self):
132-
time = ((self.time/16)/60,(self.time/16)%60)
133-
return "%s - Player %s - %s" % (time,self.player,self.text)
132+
time = ((self.time/16)/60, (self.time/16)%60)
133+
return "%s - Player %s - %s" % (time, self.player, self.text)
134134

135135
def __repr__(self):
136136
return str(self)
@@ -139,24 +139,24 @@ def __repr__(self):
139139

140140
class Player(object):
141141

142-
def __init__(self,pid, data):
142+
def __init__(self, pid, data):
143143
self.pid = pid
144144
self.name = data[0].decode("hex")
145145
self.uid = data[1][4]
146146
self.uidIndex = data[1][2]
147-
self.url = "http://us.battle.net/sc2/en/profile/%s/%s/%s/" % (self.uid,self.uidIndex,self.name)
147+
self.url = "http://us.battle.net/sc2/en/profile/%s/%s/%s/" % (self.uid, self.uidIndex, self.name)
148148
self.race = data[2].decode("hex")
149149
self.rgba = dict([
150-
['r',data[3][1]],
151-
['g',data[3][2]],
152-
['b',data[3][3]],
153-
['a',data[3][0]],
150+
['r', data[3][1]],
151+
['g', data[3][2]],
152+
['b', data[3][3]],
153+
['a', data[3][0]],
154154
])
155155
self.recorder = True
156156
self.handicap = data[6]
157157

158158
def __str__(self):
159-
return "Player %s - %s (%s)" % (self.pid,self.name,self.race)
159+
return "Player %s - %s (%s)" % (self.pid, self.name, self.race)
160160

161161
def __repr__(self):
162162
return str(self)

0 commit comments

Comments
 (0)