|
|
|
@ -602,46 +602,6 @@ class FreeBSDHardware(Hardware):
|
|
|
|
|
if s:
|
|
|
|
|
self.facts['devices'][d.group(1)].append(s.group(1))
|
|
|
|
|
|
|
|
|
|
def itersubclasses(cls, _seen=None):
|
|
|
|
|
"""
|
|
|
|
|
itersubclasses(cls)
|
|
|
|
|
|
|
|
|
|
Generator over all subclasses of a given class, in depth first order.
|
|
|
|
|
|
|
|
|
|
>>> list(itersubclasses(int)) == [bool]
|
|
|
|
|
True
|
|
|
|
|
>>> class A(object): pass
|
|
|
|
|
>>> class B(A): pass
|
|
|
|
|
>>> class C(A): pass
|
|
|
|
|
>>> class D(B,C): pass
|
|
|
|
|
>>> class E(D): pass
|
|
|
|
|
>>>
|
|
|
|
|
>>> for cls in itersubclasses(A):
|
|
|
|
|
... print(cls.__name__)
|
|
|
|
|
B
|
|
|
|
|
D
|
|
|
|
|
E
|
|
|
|
|
C
|
|
|
|
|
>>> # get ALL (new-style) classes currently defined
|
|
|
|
|
>>> [cls.__name__ for cls in itersubclasses(object)] #doctest: +ELLIPSIS
|
|
|
|
|
['type', ...'tuple', ...]
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
if not isinstance(cls, type):
|
|
|
|
|
raise TypeError('itersubclasses must be called with '
|
|
|
|
|
'new-style classes, not %.100r' % cls)
|
|
|
|
|
if _seen is None: _seen = set()
|
|
|
|
|
try:
|
|
|
|
|
subs = cls.__subclasses__()
|
|
|
|
|
except TypeError: # fails only when cls is type
|
|
|
|
|
subs = cls.__subclasses__(cls)
|
|
|
|
|
for sub in subs:
|
|
|
|
|
if sub not in _seen:
|
|
|
|
|
_seen.add(sub)
|
|
|
|
|
yield sub
|
|
|
|
|
for sub in itersubclasses(sub, _seen):
|
|
|
|
|
yield sub
|
|
|
|
|
|
|
|
|
|
class Network(Facts):
|
|
|
|
|
"""
|
|
|
|
|
This is a generic Network subclass of Facts. This should be further
|
|
|
|
@ -663,7 +623,7 @@ class Network(Facts):
|
|
|
|
|
|
|
|
|
|
def __new__(cls, *arguments, **keyword):
|
|
|
|
|
subclass = cls
|
|
|
|
|
for sc in itersubclasses(Network):
|
|
|
|
|
for sc in Network.__subclasses__():
|
|
|
|
|
if sc.platform == platform.system():
|
|
|
|
|
subclass = sc
|
|
|
|
|
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
|
|
|
@ -969,14 +929,14 @@ class GenericBsdIfconfigNetwork(Network):
|
|
|
|
|
for item in ifinfo[ip_type][0].keys():
|
|
|
|
|
defaults[item] = ifinfo[ip_type][0][item]
|
|
|
|
|
|
|
|
|
|
class DarwinNetwork(GenericBsdIfconfigNetwork):
|
|
|
|
|
class DarwinNetwork(GenericBsdIfconfigNetwork, Network):
|
|
|
|
|
"""
|
|
|
|
|
This is the Mac OS X/Darwin Network Class.
|
|
|
|
|
It uses the GenericBsdIfconfigNetwork unchanged
|
|
|
|
|
"""
|
|
|
|
|
platform = 'Darwin'
|
|
|
|
|
|
|
|
|
|
class FreeBSDNetwork(GenericBsdIfconfigNetwork):
|
|
|
|
|
class FreeBSDNetwork(GenericBsdIfconfigNetwork, Network):
|
|
|
|
|
"""
|
|
|
|
|
This is the FreeBSD Network Class.
|
|
|
|
|
It uses the GenericBsdIfconfigNetwork unchanged
|
|
|
|
|