Types¶
String based types¶
-
class
confiture.schema.types.String(encoding=None)¶ A type representing a string in the configuration.
Example in configuration:
my_string = "hello, world!"
-
class
confiture.schema.types.Regex(regex, error="value doesn't match", **kwargs)¶ A string based type validated against a regex.
-
class
confiture.schema.types.NamedRegex(regex, error="value doesn't match", **kwargs)¶ A string based type like Regex but returning named groups in dict.
-
class
confiture.schema.types.RegexPattern(flags=0, **kwargs)¶ A re Python object.
Parameters: flags – python re compile flag Example in configuration:
match = '/[a-z]+(-[a-z]+)?\.css'
-
class
confiture.schema.types.IPAddress(version=None, **kwargs)¶ A string based type representing an ipv4 or ipv6 address.
This type require the “ipaddr” package to work and will return an
ipaddr.IPAddressobject.Parameters: version – type or ip address to validate, can be 4 (ipv4 addresses only), 6 (ipv6 addresses only), or None (both). Example in configuration:
interface = "127.0.0.1"
-
class
confiture.schema.types.IPNetwork(version=None, **kwargs)¶ A string based type representing an ipv4 or ipv6 network.
This type require the “ipaddr” package to work and will return an
ipaddr.IPNetworkobject.Parameters: version – type or ip address to validate, can be 4 (ipv4 addresses only), 6 (ipv6 addresses only), or None (both). Example in configuration:
allow = "10.0.0.0/8"
-
class
confiture.schema.types.Url(encoding=None)¶ A string based type representing an URL.
This type return an urlparse.ParseResult object.
Example in configuration:
proxy = "http://proxy:3128"
-
class
confiture.schema.types.IPSocketAddress(default_addr='127.0.0.1', default_port=None, version=None, **kwargs)¶ A string based type representing an (ip address, port) couple.
This type return an IPSocketAddress.Address object.
Example in configuration:
interface = "0.0.0.0:80"
-
class
confiture.schema.types.Eval(locals=None, globals=None, **kwargs)¶ A string base type evaluating string as Python expression.
Example in configuration:
sum = 'sum(range(3, 10))'
Warning
This type can be dangerous since any Python expression can be typed by the user, like __import__(“sys”).exit(). Use it at your own risk.
-
class
confiture.schema.types.Path(encoding=None)¶ A string representing a filesystem path.
It will expand ‘~’ to user home directory and return an absolute path if you provide a relative path (this is usefull if you change the working directory of a process after configuration parsing).
Number based types¶
-
class
confiture.schema.types.Integer(min=None, max=None)¶ A type representing an integer in the configuration.
Parameters: - min – define the minimum acceptable value value of the integer
- max – define the maximum acceptable value value of the integer
Example in configuration:
my_integer = 42 my_integer = 42.0 # Will also match this type
-
class
confiture.schema.types.Float¶ A type representing a float in the configuration.
Example in configuration:
my_float = 42.2 my_float = 42 # All values matched by the Integer type also match # for the Float type