fixed crash on worlds named "World[not int]", and made world list play nice with world names
This commit is contained in:
12
gmap.py
12
gmap.py
@@ -183,13 +183,21 @@ def list_worlds():
|
|||||||
print 'No world saves found in the usual place'
|
print 'No world saves found in the usual place'
|
||||||
return
|
return
|
||||||
print "Detected saves:"
|
print "Detected saves:"
|
||||||
for num, info in sorted(worlds.iteritems()):
|
for name, info in sorted(worlds.iteritems()):
|
||||||
|
if isinstance(name, basestring) and name.startswith("World") and len(name) == 6:
|
||||||
|
try:
|
||||||
|
world_n = int(name[-1])
|
||||||
|
# we'll catch this one later, when it shows up as an
|
||||||
|
# integer key
|
||||||
|
continue
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
timestamp = time.strftime("%Y-%m-%d %H:%M",
|
timestamp = time.strftime("%Y-%m-%d %H:%M",
|
||||||
time.localtime(info['LastPlayed'] / 1000))
|
time.localtime(info['LastPlayed'] / 1000))
|
||||||
playtime = info['Time'] / 20
|
playtime = info['Time'] / 20
|
||||||
playstamp = '%d:%02d' % (playtime / 3600, playtime / 60 % 60)
|
playstamp = '%d:%02d' % (playtime / 3600, playtime / 60 % 60)
|
||||||
size = "%.2fMB" % (info['SizeOnDisk'] / 1024. / 1024.)
|
size = "%.2fMB" % (info['SizeOnDisk'] / 1024. / 1024.)
|
||||||
print "World %s: %s Playtime: %s Modified: %s" % (num, size, playstamp, timestamp)
|
print "World %s: %s Playtime: %s Modified: %s" % (name, size, playstamp, timestamp)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
7
world.py
7
world.py
@@ -406,8 +406,11 @@ def get_worlds():
|
|||||||
info = nbt.load(world_dat)[1]
|
info = nbt.load(world_dat)[1]
|
||||||
info['Data']['path'] = os.path.join(save_dir, dir)
|
info['Data']['path'] = os.path.join(save_dir, dir)
|
||||||
if dir.startswith("World") and len(dir) == 6:
|
if dir.startswith("World") and len(dir) == 6:
|
||||||
world_n = int(dir[-1])
|
try:
|
||||||
ret[world_n] = info['Data']
|
world_n = int(dir[-1])
|
||||||
|
ret[world_n] = info['Data']
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
if 'LevelName' in info['Data'].keys():
|
if 'LevelName' in info['Data'].keys():
|
||||||
ret[info['Data']['LevelName']] = info['Data']
|
ret[info['Data']['LevelName']] = info['Data']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user