mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-03 11:57:41 +02:00
better checks for attributes
This commit is contained in:
parent
679c2bba85
commit
a71093038c
4 changed files with 41 additions and 20 deletions
|
@ -10,7 +10,7 @@ import sys
|
|||
|
||||
from ldapcherry.pyyamlwrapper import loadNoDump
|
||||
from ldapcherry.pyyamlwrapper import DumplicatedKey
|
||||
from ldapcherry.exceptions import MissingAttributesFile, MissingKey
|
||||
from ldapcherry.exceptions import MissingAttributesFile, MissingKey, WrongAttributeType
|
||||
from sets import Set
|
||||
import yaml
|
||||
|
||||
|
@ -32,6 +32,9 @@ class Attributes:
|
|||
|
||||
for attrid in self.attributes:
|
||||
self._mandatory_check(attrid)
|
||||
attr = self.attributes[attrid]
|
||||
if not attr['type'] in types:
|
||||
raise WrongAttributeType(attr['type'], attrid, attributes_file)
|
||||
|
||||
def _mandatory_check(self, attr):
|
||||
for m in ['description', 'display_name', 'type', 'backend-attributes']:
|
||||
|
|
|
@ -43,3 +43,12 @@ class MissingAttributesFile(Exception):
|
|||
def __init__(self, attributesfile):
|
||||
self.attributesfile = attributesfile
|
||||
self.log = "fail to open attributes file <%(attributesfile)s>" % { 'attributesfile' : attributesfile}
|
||||
|
||||
class WrongAttributeType(Exception):
|
||||
def __init__(self, key, section, ymlfile):
|
||||
self.key = key
|
||||
self.section = section
|
||||
self.ymlfile = ymlfile
|
||||
self.log = "wrong attribute type <%(key)s> in section <%(section)s> inside file <%(ymlfile)s>" % {'key': key, 'section': section, 'ymlfile': ymlfile }
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue