0

--forcerender, --check-tiles, and --no-tile-checks now work

This commit is contained in:
Andrew Brown
2012-02-16 11:36:31 -05:00
parent 1457bf1564
commit f8769c0a0d
3 changed files with 44 additions and 4 deletions

View File

@@ -269,6 +269,32 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
############################################################
# Final validation steps and creation of the destination directory
# Override some render configdict options depending on one-time command line
# modifiers
if (
bool(options.forcerender) +
bool(options.checktiles) +
bool(options.notilechecks)
) > 1:
logging.error("You cannot specify more than one of --forcerender, "+
"--check-tiles, and --no-tile-checks. These options conflict.")
parser.print_help()
return 1
if options.forcerender:
logging.info("Forcerender mode activated. ALL tiles will be rendered")
for render in config['renders'].itervalues():
render['renderchecks'] = 2
elif options.checktiles:
logging.info("Checking all tiles for updates manually.")
for render in config['renders'].itervalues():
render['renderchecks'] = 1
elif options.notilechecks:
logging.info("Disabling all tile mtime checks. Only rendering tiles "+
"that need updating since last render")
for render in config['renders'].itervalues():
render['renderchecks'] = 0
if not config['renders']:
logging.error("You must specify at least one render in your config file. See the docs if you're having trouble")
return 1

View File

@@ -44,6 +44,18 @@ class MultiWorldParser(object):
def set_config_item(self, itemname, itemvalue):
self._config_state[itemname] = itemvalue
def set_renders_default(self, settingname, newdefault):
"""This method sets the default for one of the settings of the "renders"
dictionary. This is hard-coded to expect a "renders" setting in the
settings definition, and for its validator to be a dictValidator with
its valuevalidator to be a configDictValidator
"""
# If the structure of settingsDefinitions changes, you'll need to change
# this to find the proper place to find the settings dictionary
render_settings = self._settings['renders'].validator.valuevalidator.config
render_settings[settingname].default = newdefault
def parse(self, settings_file):
"""Reads in the named file and parses it, storing the results in an
internal state awating to be validated and returned upon call to

View File

@@ -19,7 +19,7 @@ class Setting(object):
def validateWorldPath(worldpath):
abs_path = os.path.abspath(worldpath)
if not os.path.exists(os.path.join(abs_path, "level.dat")):
raise ValidationException("No level.dat file in %r. Are you sure you have the right path?" % (abs_path,))
raise ValidationException("No level.dat file in '%s'. Are you sure you have the right path?" % (abs_path,))
return abs_path
@@ -53,9 +53,11 @@ def validateNorthDirection(direction):
elif isinstance(direction, str):
direction = direction.lower().replace("-","").replace("_","")
if direction == "upperleft": intdir = UPPER_LEFT
if direction == "upperright": intdir = UPPER_RIGHT
if direction == "lowerright": intdir = LOWER_RIGHT
if direction == "lowerleft": intdir = LOWER_LEFT
elif direction == "upperright": intdir = UPPER_RIGHT
elif direction == "lowerright": intdir = LOWER_RIGHT
elif direction == "lowerleft": intdir = LOWER_LEFT
else:
raise ValidationException("'%s' is not a valid north direction" % direction)
if intdir < 0 or intdir > 3:
raise ValidationException("%r is not a valid north direction" % direction)
return intdir