1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 __docformat__ = 'reStructuredText'
20
21 from pytilities.overloading import overloaded, Overload, Param
24 assert(isinstance(attribute, basestring))
25
26 if attribute.startswith("__") and not attribute.endswith("__"):
27 return "_" + cls_name + attribute
28 else:
29 return attribute
30
32 return __mangle_cls(instance.__class__.__name__, attribute)
33
34 @overloaded((
35 Overload(__mangle_cls,
36 Param('cls_name', basestring),
37 Param('attribute')),
38 Overload(__mangle_instance,
39 Param('instance'),
40 Param('attribute'))),
41 False)
43 """
44 Get the mangled name of an attribute
45
46 Overloaded parameters:
47
48 :a:
49
50 `cls_name` :: string
51 the name of the class to which the attribute belongs
52
53 `attribute` :: string
54 the attribute name to mangle
55
56 :b:
57
58 `instance`
59 the instance to which the attribute belongs to. It's class name
60 will be used for mangling.
61
62 `attribute` :: string
63 the attribute name to mangle
64
65 Returns mangled attribute, if it starts with '__' and doesn't end with
66 '__'. Otherwise, `attribute` is returned :: string
67 """
68