Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 95 lines (78 sloc) 5.383 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# This file describes the format of the config file. Each item defined in this
# module is expected to appear in the described format in a valid config file.
# The only difference is, instead of actual values for the settings, values are
# Setting objects which define how to validate a value as correct, and whether
# the value is required or not.

# Settings objects have this signature:
# Setting(required, validator, default)

# required
# a boolean indicating that this value is required. A required setting will
# always exist in a validated config. This option only has effect in the
# event that a user doesn't provide a value and the default is None. In this
# case, a required setting will raise an error. Otherwise, the situation will
# result in the setting being omitted from the config with no error.

# (If it wasn't obvious: a required setting does NOT mean that the user is
# required to specify it, just that the setting is required to be set for the
# operation of the program, either by the user or by using the default)

# validator
# a callable that takes the provided value and returns a cleaned/normalized
# value to replace it with. It should raise a ValidationException if there is
# a problem parsing or validating the value given.

# default
# This is used in the event that the user does not provide a value. In this
# case, the default value is passed into the validator just the same. If
# default is None, then depending on the value of required, it is either an
# error to omit this setting or the setting is skipped entirely and will not
# appear in the resulting parsed options.

# The signature for validator callables is validator(value_given). Remember
# that the default is passed in as value_given if the user did not provide a
# value.

# This file doesn't specify the format or even the type of the setting values,
# it is up to the validators to ensure the values passed in are the right type,
# either by coercion or by raising an error.

# Oh, one other thing: For top level values whose required attribute is True,
# the default value is set initially, before the config file is parsed, and is
# available during the execution of the config file. This way, container types
# can be initialized and then appended/added to when the config file is parsed.

from settingsValidators import *
import util

# renders is a dictionary mapping strings to dicts. These dicts describe the
# configuration for that render. Therefore, the validator for 'renders' is set
# to a dict validator configured to validate keys as strings and values as...

# values are set to validate as a "configdict", which is a dict mapping a set
# of strings to some value. the make_configdictvalidator() function creates a
# validator to use here configured with the given set of keys and Setting
# objects with their respective validators.

# config file.
renders = Setting(required=True, default=util.OrderedDict(),
        validator=make_dictValidator(validateStr, make_configDictValidator(
        {
            "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'),
            "northdirection": Setting(required=True, validator=validateNorthDirection, default=0),
            "forcerender": Setting(required=False, validator=validateBool, default=None),
            "imgformat": Setting(required=True, validator=validateImgFormat, default="png"),
            "imgquality": Setting(required=False, validator=validateImgQuality, default=95),
            "bgcolor": Setting(required=True, validator=validateBGColor, default="1a1a1a"),
            "optimizeimg": Setting(required=True, validator=validateOptImg, default=0),
            "nomarkers": Setting(required=False, validator=validateBool, default=None),
            "texturepath": Setting(required=False, validator=validateTexturePath, default=None),
            "renderchecks": Setting(required=False, validator=validateInt, default=None),
            "rerenderprob": Setting(required=True, validator=validateFloat, default=0),
            "crop": Setting(required=False, validator=validateCrop, default=None),
            "changelist": Setting(required=False, validator=validateStr, default=None),
            "markers": Setting(required=False, validator=validateMarkers, default=[]),
            
            # 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")),
        }
        )))

# The worlds dict, mapping world names to world paths
worlds = Setting(required=True, validator=make_dictValidator(validateStr, validateWorldPath), default=util.OrderedDict())

outputdir = Setting(required=True, validator=validateOutputDir, default=None)

processes = Setting(required=True, validator=int, default=-1)

# memcached is an option, but unless your IO costs are really high, it just
# ends up adding overhead and isn't worth it.
memcached_host = Setting(required=False, validator=str, default=None)
Something went wrong with that request. Please try again.