Passed
Push — master ( 49a75c...deac8e )
by Max
01:10
created

structured_data._doc_wrapper.DocWrapper.__set__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 3
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
class DocWrapper:
2
    def __init__(self, doc=None):
3
        self.doc = doc
4
5
    @classmethod
6
    def wrap_class(cls, klass):
7
        """Wrapp a classes docstring to conceal it from instances."""
8
        klass.__doc__ = cls(klass.__doc__)
9
        return klass
10
11
    def __get__(self, instance, owner):
12
        if instance is None:
13
            return self.doc
14
        return vars(instance).get("__doc__")
15
16
    def __set__(self, instance, value):
17
        vars(instance)["__doc__"] = value
18
19
    def __delete__(self, instance):
20
        vars(instance).pop("__doc__", None)
21