Deleted Added
sdiff udiff text old ( 3179:c86dfc93984b ) new ( 8459:b8c3c20d0385 )
full compact
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 170 unchanged lines hidden (view full) ---

179
180class AnyProxy(BaseProxy):
181 def find(self, obj):
182 return obj.find_any(self._pdesc.ptype)
183
184 def path(self):
185 return 'any'
186
187def isproxy(obj):
188 if isinstance(obj, (BaseProxy, params.EthernetAddr)):
189 return True
190 elif isinstance(obj, (list, tuple)):
191 for v in obj:
192 if isproxy(v):
193 return True
194 return False
195
196class ProxyFactory(object):
197 def __init__(self, search_self, search_up):
198 self.search_self = search_self
199 self.search_up = search_up
200
201 def __getattr__(self, attr):
202 if attr == 'any':
203 return AnyProxy(self.search_self, self.search_up)
204 else:
205 return AttrProxy(self.search_self, self.search_up, attr)
206
207# global objects for handling proxies
208Parent = ProxyFactory(search_self = False, search_up = True)
209Self = ProxyFactory(search_self = True, search_up = False)
210
211# limit exports on 'from proxy import *'
212__all__ = ['Parent', 'Self']
213
214# see comment on imports at end of __init__.py.
215import params # for EthernetAddr