linotp.lib.type_utils module¶
contains utility functions for type checking
- exception linotp.lib.type_utils.DurationParsingException¶
Bases:
Exception
- linotp.lib.type_utils.boolean(value)¶
type converter for boolean config entries
- linotp.lib.type_utils.check_networks_expression(networks)¶
check if a given term is realy a description of networks
- Parameters
networks – the term which should describe a network eg. “192.168.178.1/24, example.com/32”
- Returns
boolean - true if this is a network description
- linotp.lib.type_utils.check_time_format_string(time_format_string)¶
check if a given parameter is a valid time filter format
- Parameters
timefilter_format – the term which should describe datetime format eg. “%d, %m, %H, %I, %M, %S, %J”
- Returns
boolean - true if this is valid format string
- linotp.lib.type_utils.convert_to_datetime(date_str, time_formats)¶
Convert a string to a datetime object by one of the time format strings.
- Parameters
date_str – date string
time_formats – list of time formats, which the date string should match
- linotp.lib.type_utils.encrypted_data(value)¶
type converter for config entries -
similar to int(bla) it will try to conveert the given value into an object of EncryptedData
- Returns
EncyptedData object
- linotp.lib.type_utils.get_duration(value)¶
return duration in seconds
- linotp.lib.type_utils.get_ip_address(address)¶
get the ip address representation from netaddr
- Parameters
address – the term which should describe a ip address eg. 192.168.178.1 or www.example.com
- Returns
None or the netaddr.IPAddress object
- linotp.lib.type_utils.get_ip_network(network)¶
get the ip network representation from netaddr
- Parameters
network – the term which should describe a network eg. 192.168.178.1/24 or example.com/32
- Returns
None or the netaddr.IPNetwork object
- linotp.lib.type_utils.get_timeout(timeout, seperator=',')¶
get the timeout or timeout tuple from timeout input
- linotp.lib.type_utils.is_duration(value)¶
- linotp.lib.type_utils.is_integer(value)¶
type checking function for integers
- Parameters
value – the to be checked value
- Returns
return boolean
- linotp.lib.type_utils.is_ip_address(address)¶
get the ip address representation from netaddr
- Parameters
address – the term which should describe a ip address eg. 192.168.178.1 or www.example.com
- Returns
boolean - true if it is an IPAddress
- linotp.lib.type_utils.is_network(network)¶
test if a given term is realy a network description
- Parameters
network – the term which should describe a network eg. 192.168.178.1/24 or example.com/32
- Returns
boolean - true if this is a network description
- linotp.lib.type_utils.parse_duration(duration_str, time_delta_compliant=False)¶
transform a duration string into a time delta object
- Parameters
duration_str – duration string like ‘1h’ ‘3h 20m 10s’ ’10s’ or iso8601 durations like ‘P23DT23H’
- Returns
timedelta
- linotp.lib.type_utils.parse_timeout(timeout_val, seperator=',')¶
parse a timeout value which migth be a single value or a tuple of connection and response timeouts
- Params timeout_val
timeout value which could be either string, tuple or float/int
- Returns
timeout tuple of float or float/int timeout value
- linotp.lib.type_utils.text(value)¶
type converter for text config entries
if the value is unicode or str, leave it as is otherwise take the string representation