"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "linotpd/src/linotp/lib/type_utils.py" between
LinOTP-release-2.11.2.tar.gz and LinOTP-release-2.12.tar.gz

About: LinOTP is a flexible and versatile OTP-platform for strong user authentication (two-factor authentication with one time passwords).

type_utils.py  (LinOTP-release-2.11.2):type_utils.py  (LinOTP-release-2.12)
skipping to change at line 31 skipping to change at line 31
# #
# E-mail: linotp@keyidentity.com # E-mail: linotp@keyidentity.com
# Contact: www.linotp.org # Contact: www.linotp.org
# Support: www.keyidentity.com # Support: www.keyidentity.com
# #
""" contains utility functions for type checking """ """ contains utility functions for type checking """
import re import re
import socket import socket
import netaddr import netaddr
import logging
from datetime import datetime
from datetime import timedelta from datetime import timedelta
from netaddr.ip import IPNetwork from netaddr.ip import IPNetwork
from linotp.lib.crypto.encrypted_data import EncryptedData from linotp.lib.crypto.encrypted_data import EncryptedData
DEFAULT_TIMEFORMAT = "%a, %d %b %Y %H:%M:%S GMT"
log = logging.getLogger(__name__)
class DurationParsingException(Exception): class DurationParsingException(Exception):
pass pass
duration_regex = re.compile(r'((?P<weeks>\d+?)(w|week|weeks))?' duration_regex = re.compile(r'((?P<weeks>\d+?)(w|week|weeks))?'
'((?P<days>\d+?)(d|day|days))?' '((?P<days>\d+?)(d|day|days))?'
'((?P<hours>\d+?)(h|hour|hours))?' '((?P<hours>\d+?)(h|hour|hours))?'
'((?P<minutes>\d+?)(m|minute|minutes))?' '((?P<minutes>\d+?)(m|minute|minutes))?'
'((?P<seconds>\d+?)(s|second|seconds))?$') '((?P<seconds>\d+?)(s|second|seconds))?$')
iso8601_duration_regex = re.compile(r'P((?P<years>\d+)Y)?' iso8601_duration_regex = re.compile(r'P((?P<years>\d+)Y)?'
skipping to change at line 204 skipping to change at line 210
false_def = ("no", "false") false_def = ("no", "false")
if value in (True, False): if value in (True, False):
return value return value
if value.lower() not in true_def and value.lower() not in false_def: if value.lower() not in true_def and value.lower() not in false_def:
raise Exception("unable to convert %r" % value) raise Exception("unable to convert %r" % value)
return value.lower() in true_def return value.lower() in true_def
def check_time_format_string(time_format_string):
"""
check if a given parameter is a valid time filter format
:param timefilter_format: the term which should describe datetime format
eg. "%d, %m, %H, %I, %M, %S, %J"
:return: boolean - true if this is valid format string
"""
# due to historical reasons we have to support as well booleans
if time_format_string in [True, False]:
return True
if time_format_string.lower() in ('true','false'):
return True
# verify that the given format could be applied
try:
now = datetime.utcnow()
dt_str = now.strftime(time_format_string)
_now_stripped = datetime.strptime(dt_str, time_format_string)
return True
except ValueError as exx:
log.error(
'invalid time filter format: %r: %r', time_format_string, exx
)
return False
def check_networks_expression(networks): def check_networks_expression(networks):
""" """
check if a given term is realy a description of networks check if a given term is realy a description of networks
:param networks: the term which should describe a network :param networks: the term which should describe a network
eg. "192.168.178.1/24, example.com/32" eg. "192.168.178.1/24, example.com/32"
:return: boolean - true if this is a network description :return: boolean - true if this is a network description
""" """
if not isinstance(networks, str) and not isinstance(networks, unicode): if not isinstance(networks, str) and not isinstance(networks, unicode):
 End of changes. 4 change blocks. 
0 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)