new frontend 'weboobcfg'
This commit is contained in:
parent
dc706132ab
commit
7b2295cf6c
9 changed files with 167 additions and 49 deletions
|
|
@ -115,7 +115,7 @@ class ConsoleApplication(BaseApplication):
|
|||
sys.stderr.write("No such command: %s.\n" % command)
|
||||
elif len(matching_commands) == 1:
|
||||
try:
|
||||
getattr(self, matching_commands[0])(*args)
|
||||
return getattr(self, matching_commands[0])(*args)
|
||||
except TypeError, e:
|
||||
try:
|
||||
sys.stderr.write("Command '%s' takes %s arguments.\n" % \
|
||||
|
|
|
|||
|
|
@ -43,43 +43,3 @@ def local2utc(d):
|
|||
d = d.replace(tzinfo=tz.tzlocal())
|
||||
d = d.astimezone(tz.tzutc())
|
||||
return d
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue