Types

String based types

class dotconf.schema.types.String

A type representing a string in the configuration.

Example in configuration:

my_string = "hello, world!"
class dotconf.schema.types.Regex(regex, error="value doesn't match")

A string based type validated against a regex.

class dotconf.schema.types.NamedRegex(regex, error="value doesn't match")

A string based type like Regex but returning named groups in dict.

class dotconf.schema.types.RegexPattern(flags=0)

A re Python object.

Parameters:flags – python re compile flag

Example in configuration:

match = '/[a-z]+(-[a-z]+)?\.css'
class dotconf.schema.types.IPAddress(version=None)

A string based type representing an ipv4 or ipv6 address.

This type require the “ipaddr” package to work and will return an ipaddr.IPAddress object.

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 dotconf.schema.types.IPNetwork(version=None)

A string based type representing an ipv4 or ipv6 network.

This type require the “ipaddr” package to work and will return an ipaddr.IPNetwork object.

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 dotconf.schema.types.Url

A string based type representing an URL.

This type return an urlparse.ParseResult object.

Example in configuration:

proxy = "http://proxy:3128"
class dotconf.schema.types.IPSocketAddress(default_addr='127.0.0.1', default_port=None, version=None)

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 dotconf.schema.types.Eval(locals=None, globals=None)

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.

Number based types

class dotconf.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 dotconf.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

Boolean based types

class dotconf.schema.types.Boolean

A type representing a boolean value in the configuration.

Example in configuration:

my_boolean = yes

Table Of Contents

Related Topics

This Page