Changed "worldname" to "world" in configfile
Also brought tests up to date. All tests pass now.
This commit is contained in:
parent
f3b434a327
commit
aaf8e1d7cb
|
@ -22,7 +22,7 @@ A Simple Example
|
|||
worlds["My world"] = "/home/username/server/world"
|
||||
|
||||
render["normalrender"] = {
|
||||
"worldname": "My world",
|
||||
"world": "My world",
|
||||
"title": "Normal Render of My World",
|
||||
}
|
||||
|
||||
|
@ -60,28 +60,28 @@ A more complicated example
|
|||
worlds["creative"] = "/home/username/server/creativeworld"
|
||||
|
||||
renders["survivalday"] = {
|
||||
"worldname": "survival",
|
||||
"world": "survival",
|
||||
"title": "Survival Daytime",
|
||||
"rendermode": smooth_lighting,
|
||||
"dimension": "overworld",
|
||||
}
|
||||
|
||||
renders["survivalnight"] = {
|
||||
"worldname": "survival",
|
||||
"world": "survival",
|
||||
"title": "Survival Daytime",
|
||||
"rendermode": smooth_night,
|
||||
"dimension": "overworld",
|
||||
}
|
||||
|
||||
renders["survivalnether"] = {
|
||||
"worldname": "survival",
|
||||
"world": "survival",
|
||||
"title": "Survival Nether",
|
||||
"rendermode": nether_smooth_lighting,
|
||||
"dimension": "nether",
|
||||
}
|
||||
|
||||
renders["survivalspawnoverlay"] = {
|
||||
"worldname": "survival",
|
||||
"world": "survival",
|
||||
"title": "Spawn Overlay",
|
||||
"rendermode": spawn_overlay,
|
||||
"dimension": "overworld",
|
||||
|
@ -89,7 +89,7 @@ A more complicated example
|
|||
}
|
||||
|
||||
renders["creative"] = {
|
||||
"worldname": "creative",
|
||||
"world": "creative",
|
||||
"title": "Creative",
|
||||
"rendermode": smooth_lighting,
|
||||
"dimension": "overworld",
|
||||
|
@ -152,7 +152,7 @@ Overviewer's rendering.
|
|||
Render Dictonary Keys
|
||||
---------------------
|
||||
|
||||
``worldname``
|
||||
``world``
|
||||
Specifies which world this render corresponds to. Its value should be a
|
||||
string from the appropriate key in the worlds dictionary.
|
||||
|
||||
|
@ -363,7 +363,7 @@ primitive object's constructor::
|
|||
Then you can use your new rendermode in your render definitions::
|
||||
|
||||
render["survivalday"] = {
|
||||
"worldname": "survival",
|
||||
"world": "survival",
|
||||
"title": "Survival Daytime",
|
||||
"rendermode": my_rendermode,
|
||||
"dimension": "overworld",
|
||||
|
|
|
@ -194,7 +194,7 @@ def main():
|
|||
print "worlds['myworld'] = %r" % args[0]
|
||||
print "outputdir = %r" % (args[1] if len(args) > 1 else "/path/to/output")
|
||||
print
|
||||
logging.error("Cannot specify both --config and worldname / output directory")
|
||||
logging.error("Cannot specify both --config AND a world + output directory on the command line.")
|
||||
parser.print_help()
|
||||
return 1
|
||||
|
||||
|
@ -238,7 +238,7 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||
renders = {}
|
||||
for rm in rendermodes:
|
||||
renders["world-" + rm] = {
|
||||
"worldname": "world",
|
||||
"world": "world",
|
||||
"title": "Overviewer Render (%s)" % rm,
|
||||
"rendermode": rm,
|
||||
}
|
||||
|
@ -274,16 +274,16 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||
return 1
|
||||
|
||||
for rname, render in config['renders'].iteritems():
|
||||
# Convert render['worldname'] to the world path, and store the original
|
||||
# Convert render['world'] to the world path, and store the original
|
||||
# in render['worldname_orig']
|
||||
try:
|
||||
worldpath = config['worlds'][render['worldname']]
|
||||
worldpath = config['worlds'][render['world']]
|
||||
except KeyError:
|
||||
logging.error("Render %s's world is '%s', but I could not find a corresponding entry in the worlds dictionary.",
|
||||
rname, render['worldname'])
|
||||
rname, render['world'])
|
||||
return 1
|
||||
render['worldname_orig'] = render['worldname']
|
||||
render['worldname'] = worldpath
|
||||
render['worldname_orig'] = render['world']
|
||||
render['world'] = worldpath
|
||||
|
||||
destdir = config['outputdir']
|
||||
if not destdir:
|
||||
|
@ -319,11 +319,11 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
|||
logging.debug("Found the following render thing: %r", render)
|
||||
|
||||
# find or create the world object
|
||||
if (render['worldname'] not in worldcache):
|
||||
w = world.World(render['worldname'])
|
||||
worldcache[render['worldname']] = w
|
||||
if (render['world'] not in worldcache):
|
||||
w = world.World(render['world'])
|
||||
worldcache[render['world']] = w
|
||||
else:
|
||||
w = worldcache[render['worldname']]
|
||||
w = worldcache[render['world']]
|
||||
|
||||
# find or create the textures object
|
||||
texopts = util.dict_subset(render, ["texturepath", "bgcolor", "northdirection"])
|
||||
|
|
|
@ -58,7 +58,7 @@ from settingsValidators import *
|
|||
renders = Setting(required=True, default={},
|
||||
validator=make_dictValidator(validateStr, make_configDictValidator(
|
||||
{
|
||||
"worldname": Setting(required=True, validator=validateStr, default=None),
|
||||
"world": Setting(required=True, validator=validateStr, default=None),
|
||||
"dimension": Setting(required=True, validator=validateDimension, default="default"),
|
||||
"title": Setting(required=True, validator=validateStr, default=None),
|
||||
"rendermode": Setting(required=True, validator=validateRenderMode, default='normal'),
|
||||
|
@ -74,6 +74,10 @@ renders = Setting(required=True, default={},
|
|||
"texturepath": Setting(required=False, validator=validateTexturePath, default=None),
|
||||
"renderchecks": Setting(required=True, validator=validateInt, default=0),
|
||||
"rerenderprob": Setting(required=True, validator=validateFloat, default=0),
|
||||
|
||||
# Remove this eventually (once people update their configs)
|
||||
"worldname": Setting(required=False, default=None,
|
||||
validator=error("The option 'worldname' is now called 'world'. Please update your config files")),
|
||||
}
|
||||
)))
|
||||
|
||||
|
|
|
@ -188,3 +188,8 @@ def make_configDictValidator(config, ignore_undefined=False):
|
|||
return newdict
|
||||
|
||||
return configDictValidator
|
||||
|
||||
def error(errstr):
|
||||
def validator(_):
|
||||
raise ValidationException(errstr)
|
||||
return validator
|
||||
|
|
|
@ -244,6 +244,13 @@ class TileSet(object):
|
|||
that a tile which is not marked for render by any mtime checks will
|
||||
be rendered anyways. 0 disables this option.
|
||||
|
||||
Other options that must be specified but aren't really documented
|
||||
(oops. consider it a TODO):
|
||||
* worldname_orig
|
||||
* dimension
|
||||
* title
|
||||
* name
|
||||
|
||||
"""
|
||||
self.options = options
|
||||
self.regionset = regionsetobj
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
world['test'] = "test/data/settings/test_world"
|
||||
worlds['test'] = "test/data/settings/test_world"
|
||||
|
||||
render["myworld"] = {
|
||||
renders["myworld"] = {
|
||||
"title": "myworld title",
|
||||
"worldname": "test",
|
||||
"world": "test",
|
||||
"rendermode": normal,
|
||||
"northdirection": "upper-left",
|
||||
}
|
||||
|
||||
render["otherworld"] = {
|
||||
renders["otherworld"] = {
|
||||
"title": "otherworld title",
|
||||
"worldname": "test",
|
||||
"world": "test",
|
||||
"rendermode": normal,
|
||||
"bgcolor": "#ffffff"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
world['test'] = "test/data/settings/test_world"
|
||||
worlds['test'] = "test/data/settings/test_world"
|
||||
|
||||
render["world"] = {
|
||||
"worldname": "test",
|
||||
renders["world"] = {
|
||||
"world": "test",
|
||||
"title": "myworld title",
|
||||
"rendermode": "bad_rendermode",
|
||||
"northdirection": "upper-left",
|
||||
|
|
|
@ -12,5 +12,23 @@ from test_rendertileset import RendertileSetTest
|
|||
from test_settings import SettingsTest
|
||||
from test_tileset import TilesetTest
|
||||
|
||||
# DISABLE THIS BLOCK TO GET LOG OUTPUT FROM TILESET FOR DEBUGGING
|
||||
if 0:
|
||||
import logging
|
||||
root = logging.getLogger()
|
||||
class NullHandler(logging.Handler):
|
||||
def handle(self, record):
|
||||
pass
|
||||
def emit(self, record):
|
||||
pass
|
||||
def createLock(self):
|
||||
self.lock = None
|
||||
root.addHandler(NullHandler())
|
||||
else:
|
||||
import overviewer
|
||||
import logging
|
||||
overviewer.configure_logger(logging.DEBUG, True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -21,12 +21,12 @@ class SettingsTest(unittest.TestCase):
|
|||
# no exceptions so far. that's a good thing
|
||||
|
||||
# Test the default
|
||||
self.assertEquals(things['render']['myworld']['bgcolor'], (26,26,26,0))
|
||||
self.assertEquals(things['renders']['myworld']['bgcolor'], (26,26,26,0))
|
||||
|
||||
# Test a non-default
|
||||
self.assertEquals(things['render']['otherworld']['bgcolor'], (255,255,255,0))
|
||||
self.assertEquals(things['renders']['otherworld']['bgcolor'], (255,255,255,0))
|
||||
|
||||
self.assertEquals(things['render']['myworld']['northdirection'],
|
||||
self.assertEquals(things['renders']['myworld']['northdirection'],
|
||||
world.UPPER_LEFT)
|
||||
|
||||
def test_rendermode_validation(self):
|
||||
|
@ -42,20 +42,20 @@ class SettingsTest(unittest.TestCase):
|
|||
fromfile = configParser.MultiWorldParser()
|
||||
fromfile.parse("test/data/settings/settings_test_1.py")
|
||||
|
||||
self.s.set_config_item("world", {
|
||||
self.s.set_config_item("worlds", {
|
||||
'test': "test/data/settings/test_world",
|
||||
})
|
||||
self.s.set_config_item("render", {
|
||||
self.s.set_config_item("renders", {
|
||||
"myworld": {
|
||||
"title": "myworld title",
|
||||
"worldname": "test",
|
||||
"world": "test",
|
||||
"rendermode": rendermodes.normal,
|
||||
"northdirection": "upper-left",
|
||||
},
|
||||
|
||||
"otherworld": {
|
||||
"title": "otherworld title",
|
||||
"worldname": "test",
|
||||
"world": "test",
|
||||
"rendermode": rendermodes.normal,
|
||||
"bgcolor": "#ffffff"
|
||||
},
|
||||
|
@ -64,20 +64,20 @@ class SettingsTest(unittest.TestCase):
|
|||
self.assertEquals(fromfile.get_validated_config(), self.s.get_validated_config())
|
||||
|
||||
def test_rendermode_string(self):
|
||||
self.s.set_config_item("world", {
|
||||
self.s.set_config_item("worlds", {
|
||||
'test': "test/data/settings/test_world",
|
||||
})
|
||||
self.s.set_config_item("outputdir", "/tmp/fictional/outputdir")
|
||||
self.s.set_config_item("render", {
|
||||
self.s.set_config_item("renders", {
|
||||
"myworld": {
|
||||
"title": "myworld title",
|
||||
"worldname": "test",
|
||||
"world": "test",
|
||||
"rendermode": "normal",
|
||||
"northdirection": "upper-left",
|
||||
},
|
||||
})
|
||||
p = self.s.get_validated_config()
|
||||
self.assertEquals(p['render']['myworld']['rendermode'], rendermodes.normal)
|
||||
self.assertEquals(p['renders']['myworld']['rendermode'], rendermodes.normal)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -8,23 +8,6 @@ import random
|
|||
|
||||
from overviewer_core import tileset, util
|
||||
|
||||
# DISABLE THIS BLOCK TO GET LOG OUTPUT FROM TILESET FOR DEBUGGING
|
||||
if 1:
|
||||
import logging
|
||||
root = logging.getLogger()
|
||||
class NullHandler(logging.Handler):
|
||||
def handle(self, record):
|
||||
pass
|
||||
def emit(self, record):
|
||||
pass
|
||||
def createLock(self):
|
||||
self.lock = None
|
||||
root.addHandler(NullHandler())
|
||||
else:
|
||||
import overviewer
|
||||
import logging
|
||||
overviewer.configure_logger(logging.DEBUG, True)
|
||||
|
||||
# Supporing data
|
||||
# chunks list: chunkx, chunkz mapping to chunkmtime
|
||||
# In comments: col, row
|
||||
|
@ -121,6 +104,13 @@ class FakeRegionset(object):
|
|||
except KeyError:
|
||||
return None
|
||||
|
||||
class FakeAssetmanager(object):
|
||||
def __init__(self, lastrendertime):
|
||||
self.lrm = lastrendertime
|
||||
|
||||
def get_tileset_config(self, _):
|
||||
return {'lastrendertime': self.lrm}
|
||||
|
||||
def get_tile_set(chunks):
|
||||
"""Given the dictionary mapping chunk coordinates their mtimes, returns a
|
||||
dict mapping the tiles that are to be rendered to their mtimes that are
|
||||
|
@ -201,7 +191,7 @@ class TilesetTest(unittest.TestCase):
|
|||
'rerenderprob': 0
|
||||
}
|
||||
defoptions.update(options)
|
||||
ts = tileset.TileSet(self.rs, None, None, defoptions, outputdir)
|
||||
ts = tileset.TileSet(self.rs, FakeAssetmanager(0), None, defoptions, outputdir)
|
||||
if preprocess:
|
||||
preprocess(ts)
|
||||
ts.do_preprocessing()
|
||||
|
|
Loading…
Reference in New Issue