def verify_name(value, dotted_name):
"""
Verify the name. E.g., if it's a nested class, then we won't be
able to find it with the name we constructed.
"""
if dotted_name is UNKNOWN: return UNKNOWN
if len(dotted_name) == 1 and hasattr(__builtin__, dotted_name[0]):
return dotted_name
named_value = sys.modules.get(dotted_name[0])
if named_value is None: return UNKNOWN
for identifier in dotted_name[1:]:
try: named_value = getattr(named_value, identifier)
except: return UNKNOWN
if value is named_value:
return dotted_name
else:
return UNKNOWN
# [xx] not used:
评论列表
文章目录