def find(self, obj):
try:
val = getattr(obj, self._attr)
+ # for any additional unproxying to be done, pass the
+ # current, rather than the original object so that proxy
+ # has the right context
+ obj = val
except:
return None, False
while isproxy(val):
def path(self):
return 'any'
+# The AllProxy traverses the entire sub-tree (not only the children)
+# and adds all objects of a specific type
+class AllProxy(BaseProxy):
+ def find(self, obj):
+ return obj.find_all(self._pdesc.ptype)
+
+ def path(self):
+ return 'all'
+
def isproxy(obj):
if isinstance(obj, (BaseProxy, params.EthernetAddr)):
return True
def __getattr__(self, attr):
if attr == 'any':
return AnyProxy(self.search_self, self.search_up)
+ elif attr == 'all':
+ if self.search_up:
+ assert("Parant.all is not supported")
+ return AllProxy(self.search_self, self.search_up)
else:
return AttrProxy(self.search_self, self.search_up, attr)