def dict_to_schema(schema_dict, required, allow_custom_keys=True, modifier=None):
if modifier:<EOL><INDENT>modifier = Use(modifier)<EOL><DEDENT>def _to(value):<EOL><INDENT>if isinstance(value, dict):<EOL><INDENT>d = {}<EOL>for k, v in value.iteritems():<EOL><INDENT>if isinstance(k, basestring):<EOL><INDENT>k = Required(k) if required else Optional(k)<EOL><DEDENT>d[k] = _to(v)<EOL><DEDENT>if allow_custom_keys:<EOL><INDENT>d[Optional(basestring)] = modifier or object<EOL><DEDENT>schema = Schema(d)<EOL><DEDENT>elif modifier:<EOL><INDENT>schema = And(value, modifier)<EOL><DEDENT>else:<EOL><INDENT>schema = value<EOL><DEDENT>return schema<EOL><DEDENT>return _to(schema_dict)<EOL>
Convert a dict of Schemas into a Schema.

    Args:
        required (bool): Whether to make schema keys optional or required.
        allow_custom_keys (bool, optional): If True, creates a schema that
            allows custom items in dicts.
        modifier (callable): Functor to apply to dict values - it is applied
            via `Schema.Use`.

    Returns:
        A `Schema` object.