MCPcopy Index your code
hub / github.com/python/cpython / resolve_dotted_attribute

Function resolve_dotted_attribute

Lib/xmlrpc/server.py:124–146  ·  view source on GitHub ↗

resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d Resolves a dotted attribute name to an object. Raises an AttributeError if any attribute in the chain starts with a '_'. If the optional allow_dotted_names argument is false, dots are not supported and this function operates similar

(obj, attr, allow_dotted_names=True)

Source from the content-addressed store, hash-verified

122 fcntl = None
123
124def resolve_dotted_attribute(obj, attr, allow_dotted_names=True):
125 """resolve_dotted_attribute(a, 'b.c.d') => a.b.c.d
126
127 Resolves a dotted attribute name to an object. Raises
128 an AttributeError if any attribute in the chain starts with a '_'.
129
130 If the optional allow_dotted_names argument is false, dots are not
131 supported and this function operates similar to getattr(obj, attr).
132 """
133
134 if allow_dotted_names:
135 attrs = attr.split('.')
136 else:
137 attrs = [attr]
138
139 for i in attrs:
140 if i.startswith('_'):
141 raise AttributeError(
142 'attempt to access private attribute "%s"' % i
143 )
144 else:
145 obj = getattr(obj,i)
146 return obj
147
148def list_public_methods(obj):
149 """Returns a list of attribute strings, found in the specified

Callers 3

system_methodHelpMethod · 0.85
_dispatchMethod · 0.85

Calls 2

splitMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…