This commit is contained in:
sfigato 2019-06-30 21:19:04 +02:00
parent ed8af40392
commit 7e6b757e3a
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F

View File

@ -1,9 +1,16 @@
# -*- encoding: utf-8 -*-
import asyncio
import logging
import typing as T
from phi.logging import get_logger
log = get_logger(__name__)
alog = logging.getLogger("asyncio")
alog.setLevel(logging.DEBUG)
def get_class(obj):
@ -53,8 +60,8 @@ class Entry(object):
LDAP Entry. Interface to LDAP.
"""
kind = None
_name = None
kind: T.Union[None, str] = None
_name: T.Union[None, str] = None
@classmethod
def name(cls):
@ -98,7 +105,7 @@ class Entry(object):
return res
async def build_heritage(obj, ChildClass, attribute_id="uid"):
async def build_heritage(obj, child_class, attribute_id="uid"):
"""
Given the object and the child class, yields the
instances of the children.
@ -106,7 +113,7 @@ async def build_heritage(obj, ChildClass, attribute_id="uid"):
async for child in obj.get_children():
if attribute_id in child:
_name = child[attribute_id][0]
yield ChildClass(_name, obj.client)
yield child_class(_name, obj.client)
class Hackers(Entry):
@ -175,7 +182,7 @@ class User(Hackers):
"""
kind = "uid"
_instances = dict()
_instances: T.Dict[str, Entry] = dict()
def __new__(cls, name, client, *args, **kwargs):
_name = f"{name}-{id(client)}"
@ -210,7 +217,7 @@ class Service(Robots):
"""
kind = "uid"
_instances = dict()
_instances: T.Dict[str, Entry] = dict()
def __new__(cls, name, client, *args, **kwargs):
_name = f"{name}-{id(client)}"
@ -244,7 +251,7 @@ class Group(Congregations):
"""
kind = "cn"
_instances = dict()
_instances: T.Dict[str, Entry] = dict()
def __new__(cls, name, client, *args, **kwargs):
_name = f"{name}-{id(client)}"