# Path: ldapcherry/pyyamlwrapper.py
# def loadNoDump(stream):
#     loader = MyLoader(stream)
#     try:
#         return loader.get_single_data()
#     finally:
#         loader.dispose()
# 
# Path: ldapcherry/pyyamlwrapper.py
# class DumplicatedKey(Exception):
#     def __init__(self, host, key):
#         self.host = host
#         self.key = key


import os
import sys
import copy
import yaml
from ldapcherry.pyyamlwrapper import loadNoDump
from ldapcherry.pyyamlwrapper import DumplicatedKey
from ldapcherry.exceptions import *
    from sets import Set as set

if sys.version < '3':


class CustomDumper(yaml.SafeDumper):
    "A custom YAML dumper that never emits aliases"

    def ignore_aliases(self, _data):
        return True


class Roles:

    def __init__(self, role_file):
        self.role_file = role_file
        self.backends = set([])
        try:
            stream = open(role_file, 'r')
        except Exception as e:
            raise MissingRolesFile(role_file)
        try:
            self.roles_raw = loadNoDump(stream)
        except DumplicatedKey as e:
            raise DumplicateRoleKey(e.key)
        stream.close()

        self.graph = {}
        self.roles = {}
        self.flatten = {}
        self.group2roles = {}

# Path: ldapcherry/pyyamlwrapper.py
# def loadNoDump(stream):
#     loader = MyLoader(stream)
#     try:
#         return loader.get_single_data()
#     finally:
#         loader.dispose()
# 
# Path: ldapcherry/pyyamlwrapper.py
# class DumplicatedKey(Exception):
#     def __init__(self, host, key):
#         self.host = host
#         self.key = key


# Path: ldapcherry/roles.py
import os
import sys
import copy
import yaml
from ldapcherry.pyyamlwrapper import loadNoDump
from ldapcherry.pyyamlwrapper import DumplicatedKey
from ldapcherry.exceptions import *
    from sets import Set as set


if sys.version < '3':


class CustomDumper(yaml.SafeDumper):
    "A custom YAML dumper that never emits aliases"

    def ignore_aliases(self, _data):
        return True


class Roles:

    def __init__(self, role_file):
        self.role_file = role_file
        self.backends = set([])
        try:
            stream = open(role_file, 'r')
        except Exception as e:
            raise MissingRolesFile(role_file)
        try:
            self.roles_raw = loadNoDump(stream)
        except DumplicatedKey as e:
            raise DumplicateRoleKey(e.key)
        stream.close()

        self.graph = {}
        self.roles = {}
        self.flatten = {}
        self.group2roles = {}

        self.admin_roles = []