0

Removing more stuff that we will not support just yet

This commit is contained in:
Andrew Chin
2012-01-01 14:31:38 -05:00
parent 0a23187f51
commit c17fb351f0
3 changed files with 65 additions and 84 deletions

View File

@@ -292,12 +292,22 @@ def main():
# parser.advanced_help() # parser.advanced_help()
# doExit(code=0, consoleMsg=False) # doExit(code=0, consoleMsg=False)
if len(args) < 1: # TODO right now, we will not let users specify worlds to render on the command line.
# TODO in the future, we need to also let worlds be specified on the command line
# for multiworld, we must specify the *outputdir* on the command line
if len(args) == 1:
logging.debug("Using %r as the output_directory", args[0])
destdir = os.path.expanduser(args[0])
elif len(args) < 1:
logging.error("You need to give me your world number or directory") logging.error("You need to give me your world number or directory")
parser.print_help() parser.print_help()
list_worlds() list_worlds()
doExit(code=1, consoleMsg=True) doExit(code=1, consoleMsg=True)
worlddir = os.path.expanduser(args[0]) elif len(args) == 2: # TODO support this usecase
worlddir = os.path.expanduser(args[0])
destdir = os.path.expanduser(args[1])
if len(args) > 2: if len(args) > 2:
# it's possible the user has a space in one of their paths but didn't properly escape it # it's possible the user has a space in one of their paths but didn't properly escape it
@@ -310,92 +320,55 @@ def main():
dir but you forgot to put quotes around the directory, since it contains spaces." % " ".join(args[start:end])) dir but you forgot to put quotes around the directory, since it contains spaces." % " ".join(args[start:end]))
doExit(code=1, consoleMsg=False) doExit(code=1, consoleMsg=False)
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()
logging.error("Invalid world path")
doExit(code=1, consoleMsg=False)
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()
logging.error("Invalid world name or path")
doExit(code=1, consoleMsg=False)
except KeyError:
# it was an invalid number
parser.print_help()
logging.error("Invalid world number")
doExit(code=1, consoleMsg=False)
# final sanity check for worlddir
if not os.path.exists(os.path.join(worlddir, 'level.dat')):
logging.error("Invalid world path -- does not contain level.dat")
doExit(code=1, consoleMsg=False)
if len(args) < 2:
logging.error("Where do you want to save the tiles?")
doExit(code=1, consoleMsg=False)
elif len(args) > 2:
parser.print_help()
logging.error("Sorry, you specified too many arguments")
doExit(code=1, consoleMsg=False)
destdir = os.path.expanduser(args[1])
if options.display_config: if options.display_config:
# just display the config file and exit # just display the config file and exit
parser.display_config() parser.display_config()
doExit(code=0, consoleMsg=False) doExit(code=0, consoleMsg=False)
if options.regionlist: # TODO regionlists are per-world
regionlist = map(str.strip, open(options.regionlist, 'r')) #if options.regionlist:
else: # regionlist = map(str.strip, open(options.regionlist, 'r'))
regionlist = None #else:
# regionlist = None
if options.imgformat: # TODO imgformat is per-world
if options.imgformat not in ('jpg','png'): #if options.imgformat:
parser.error("Unknown imgformat!") # if options.imgformat not in ('jpg','png'):
else: # parser.error("Unknown imgformat!")
imgformat = options.imgformat # else:
else: # imgformat = options.imgformat
imgformat = 'png' #else:
# imgformat = 'png'
if options.optimizeimg: # TODO optimzeimg is per-world
optimizeimg = int(options.optimizeimg) #if options.optimizeimg:
optimizeimages.check_programs(optimizeimg) # optimizeimg = int(options.optimizeimg)
else: # optimizeimages.check_programs(optimizeimg)
optimizeimg = None #else:
# optimizeimg = None
if options.north_direction: # TODO north_direction is per-world
north_direction = options.north_direction #if options.north_direction:
else: # north_direction = options.north_direction
north_direction = 'auto' #else:
# north_direction = 'auto'
if options.changelist: # TODO reimplement changelists
try: #if options.changelist:
changefile = open(options.changelist,'w+') # try:
except IOError as e: # changefile = open(options.changelist,'w+')
logging.error("Unable to open file %s to use for changelist." % options.changelist) # except IOError as e:
logging.error("I/O Error: %s" % e.strerror) # logging.error("Unable to open file %s to use for changelist." % options.changelist)
doExit(code=1, consoleMsg=False) # logging.error("I/O Error: %s" % e.strerror)
# doExit(code=1, consoleMsg=False)
if options.changelist_format != "auto" and not options.changelist: #if options.changelist_format != "auto" and not options.changelist:
logging.error("changelist_format specified without changelist.") # logging.error("changelist_format specified without changelist.")
doExit(code=1, consoleMsg=False) # doExit(code=1, consoleMsg=False)
if options.changelist_format == "auto": #if options.changelist_format == "auto":
options.changelist_format = "relative" # options.changelist_format = "relative"
logging.info("Welcome to Minecraft Overviewer!") logging.info("Welcome to Minecraft Overviewer!")
logging.debug("Current log level: {0}".format(logging.getLogger().level)) logging.debug("Current log level: {0}".format(logging.getLogger().level))
@@ -403,7 +376,9 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
# make sure that the textures can be found # make sure that the textures can be found
try: try:
textures.generate(path=options.textures_path) #textures.generate(path=options.textures_path)
# TODO(agrif): your magic goes here
textures.generate(path=None)
except IOError, e: except IOError, e:
logging.error(str(e)) logging.error(str(e))
doExit(code=1, consoleMsg=False) doExit(code=1, consoleMsg=False)

View File

@@ -15,7 +15,7 @@ from settingsValidators import *
render = { render = {
"world_path": dict(required=True, validator=validatePath), "world_path": dict(required=True, validator=validateWorldPath),
"rendermode": dict(required=False, validator=validateRenderMode), "rendermode": dict(required=False, validator=validateRenderMode),
"north-direction": dict(required=False, validator=validateNorthDirection), "north-direction": dict(required=False, validator=validateNorthDirection),
"render-range": dict(required=False, validator=validateRenderRange), "render-range": dict(required=False, validator=validateRenderRange),

View File

@@ -5,12 +5,18 @@ import os.path
class ValidationException(Exception): class ValidationException(Exception):
pass pass
def validatePath(path): def validateWorldPath(path):
if not os.path.exists(path): try:
raise ValidationException("%r does not exist" % path) if not os.path.exists(path):
if not os.path.isdir(path): raise ValidationException("%r does not exist" % path)
raise ValidationException("%r is not a directory" % path) if not os.path.isdir(path):
return os.path.abspath(path) raise ValidationException("%r is not a directory" % path)
except ValidationException, e
# TODO assume this is the name of a world and try
# to find it
raise e
full_path = os.path.abspath(path)
return full_path
def validateRenderMode(mode): def validateRenderMode(mode):
# TODO get list of valid rendermodes # TODO get list of valid rendermodes