3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

CamelCaseToSnakeCase: add deprecation warnings

This commit is contained in:
James Lu 2017-06-29 22:41:18 -07:00
parent 3f240bd9e8
commit 5647229c05

View File

@ -624,9 +624,12 @@ class CamelCaseToSnakeCase():
char = '_' + char.lower()
normalized_attr += char
classname = self.__class__.__name__
if normalized_attr == attr:
# __getattr__ only fires if normal attribute fetching fails, so we can assume that
# the attribute was tried already and failed.
raise AttributeError('%s object has no attribute with normalized name %r' % (self.__class__.__name__, attr))
raise AttributeError('%s object has no attribute with normalized name %r' % (classname, attr))
return getattr(self, normalized_attr)
target = getattr(self, normalized_attr)
log.warning('%s.%s is deprecated, considering migrating to %s.%s!', classname, attr, classname, normalized_attr)
return target