Skip to content

Commit 28a1d16

Browse files
committed
refs #75, don't use {} for v2.6 support.
1 parent cd59fb1 commit 28a1d16

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

sc2reader/data/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def __init__(self, unit_id, flags):
273273
self._cmp_val = (self.id << 16) | self.type
274274

275275
def __str__(self):
276-
return "{} [{:X}]".format(self.name, self.id)
276+
return "{0} [{1:X}]".format(self.name, self.id)
277277

278278
def __cmp__(self, other):
279279
if self._cmp_val == other._cmp_val:
@@ -293,8 +293,8 @@ class Ability(object):
293293
pass
294294

295295
def load_build(expansion, version):
296-
unit_file = '{}/{}_units.csv'.format(expansion,version)
297-
abil_file = '{}/{}_abilities.csv'.format(expansion,version)
296+
unit_file = '{0}/{1}_units.csv'.format(expansion,version)
297+
abil_file = '{0}/{1}_abilities.csv'.format(expansion,version)
298298

299299
units = dict()
300300
for entry in pkgutil.get_data('sc2reader.data', unit_file).split('\n'):

sc2reader/events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self, frames, pid, event_type, x, y, distance, pitch, yaw, height_o
128128
self.height_offset = height_offset
129129

130130
def __str__(self):
131-
return self._str_prefix() + "{} at ({}, {})".format(self.name, self.x,self.y)
131+
return self._str_prefix() + "{0} at ({1}, {2})".format(self.name, self.x,self.y)
132132

133133
class PlayerActionEvent(GameEvent):
134134
name = 'PlayerActionEvent'
@@ -147,7 +147,7 @@ def __init__(self, frames, pid, event_type, target, minerals, vespene, terrazine
147147
self.custom = custom
148148

149149
def __str__(self):
150-
return self._str_prefix() + " transfer {} minerals, {} gas, {} terrazine, and {} custom to {}" % (self.minerals, self.vespene, self.terrazine, self.custom, self.reciever)
150+
return self._str_prefix() + " transfer {0} minerals, {1} gas, {2} terrazine, and {3} custom to {4}" % (self.minerals, self.vespene, self.terrazine, self.custom, self.reciever)
151151

152152
def load_context(self, replay):
153153
super(SendResourceEvent, self).load_context(replay)
@@ -166,7 +166,7 @@ def __init__(self, frames, pid, event_type, minerals, vespene, terrazine, custom
166166
self.custom = custom
167167

168168
def __str__(self):
169-
return self._str_prefix() + " requests {} minerals, {} gas, {} terrazine, and {} custom" % (self.minerals, self.vespene, self.terrazine, self.custom)
169+
return self._str_prefix() + " requests {0} minerals, {1} gas, {2} terrazine, and {3} custom" % (self.minerals, self.vespene, self.terrazine, self.custom)
170170

171171
@loggable
172172
class AbilityEvent(PlayerActionEvent):

sc2reader/factories.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ def __init__(self, cache_dir, **options):
254254
super(FileCachedSC2Factory, self).__init__(**options)
255255
self.cache_dir = os.path.abspath(cache_dir)
256256
if not os.path.isdir(self.cache_dir):
257-
raise ValueError("cache_dir ({}) must be an existing directory.".format(self.cache_dir))
257+
raise ValueError("cache_dir ({0}) must be an existing directory.".format(self.cache_dir))
258258
elif not os.access(self.cache_dir, os.F_OK | os.W_OK | os.R_OK ):
259-
raise ValueError("Must have read/write access to {} for local file caching.".format(self.cache_dir))
259+
raise ValueError("Must have read/write access to {0} for local file caching.".format(self.cache_dir))
260260

261261
def cache_has(self, cache_key):
262262
return os.path.exists(self.cache_path(cache_key))

sc2reader/objects.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def __init__(self, pid, name):
163163
def __repr__(self):
164164
return str(self)
165165
def __str__(self):
166-
return "Player {} - {}".format(self.pid, self.name)
166+
return "Player {0} - {1}".format(self.pid, self.name)
167167

168168
class Player(Person):
169169
"""
@@ -279,17 +279,17 @@ def __init__(self, pid):
279279

280280
def __str__(self):
281281
if not self.is_ai:
282-
return '{} - {} - {}/{}/'.format(self.teamid, self.race, self.subregion, self.bnetid)
282+
return '{0} - {1} - {2}/{3}/'.format(self.teamid, self.race, self.subregion, self.bnetid)
283283
else:
284-
return '{} - {} - AI'.format(self.teamid, self.race)
284+
return '{0} - {1} - AI'.format(self.teamid, self.race)
285285

286286
def __repr__(self):
287287
return str(self)
288-
288+
289289
def get_stats(self):
290290
s = ''
291291
for k in self.stats:
292-
s += '{}: {}\n'.format(self.stats_pretty_names[k], self.stats[k])
292+
s += '{0}: {1}\n'.format(self.stats_pretty_names[k], self.stats[k])
293293
return s.strip()
294294

295295
# TODO: Are there libraries with classes like this in them

sc2reader/plugins/replay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def SelectionTracker(replay):
139139
if error:
140140
person.selection_errors += 1
141141
if debug:
142-
logger.warn("Error detected in deselection mode {}.".format(event.deselect[0]))
142+
logger.warn("Error detected in deselection mode {0}.".format(event.deselect[0]))
143143

144144
person.selection = player_selection
145145
# Not a real lock, so don't change it!

sc2reader/readers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,16 +273,16 @@ def __call__(self, data, replay):
273273

274274
# Otherwise throw a read error
275275
else:
276-
raise ReadError("Event type {} unknown at position {}.".format(hex(event_type),hex(event_start)), event_type, event_start, replay, game_events, data)
276+
raise ReadError("Event type {0} unknown at position {1}.".format(hex(event_type),hex(event_start)), event_type, event_start, replay, game_events, data)
277277

278278
byte_align()
279279
event_start = tell()
280280

281281
return game_events
282282
except ParseError as e:
283-
raise ReadError("Parse error '{}' unknown at position {}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
283+
raise ReadError("Parse error '{0}' unknown at position {1}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
284284
except EOFError as e:
285-
raise ReadError("EOFError error '{}' unknown at position {}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
285+
raise ReadError("EOFError error '{0}' unknown at position {1}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
286286

287287

288288

@@ -341,7 +341,7 @@ def player_hotkey_event(self, data, fstamp, pid, event_type):
341341
elif action == 2:
342342
return GetFromHotkeyEvent(fstamp, pid, event_type, hotkey, overlay)
343343
else:
344-
raise ParseError("Hotkey Action '{}' unknown".format(hotkey))
344+
raise ParseError("Hotkey Action '{0}' unknown".format(hotkey))
345345

346346
def player_send_resource_event(self, data, fstamp, pid, event_type):
347347
target = data.read_bits(4)

sc2reader/resources.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def load_details(self):
303303
elif details.os == 1:
304304
self.os = "Mac"
305305
else:
306-
raise ValueError("Unknown operating system {} detected.".format(details.os))
306+
raise ValueError("Unknown operating system {0} detected.".format(details.os))
307307

308308
self.windows_timestamp = details.file_time
309309
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
@@ -381,7 +381,7 @@ def load_players(self):
381381
player.team = self.team[team_number]
382382

383383
# Do basic win/loss processing from details data
384-
if pdata.result == 1:
384+
if pdata.result == 1:
385385
player.team.result = "Win"
386386
self.winner = player.team
387387
elif pdata.result == 2:
@@ -456,7 +456,7 @@ def load_players(self):
456456
self.recorder.recorder = True
457457
else:
458458
self.recorder = None
459-
self.logger.error("{} possible recorders remain: {}".format(len(recorders), recorders))
459+
self.logger.error("{0} possible recorders remain: {1}".format(len(recorders), recorders))
460460

461461
player_names = sorted(map(lambda p: p.name, self.people))
462462
hash_input = self.gateway+":"+','.join(player_names)
@@ -584,7 +584,7 @@ def _get_reader(self, data_file):
584584
if callback(self):
585585
return reader
586586
else:
587-
raise ValueError("Valid {} reader could not found for build {}".format(data_file, self.build))
587+
raise ValueError("Valid {0} reader could not found for build {1}".format(data_file, self.build))
588588

589589
def _get_datapack(self):
590590
for callback, datapack in self.registered_datapacks:
@@ -980,7 +980,7 @@ def load_player_builds(self):
980980
build_index=command[1] >> 16
981981
))
982982
else:
983-
self.logger.warn("Unknown item in build order, key = {}".format(translation_key))
983+
self.logger.warn("Unknown item in build order, key = {0}".format(translation_key))
984984

985985
# Once we've compiled all the build commands we need to make
986986
# sure they are properly sorted for presentation.
@@ -1054,7 +1054,7 @@ def load_players(self):
10541054
self.player[player.pid] = player
10551055

10561056
def __str__(self):
1057-
return "{} - {} {}".format(self.start_time,self.game_length,
1057+
return "{0} - {1} {2}".format(self.start_time,self.game_length,
10581058
'v'.join(''.join(self.players[p].race[0] for p in self.teams[tid]) for tid in self.teams))
10591059

10601060

sc2reader/scripts/sc2boprinter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def main():
1414
args = parser.parse_args()
1515
for r in sc2reader.load_game_summaries(args.path):
1616
print("\n"+"-"*40+"\n")
17-
print("= {} =".format(r))
17+
print("= {0} =".format(r))
1818
for p in r.players:
19-
print("== {} - {} ==".format(p.race, p.bnetid if not p.is_ai else "AI"))
19+
print("== {0} - {1} ==".format(p.race, p.bnetid if not p.is_ai else "AI"))
2020
for order in r.build_orders[p.pid]:
21-
print("{:0>2}:{:0>2} {:<35} {:>2}/{}".format(order['time'] / 60,
21+
print("{0:0>2}:{1:0>2} {2:<35} {3:>2}/{4}".format(order['time'] / 60,
2222
order['time'] % 60,
2323
order['order']['name'],
2424
order['supply'],

sc2reader/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def read_byte(self):
102102

103103
def read_short(self, endian=LITTLE_ENDIAN):
104104
#if self.bytes_left() < 2:
105-
# raise EOFError("Cannot read short; only {} bytes left in buffer".format(self.left))
105+
# raise EOFError("Cannot read short; only {0} bytes left in buffer".format(self.left))
106106

107107
if self.bit_shift == 0:
108108
return struct.unpack(endian+'H', self.read(2))[0]
@@ -119,7 +119,7 @@ def read_short(self, endian=LITTLE_ENDIAN):
119119

120120
def read_int(self, endian=LITTLE_ENDIAN):
121121
#if self.bytes_left() < 4:
122-
# raise EOFError("Cannot read int; only {} bytes left in buffer".format(self.left))
122+
# raise EOFError("Cannot read int; only {0} bytes left in buffer".format(self.left))
123123

124124
if self.bit_shift == 0:
125125
return struct.unpack(endian+'I', self.read(4))[0]
@@ -136,7 +136,7 @@ def read_int(self, endian=LITTLE_ENDIAN):
136136

137137
def read_bits(self, bits):
138138
#if self.bytes_left()*8 < bits-(8-self.bit_shift):
139-
# raise EOFError("Cannot read {} bits. only {} bits left in buffer.".format(bits, (self.length-self.tell()+1)*8-self.bit_shift))
139+
# raise EOFError("Cannot read {0} bits. only {1} bits left in buffer.".format(bits, (self.length-self.tell()+1)*8-self.bit_shift))
140140
bit_shift = self.bit_shift
141141
if bit_shift!=0:
142142
bits_left = 8-bit_shift
@@ -188,7 +188,7 @@ def read_bits(self, bits):
188188

189189
def read_bytes(self, bytes):
190190
#if self.bytes_left() < bytes:
191-
# raise EOFError("Cannot read {} bytes. only {} bytes left in buffer.".format(bytes, self.length-self.tell()))
191+
# raise EOFError("Cannot read {0} bytes. only {1} bytes left in buffer.".format(bytes, self.length-self.tell()))
192192

193193
if self.bit_shift==0:
194194
return self.read(bytes)
@@ -470,7 +470,7 @@ def extract_data_file(data_file, archive):
470470

471471
except Exception as e:
472472
trace = sys.exc_info()[2]
473-
raise exceptions.MPQError("Unable to extract file: {}".format(data_file),e), None, trace
473+
raise exceptions.MPQError("Unable to extract file: {0}".format(data_file),e), None, trace
474474

475475
def read_header(replay_file):
476476
# Extract useful header information from the MPQ files. This information
@@ -481,7 +481,7 @@ def read_header(replay_file):
481481

482482
# Sanity check that the input is in fact an MPQ file
483483
if data.length==0 or data.read(4) != "MPQ\x1b":
484-
msg = "File '{}' is not an MPQ file";
484+
msg = "File '{0}' is not an MPQ file";
485485
raise exceptions.FileError(msg.format(getattr(replay_file, 'name', '<NOT AVAILABLE>')))
486486

487487
max_data_size = data.read_int(LITTLE_ENDIAN)

0 commit comments

Comments
 (0)