contrib: delete scripts that are no longer useful
dtt-c has been a thing for 8 years now, I think it's safe to say people have deleted their old caches in the meantime. findSigns has also been superseded by genPOI ever since genPOI has been a thing, which has probably been since anvil.
This commit is contained in:
@@ -1,97 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
"""Deletes files from the old chunk-based cache"""
|
|
||||||
|
|
||||||
|
|
||||||
usage = "python contrib/%prog [OPTIONS] <World # / Name / Path to World>"
|
|
||||||
|
|
||||||
description = """
|
|
||||||
This script will delete files from the old chunk-based cache, a lot
|
|
||||||
like the old `overviewer.py -d World/` command. You should only use this if
|
|
||||||
you're updating from an older version of Overviewer, and you want to
|
|
||||||
clean up your world folder.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from optparse import OptionParser
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
# incantation to be able to import overviewer_core
|
|
||||||
if not hasattr(sys, "frozen"):
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0], '..')))
|
|
||||||
|
|
||||||
from overviewer_core import world
|
|
||||||
from overviewer import list_worlds
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = OptionParser(usage=usage, description=description)
|
|
||||||
parser.add_option("-d", "--dry-run", dest="dry", action="store_true",
|
|
||||||
help="Don't actually delete anything. Best used with -v.")
|
|
||||||
parser.add_option("-k", "--keep-dirs", dest="keep", action="store_true",
|
|
||||||
help="Keep the world directories intact, even if they are empty.")
|
|
||||||
parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
|
|
||||||
help="Log each and every file that is deleted.")
|
|
||||||
|
|
||||||
opt, args = parser.parse_args()
|
|
||||||
|
|
||||||
if not len(args) == 1:
|
|
||||||
parser.print_help()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
worlddir = args[0]
|
|
||||||
|
|
||||||
if not os.path.exists(worlddir):
|
|
||||||
# world given is either world number, or name
|
|
||||||
worlds = world.get_worlds()
|
|
||||||
|
|
||||||
# if there are no worlds found at all, exit now
|
|
||||||
if not worlds:
|
|
||||||
parser.print_help()
|
|
||||||
print "\nInvalid world path"
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
try:
|
|
||||||
worldnum = int(worlddir)
|
|
||||||
worlddir = worlds[worldnum]['path']
|
|
||||||
except ValueError:
|
|
||||||
# it wasn't a number or path, try using it as a name
|
|
||||||
try:
|
|
||||||
worlddir = worlds[worlddir]['path']
|
|
||||||
except KeyError:
|
|
||||||
# it's not a number, name, or path
|
|
||||||
parser.print_help()
|
|
||||||
print "Invalid world name or path"
|
|
||||||
sys.exit(1)
|
|
||||||
except KeyError:
|
|
||||||
# it was an invalid number
|
|
||||||
parser.print_help()
|
|
||||||
print "Invalid world number"
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
files_deleted = 0
|
|
||||||
dirs_deleted = 0
|
|
||||||
|
|
||||||
imgre = re.compile(r'img\.[^.]+\.[^.]+\.nocave\.\w+\.png$')
|
|
||||||
for dirpath, dirnames, filenames in os.walk(worlddir, topdown=False):
|
|
||||||
for f in filenames:
|
|
||||||
if imgre.match(f):
|
|
||||||
filepath = os.path.join(dirpath, f)
|
|
||||||
if opt.verbose:
|
|
||||||
print "Deleting %s" % (filepath,)
|
|
||||||
if not opt.dry:
|
|
||||||
os.unlink(filepath)
|
|
||||||
files_deleted += 1
|
|
||||||
|
|
||||||
if not opt.keep:
|
|
||||||
if len(os.listdir(dirpath)) == 0:
|
|
||||||
if opt.verbose:
|
|
||||||
print "Deleting %s" % (dirpath,)
|
|
||||||
if not opt.dry:
|
|
||||||
os.rmdir(dirpath)
|
|
||||||
dirs_deleted += 1
|
|
||||||
|
|
||||||
print "%i files and %i directories deleted." % (files_deleted, dirs_deleted)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
|
|
||||||
'''
|
|
||||||
Updates overviewer.dat file sign info
|
|
||||||
|
|
||||||
This script will scan through every chunk looking for signs and write out an
|
|
||||||
updated overviewer.dat file. This can be useful if your overviewer.dat file
|
|
||||||
is either out-of-date or non-existant.
|
|
||||||
|
|
||||||
To run, simply give a path to your world directory and the path to your
|
|
||||||
output directory. For example:
|
|
||||||
|
|
||||||
python contrib/findSigns.py ../world.test/ output_dir/
|
|
||||||
|
|
||||||
An optional north direction may be specified as follows:
|
|
||||||
|
|
||||||
python contrib/findSigns.py ../world.test/ output_dir/ lower-right
|
|
||||||
|
|
||||||
Valid options are upper-left, upper-right, lower-left and lower-right.
|
|
||||||
If no direction is specified, lower-left is assumed
|
|
||||||
|
|
||||||
Once that is done, simply re-run the overviewer to generate markers.js:
|
|
||||||
|
|
||||||
python overviewer.py ../world.test/ output_dir/
|
|
||||||
|
|
||||||
'''
|
|
||||||
import sys
|
|
||||||
import re
|
|
||||||
import os
|
|
||||||
import cPickle
|
|
||||||
|
|
||||||
# incantation to be able to import overviewer_core
|
|
||||||
if not hasattr(sys, "frozen"):
|
|
||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.split(__file__)[0], '..')))
|
|
||||||
|
|
||||||
from overviewer_core import nbt
|
|
||||||
|
|
||||||
from pprint import pprint
|
|
||||||
if len(sys.argv) < 3:
|
|
||||||
sys.exit("Usage: %s <worlddir> <outputdir> [north_direction]" % sys.argv[0])
|
|
||||||
|
|
||||||
worlddir = sys.argv[1]
|
|
||||||
outputdir = sys.argv[2]
|
|
||||||
|
|
||||||
directions=["upper-left","upper-right","lower-left","lower-right"]
|
|
||||||
if len(sys.argv) < 4:
|
|
||||||
print "No north direction specified - assuming lower-left"
|
|
||||||
north_direction="lower-left"
|
|
||||||
else:
|
|
||||||
north_direction=sys.argv[3]
|
|
||||||
|
|
||||||
if (north_direction not in directions):
|
|
||||||
print north_direction, " is not a valid direction"
|
|
||||||
sys.exit("Bad north-direction")
|
|
||||||
|
|
||||||
if os.path.exists(worlddir):
|
|
||||||
print "Scanning chunks in ", worlddir
|
|
||||||
else:
|
|
||||||
sys.exit("Bad WorldDir")
|
|
||||||
|
|
||||||
if os.path.exists(outputdir):
|
|
||||||
print "Output directory is ", outputdir
|
|
||||||
else:
|
|
||||||
sys.exit("Bad OutputDir")
|
|
||||||
|
|
||||||
matcher = re.compile(r"^r\..*\.mcr$")
|
|
||||||
|
|
||||||
POI = []
|
|
||||||
|
|
||||||
for dirpath, dirnames, filenames in os.walk(worlddir):
|
|
||||||
for f in filenames:
|
|
||||||
if matcher.match(f):
|
|
||||||
print f
|
|
||||||
full = os.path.join(dirpath, f)
|
|
||||||
# force lower-left so chunks are loaded in correct positions
|
|
||||||
r = nbt.load_region(full, 'lower-left')
|
|
||||||
chunks = r.get_chunks()
|
|
||||||
for x,y in chunks:
|
|
||||||
chunk = r.load_chunk(x,y).read_all()
|
|
||||||
data = chunk[1]['Level']['TileEntities']
|
|
||||||
for entity in data:
|
|
||||||
if entity['id'] == 'Sign':
|
|
||||||
msg=' \n'.join([entity['Text1'], entity['Text2'], entity['Text3'], entity['Text4']])
|
|
||||||
#print "checking -->%s<--" % msg.strip()
|
|
||||||
if msg.strip():
|
|
||||||
newPOI = dict(type="sign",
|
|
||||||
x= entity['x'],
|
|
||||||
y= entity['y'],
|
|
||||||
z= entity['z'],
|
|
||||||
msg=msg,
|
|
||||||
chunk= (entity['x']/16, entity['z']/16),
|
|
||||||
)
|
|
||||||
POI.append(newPOI)
|
|
||||||
print "Found sign at (%d, %d, %d): %r" % (newPOI['x'], newPOI['y'], newPOI['z'], newPOI['msg'])
|
|
||||||
|
|
||||||
|
|
||||||
if os.path.isfile(os.path.join(worlddir, "overviewer.dat")):
|
|
||||||
print "Overviewer.dat detected in WorldDir - this is no longer the correct location\n"
|
|
||||||
print "You may wish to delete the old file. A new overviewer.dat will be created\n"
|
|
||||||
print "Old file: ", os.path.join(worlddir, "overviewer.dat")
|
|
||||||
|
|
||||||
pickleFile = os.path.join(outputdir,"overviewer.dat")
|
|
||||||
with open(pickleFile,"wb") as f:
|
|
||||||
cPickle.dump(dict(POI=POI,north_direction=north_direction), f)
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user