Skip to content

Commit 85644f7

Browse files
committed
refs #75, don't use {} for v2.6 support.
Conflicts: sc2reader/data/__init__.py sc2reader/objects.py
1 parent 905e5c4 commit 85644f7

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

sc2reader/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def __init__(self, unit_id):
245245
self.id = unit_id
246246

247247
def __str__(self):
248-
return "{} [{:X}]".format(self.name, self.id)
248+
return "{0} [{1:X}]".format(self.name, self.id)
249249

250250
def __repr__(self):
251251
return str(self)

sc2reader/events.py

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

115115
def __str__(self):
116-
return self._str_prefix() + "{} at ({}, {})".format(self.name, self.x,self.y)
116+
return self._str_prefix() + "{0} at ({1}, {2})".format(self.name, self.x,self.y)
117117

118118
class PlayerActionEvent(GameEvent):
119119
name = 'PlayerActionEvent'
@@ -132,7 +132,7 @@ def __init__(self, frames, pid, event_type, target, minerals, vespene, terrazine
132132
self.custom = custom
133133

134134
def __str__(self):
135-
return self._str_prefix() + " transfer {} minerals, {} gas, {} terrazine, and {} custom to {}" % (self.minerals, self.vespene, self.terrazine, self.custom, self.reciever)
135+
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)
136136

137137
def load_context(self, replay):
138138
super(SendResourceEvent, self).load_context(replay)
@@ -151,7 +151,7 @@ def __init__(self, frames, pid, event_type, minerals, vespene, terrazine, custom
151151
self.custom = custom
152152

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

156156
@loggable
157157
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def __init__(self, pid, name):
185185
def __repr__(self):
186186
return str(self)
187187
def __str__(self):
188-
return "Player {} - {}".format(self.pid, self.name)
188+
return "Player {0} - {1}".format(self.pid, self.name)
189189

190190
class Player(Person):
191191
"""
@@ -301,14 +301,14 @@ def __init__(self, pid):
301301

302302
def __str__(self):
303303
if not self.is_ai:
304-
return '{} - {} - {}/{}/'.format(self.teamid, self.race, self.subregion, self.bnetid)
304+
return '{0} - {1} - {2}/{3}/'.format(self.teamid, self.race, self.subregion, self.bnetid)
305305
else:
306-
return '{} - {} - AI'.format(self.teamid, self.race)
306+
return '{0} - {1} - AI'.format(self.teamid, self.race)
307307

308308
def get_stats(self):
309309
s = ''
310310
for k in self.stats:
311-
s += '{}: {}\n'.format(self.stats_pretty_names[k], self.stats[k])
311+
s += '{0}: {1}\n'.format(self.stats_pretty_names[k], self.stats[k])
312312
return s.strip()
313313

314314
# 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
@@ -138,7 +138,7 @@ def SelectionTracker(replay):
138138
if error:
139139
person.selection_errors += 1
140140
if debug:
141-
logger.warn("Error detected in deselection mode {}.".format(event.deselect[0]))
141+
logger.warn("Error detected in deselection mode {0}.".format(event.deselect[0]))
142142

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

sc2reader/readers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,16 @@ def __call__(self, data, replay):
270270

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

275275
byte_align()
276276
event_start = tell()
277277

278278
return game_events
279279
except ParseError as e:
280-
raise ReadError("Parse error '{}' unknown at position {}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
280+
raise ReadError("Parse error '{0}' unknown at position {1}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
281281
except EOFError as e:
282-
raise ReadError("EOFError error '{}' unknown at position {}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
282+
raise ReadError("EOFError error '{0}' unknown at position {1}.".format(e.msg, hex(event_start)), event_type, event_start, replay, game_events, data)
283283

284284

285285

@@ -333,7 +333,7 @@ def player_hotkey_event(self, data, fstamp, pid, event_type):
333333
elif action == 2:
334334
return GetFromHotkeyEvent(fstamp, pid, event_type, hotkey, overlay)
335335
else:
336-
raise ParseError("Hotkey Action '{}' unknown".format(hotkey))
336+
raise ParseError("Hotkey Action '{0}' unknown".format(hotkey))
337337

338338
def player_send_resource_event(self, data, fstamp, pid, event_type):
339339
target = data.read_bits(4)
@@ -519,4 +519,4 @@ def player_selection_event(self, data, fstamp, pid, event_type):
519519

520520
unit_types = chain(*[[utype]*count for (utype, count) in unit_types])
521521
units = list(zip(unit_ids, unit_types))
522-
return SelectionEvent(fstamp, pid, event_type, bank, units, overlay)
522+
return SelectionEvent(fstamp, pid, event_type, bank, units, overlay)

sc2reader/resources.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def load_details(self):
297297
elif details.os == 1:
298298
self.os = "Mac"
299299
else:
300-
raise ValueError("Unknown operating system {} detected.".format(details.os))
300+
raise ValueError("Unknown operating system {0} detected.".format(details.os))
301301

302302
self.windows_timestamp = details.file_time
303303
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
@@ -375,7 +375,7 @@ def load_players(self):
375375
player.team = self.team[team_number]
376376

377377
# Do basic win/loss processing from details data
378-
if pdata.result == 1:
378+
if pdata.result == 1:
379379
player.team.result = "Win"
380380
self.winner = player.team
381381
elif pdata.result == 2:
@@ -450,7 +450,7 @@ def load_players(self):
450450
self.recorder.recorder = True
451451
else:
452452
self.recorder = None
453-
self.logger.error("{} possible recorders remain: {}".format(len(recorders), recorders))
453+
self.logger.error("{0} possible recorders remain: {1}".format(len(recorders), recorders))
454454

455455
player_names = sorted(map(lambda p: p.name, self.people))
456456
hash_input = self.gateway+":"+','.join(player_names)
@@ -551,7 +551,7 @@ def _get_reader(self, data_file):
551551
if callback(self):
552552
return reader
553553
else:
554-
raise ValueError("Valid {} reader could not found for build {}".format(data_file, self.build))
554+
raise ValueError("Valid {0} reader could not found for build {1}".format(data_file, self.build))
555555

556556
def _get_datapack(self):
557557
for callback, datapack in self.registered_datapacks:
@@ -947,7 +947,7 @@ def load_player_builds(self):
947947
build_index=command[1] >> 16
948948
))
949949
else:
950-
self.logger.warn("Unknown item in build order, key = {}".format(translation_key))
950+
self.logger.warn("Unknown item in build order, key = {0}".format(translation_key))
951951

952952
# Once we've compiled all the build commands we need to make
953953
# sure they are properly sorted for presentation.
@@ -1021,7 +1021,7 @@ def load_players(self):
10211021
self.player[player.pid] = player
10221022

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

10271027

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
@@ -103,7 +103,7 @@ def read_byte(self):
103103

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

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

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

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

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

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

194194
if self.bit_shift==0:
195195
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)