summaryrefslogtreecommitdiff
path: root/cad/src/experimental/demoapp_0.1/demoapp/foundation/description_utils.py
blob: 3f814a2983a3b0d5363dd48ca32b94b04e9d7a95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class _fakemethod_class(object):
    def __init__(self, name):
        self.name = name
    def fakemethod(self, *args):
        return self.name, args
    pass

class Description_Making_Methods(object): #e rename; also let it assertfail if attr not recognized
    "#doc"
    def __getattr__(self, attr):
        if attr.startswith('_'):
            raise AttributeError, attr
        #e assert attr in some list, perhaps generated from filtering dir(some subclass of HighlightGraphics)
        fakemethod = _fakemethod_class(name = attr).fakemethod
            # note: using a local function didn't seem to work re storing name --
            # e.g. the arg signature (*args, _name = attr) was not allowed.
        setattr(self, attr, fakemethod) # cache it for efficiency
        return fakemethod
    pass

def description_maker_for_methods_in_class( cls):
    del cls
    return Description_Making_Methods() # kluge: use dir(cls) as in comment above