@@ -0,0 +1,952 @@
+# -*- coding: utf-8 -*-%0A%22%22%22%0A    controlbeast.utils.dynamic%0A    ~~~~~~~~~~~~~~~~~~~~~~~~~~%0A%0A    :copyright: Copyright 2013 by the ControlBeast team, see AUTHORS.%0A    :license: ISC, see LICENSE for details.%0A%22%22%22%0A%0A%0Aclass CbDynamic(object):%0A    %22%22%22%0A    Dynamic class generating properties from kwargs%0A    %22%22%22%0A%0A    def __init__(self, *args, **kwargs):%0A        %22%22%22%0A        Construct properties from keyword arguments%0A        %22%22%22%0A        for elem in kwargs:%0A            self.__add_property(elem, kwargs%5Belem%5D)%0A%0A    def __add_property(self, name, value, doc=None):%0A        %22%22%22%0A        Dynamically add property (read-only) to the current class object%0A        %22%22%22%0A        fget = lambda self: self._get_property(name)%0A        setattr(self.__class__, name, property(fget, doc=doc))%0A        setattr(self, '_' + name, value)%0A%0A    def _get_property(self, name):%0A        %22%22%22%0A        Get property by its internal name%0A        %22%22%22%0A        return getattr(self, '_' + name)

Add dynamic class creating properties from kwargs