A second any method that is faster then the first.
This commit is contained in:
@@ -269,7 +269,7 @@ class MetaData(object):
|
||||
"""
|
||||
Return any entity that matches the specification
|
||||
|
||||
:param typ:
|
||||
:param typ: Type of entity
|
||||
:param service:
|
||||
:param binding:
|
||||
:return:
|
||||
@@ -282,6 +282,37 @@ class MetaData(object):
|
||||
|
||||
return res
|
||||
|
||||
def any2(self, typ, service, binding=None):
|
||||
"""
|
||||
|
||||
:param type:
|
||||
:param service:
|
||||
:param binding:
|
||||
:return:
|
||||
"""
|
||||
res = {}
|
||||
for entid, item in self.items():
|
||||
hit = False
|
||||
try:
|
||||
descr = item['{}sso_descriptor'.format(typ)]
|
||||
except KeyError:
|
||||
continue
|
||||
else:
|
||||
for desc in descr:
|
||||
try:
|
||||
srvs = desc[service]
|
||||
except KeyError:
|
||||
continue
|
||||
else:
|
||||
for srv in srvs:
|
||||
if srv['binding'] == binding:
|
||||
res[entid] = item
|
||||
hit = True
|
||||
break
|
||||
if hit:
|
||||
break
|
||||
return res
|
||||
|
||||
def bindings(self, entity_id, typ, service):
|
||||
"""
|
||||
Get me all the bindings that are registered for a service entity
|
||||
|
Reference in New Issue
Block a user