1
0
Fork 0
mirror of https://github.com/kakwa/ldapcherry synced 2025-07-04 04:17:43 +02:00

begin attributes handling manipulation

This commit is contained in:
kakwa 2015-05-17 12:24:29 +02:00
parent 1211ab431b
commit dbc88163dd
6 changed files with 141 additions and 28 deletions

View file

@ -8,15 +8,27 @@
import os
import sys
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
from ldapcherry.pyyamlwrapper import loadNoDump
from ldapcherry.pyyamlwrapper import DumplicatedKey
from ldapcherry.exceptions import MissingAttributesFile
from sets import Set
import yaml
types = ['string', 'email', 'int', 'stringlist', 'fix', 'password']
class Attributes:
def __init__(self, attributes_file):
pass
self.attributes_file = attributes_file
self.backends = Set([])
try:
stream = open(attributes_file, 'r')
except:
raise MissingAttributesFile(attributes_file)
try:
self.attributes = loadNoDump(stream)
except DumplicatedKey as e:
raise DumplicateAttributesKey(e.key)
def get_selfattributes(self):
"""get the list of groups from roles"""

View file

@ -38,3 +38,8 @@ class MissingRolesFile(Exception):
def __init__(self, rolefile):
self.rolefile = rolefile
self.log = "fail to open role file <%(rolefile)s>" % { 'rolefile' : rolefile}
class MissingAttributesFile(Exception):
def __init__(self, attributesfile):
self.attributesfile = attributesfile
self.log = "fail to open attributes file <%(attributesfile)s>" % { 'attributesfile' : attributesfile}