Add default parameter to get_attr method
This commit is contained in:
parent
4faaf2c3ad
commit
de9472a08a
1 changed files with 3 additions and 3 deletions
|
@ -105,17 +105,17 @@ class LdapServer(object):
|
||||||
def get_dn(self,obj):
|
def get_dn(self,obj):
|
||||||
return obj[0][0]
|
return obj[0][0]
|
||||||
|
|
||||||
def get_attr(self,obj,attr,all=None):
|
def get_attr(self,obj,attr,all=None,default=None):
|
||||||
if all is not None:
|
if all is not None:
|
||||||
if attr in obj:
|
if attr in obj:
|
||||||
return obj[attr]
|
return obj[attr]
|
||||||
else:
|
else:
|
||||||
return []
|
return default or []
|
||||||
else:
|
else:
|
||||||
if attr in obj:
|
if attr in obj:
|
||||||
return obj[attr][0]
|
return obj[attr][0]
|
||||||
else:
|
else:
|
||||||
return None
|
return default
|
||||||
|
|
||||||
class LdapServerException(BaseException):
|
class LdapServerException(BaseException):
|
||||||
def __init__(self,msg):
|
def __init__(self,msg):
|
||||||
|
|
Loading…
Reference in a new issue