Skip to content
Snippets Groups Projects
Commit 354318fe authored by ptangu01's avatar ptangu01
Browse files

add tests on devtype

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1373 b32b6428-25c9-4566-ad07-03861ab6144f
parent 9cbcceb8
Branches
No related tags found
No related merge requests found
......@@ -124,6 +124,8 @@ class Device(object):
#####################################
# Devtype
def set_type(self, value):
if not tools.valid_devtype(value):
raise DeviceError("The devtype %s is not valid" % value)
self.__devtype = value
def get_type(self):
......
......@@ -39,7 +39,7 @@ else:
XAAL_ADDR_PATTERN = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$'
XAAL_DEVTYPE_PATTERN = '^[a-zA-Z][a-zA-Z0-9_-]*.[a-zA-Z][a-zA-Z0-9_-]*$'
def get_cfg_file(name, cfg_dir=config.CONF_DIR):
filename = '%s.conf' % name
......@@ -98,6 +98,13 @@ def valid_addr(val):
return result
def valid_devtype(val):
result = False
if re.match(XAAL_DEVTYPE_PATTERN,val):
result = True
return result
def get_logger(name, level, filename=None):
"""
It creates logger if doesn't exist.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment