|
|
@ -34,6 +34,7 @@ import logging |
|
|
|
import sys |
|
|
|
from collections import Container, Mapping |
|
|
|
|
|
|
|
|
|
|
|
class LoggedClass(object): |
|
|
|
|
|
|
|
def __init__(self): |
|
|
@ -131,8 +132,8 @@ def deep_getsizeof(obj): |
|
|
|
def subclasses(base_class, strict=True): |
|
|
|
'''Return a list of subclasses of base_class in its module.''' |
|
|
|
def select(obj): |
|
|
|
return (inspect.isclass(obj) and issubclass(obj, base_class) |
|
|
|
and (not strict or obj != base_class)) |
|
|
|
return (inspect.isclass(obj) and issubclass(obj, base_class) and |
|
|
|
(not strict or obj != base_class)) |
|
|
|
|
|
|
|
pairs = inspect.getmembers(sys.modules[base_class.__module__], select) |
|
|
|
return [pair[1] for pair in pairs] |
|
|
@ -222,6 +223,7 @@ def open_file(filename, create=False): |
|
|
|
return open(filename, 'wb+') |
|
|
|
raise |
|
|
|
|
|
|
|
|
|
|
|
def open_truncate(filename): |
|
|
|
'''Open the file name. Return its handle.''' |
|
|
|
return open(filename, 'wb+') |
|
|
|