detect worlds in cwd, and print detected world paths
This commit is contained in:
@@ -428,9 +428,9 @@ def list_worlds():
|
|||||||
# get max length of world name
|
# get max length of world name
|
||||||
worldNameLen = max([len(str(x)) for x in worlds] + [len("World")])
|
worldNameLen = max([len(str(x)) for x in worlds] + [len("World")])
|
||||||
|
|
||||||
formatString = "%-" + str(worldNameLen) + "s | %-8s | %-8s | %-16s "
|
formatString = "%-" + str(worldNameLen) + "s | %-8s | %-8s | %-16s | %s "
|
||||||
print formatString % ("World", "Size", "Playtime", "Modified")
|
print formatString % ("World", "Size", "Playtime", "Modified", "Path")
|
||||||
print formatString % ("-"*worldNameLen, "-"*8, "-"*8, '-'*16)
|
print formatString % ("-"*worldNameLen, "-"*8, "-"*8, '-'*16, '-'*4)
|
||||||
for name, info in sorted(worlds.iteritems()):
|
for name, info in sorted(worlds.iteritems()):
|
||||||
if isinstance(name, basestring) and name.startswith("World") and len(name) == 6:
|
if isinstance(name, basestring) and name.startswith("World") and len(name) == 6:
|
||||||
try:
|
try:
|
||||||
@@ -445,7 +445,8 @@ def list_worlds():
|
|||||||
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 formatString % (name, size, playstamp, timestamp)
|
path = info['path']
|
||||||
|
print formatString % (name, size, playstamp, timestamp, path)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
multiprocessing.freeze_support()
|
multiprocessing.freeze_support()
|
||||||
|
|||||||
@@ -575,9 +575,7 @@ def get_worlds():
|
|||||||
save_dir = get_save_dir()
|
save_dir = get_save_dir()
|
||||||
|
|
||||||
# No dirs found - most likely not running from inside minecraft-dir
|
# No dirs found - most likely not running from inside minecraft-dir
|
||||||
if save_dir is None:
|
if not save_dir is None:
|
||||||
return None
|
|
||||||
|
|
||||||
for dir in os.listdir(save_dir):
|
for dir in os.listdir(save_dir):
|
||||||
world_dat = os.path.join(save_dir, dir, "level.dat")
|
world_dat = os.path.join(save_dir, dir, "level.dat")
|
||||||
if not os.path.exists(world_dat): continue
|
if not os.path.exists(world_dat): continue
|
||||||
@@ -592,4 +590,12 @@ def get_worlds():
|
|||||||
if 'LevelName' in info['Data'].keys():
|
if 'LevelName' in info['Data'].keys():
|
||||||
ret[info['Data']['LevelName']] = info['Data']
|
ret[info['Data']['LevelName']] = info['Data']
|
||||||
|
|
||||||
|
for dir in os.listdir("."):
|
||||||
|
world_dat = os.path.join(dir, "level.dat")
|
||||||
|
if not os.path.exists(world_dat): continue
|
||||||
|
info = nbt.load(world_dat)[1]
|
||||||
|
info['Data']['path'] = os.path.join(".", dir)
|
||||||
|
if 'LevelName' in info['Data'].keys():
|
||||||
|
ret[info['Data']['LevelName']] = info['Data']
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|||||||
Reference in New Issue
Block a user