0

added rendercheck mode 3, the identity function of rendercheck modes!

This commit is contained in:
Aaron Griffith
2014-05-01 16:48:28 -04:00
parent 7d87d25658
commit 7c23d6e86a
3 changed files with 52 additions and 9 deletions

View File

@@ -704,6 +704,14 @@ values. The valid configuration keys are listed below.
'forcerender': True,
}
``renderchecks``
This is an integer, and functions as a more complex form of
``forcerender``. Setting it to 1 enables :option:`--check-tiles`
mode, setting it to 2 enables :option:`--forcerender`, and 3 tells
Overviewer to keep this particular render in the output, but
otherwise don't update it. It defaults to 0, which is the usual
update checking mode.
``changelist``
This is a string. It names a file where it will write out, one per line, the
path to tiles that have been updated. You can specify the same file for

View File

@@ -318,19 +318,24 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
"--check-tiles, and --no-tile-checks. These options conflict.")
parser.print_help()
return 1
def set_renderchecks(checkname, num):
for name, render in config['renders'].iteritems():
if render.get('renderchecks', 0) == 3:
logging.warning(checkname + " ignoring render " + repr(name) + " since it's marked as \"don't render\".")
else:
render['renderchecks'] = num
if options.forcerender:
logging.info("Forcerender mode activated. ALL tiles will be rendered")
for render in config['renders'].itervalues():
render['renderchecks'] = 2
set_renderchecks("forcerender", 2)
elif options.checktiles:
logging.info("Checking all tiles for updates manually.")
for render in config['renders'].itervalues():
render['renderchecks'] = 1
set_renderchecks("checktiles", 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
set_renderchecks("notilechecks", 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")

View File

@@ -130,6 +130,14 @@ Bounds = namedtuple("Bounds", ("mincol", "maxcol", "minrow", "maxrow"))
# slowest, but SHOULD be specified if this is the first render because
# the scan will forgo tile stat calls. It's also useful for changing
# texture packs or other options that effect the output.
# 3
# A very special mode. Using this will not actually render
# anything, but will leave this tileset in the resulting
# map. Useful for renders that you want to keep, but not
# update. Since this mode is so simple, it's left out of the
# rest of this discussion.
#
# For 0 our caller has explicitly requested not to check mtimes on disk to
# speed things up. So the mode 0 chunk scan only looks at chunk mtimes and the
@@ -238,6 +246,13 @@ class TileSet(object):
useful for changing texture packs or other options that effect
the output.
3
A very special mode. Using this will not actually render
anything, but will leave this tileset in the resulting
map. Useful for renders that you want to keep, but not
update. Since this mode is so simple, it's left out of the
rest of this discussion.
imgformat
A string indicating the output format. Must be one of 'png' or
'jpeg'
@@ -390,6 +405,11 @@ class TileSet(object):
attribute for later use in iterate_work_items()
"""
# skip if we're told to
if self.options['renderchecks'] == 3:
return
# REMEMBER THAT ATTRIBUTES ASSIGNED IN THIS METHOD ARE NOT AVAILABLE IN
# THE do_work() METHOD (because this is only called in the main process
# not the workers)
@@ -416,15 +436,16 @@ class TileSet(object):
return 1
def get_phase_length(self, phase):
"""Returns the number of work items in a given phase, or None if there
is no good estimate.
"""Returns the number of work items in a given phase.
"""
# Yeah functional programming!
# and by functional we mean a bastardized python switch statement
return {
0: lambda: self.dirtytree.count_all(),
#there is no good way to guess this so just give total count
1: lambda: (4**(self.treedepth+1)-1)/3,
2: lambda: self.dirtytree.count_all(),
3: lambda: 0,
}[self.options['renderchecks']]()
def iterate_work_items(self, phase):
@@ -434,6 +455,10 @@ class TileSet(object):
This method returns an iterator over (obj, [dependencies, ...])
"""
# skip if asked to
if self.options['renderchecks'] == 3:
return
# The following block of code implementes the changelist functionality.
fd = self.options.get("changelist", None)
if fd:
@@ -537,6 +562,11 @@ class TileSet(object):
return "#%02x%02x%02x" % color[0:3]
isOverlay = self.options.get("overlay") or (not any(isinstance(x, rendermodes.Base) for x in self.options.get("rendermode")))
# don't update last render time if we're leaving this alone
last_rendertime = self.last_rendertime
if self.options['renderchecks'] != 3:
last_rendertime = self.max_chunk_mtime
d = dict(name = self.options.get('title'),
zoomLevels = self.treedepth,
defaultZoom = self.options.get('defaultzoom'),
@@ -546,7 +576,7 @@ class TileSet(object):
bgcolor = bgcolorformat(self.options.get('bgcolor')),
world = self.options.get('worldname_orig') +
(" - " + self.options.get('dimension')[0] if self.options.get('dimension')[1] != 0 else ''),
last_rendertime = self.max_chunk_mtime,
last_rendertime = last_rendertime,
imgextension = self.imgextension,
isOverlay = isOverlay,
poititle = self.options.get("poititle"),