def siblings(self, *args, **kargs):
"""
find all sibling components that match the supplied argument list
and attribute dictionary, or None if nothing could be found
"""
sibs = [s for s in self.parent.components if not s == self]
matches = []
first_only = False
if 'first_only' in kargs:
first_only = kargs.pop('first_only')
for c in sibs:
try:
check = True
tag = getattr(c, 'tag').replace("/", "")
if args and tag not in args:
check = False
for (key, value) in kargs.iteritems():
if c[key] != value:
check = False
if check:
matches.append(c)
if first_only:
break
except:
pass
return matches
评论列表
文章目录