add over.core.aux.DeprecationForwarder

add deprecation warning for over.core.textui
This commit is contained in:
Martinez 2015-06-08 16:34:44 +02:00
parent 57f4315c9a
commit 660bae4bf0
2 changed files with 12 additions and 1 deletions

View file

@ -7,10 +7,11 @@ from . import cmd
from . import file
from . import misc
from . import text
textui = text
try:
from . import cython_types as types
except:
aux._print('unable to load C implementation, using python instead', text.prefix.warn)
from . import python_types as types
textui = aux.DeprecationForwarder(text, 'over.core.textui', 'over.core.text')

View file

@ -6,3 +6,13 @@ import sys
from . import text
_print = text.Output('over.core', stream=sys.stderr)
class DeprecationForwarder:
def __init__(self, target, old_name, new_name):
self.target = target
self.old_name = old_name
self.new_name = new_name
def __getattr__(self, name):
_print('%s is deprecated, please use %s instead' %(self.old_name, self.new_name), text.prefix.warn)
return getattr(self.target, name)