/usr/share/pyshared/ase/utils/deprecate.py is in python-ase 3.6.0.2515-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import warnings
class Deprecate:
def __init__(self, obj, name, newmodule, oldmodule='ase'):
self.obj = obj
self.name = name
self.newmodule = newmodule
self.oldmodule = oldmodule
def __call__(self, *args, **kwargs):
message = ('%s.%s is deprecated, use %s.%s instead' %
(self.oldmodule, self.name, self.newmodule, self.name))
warnings.warn(message, DeprecationWarning, stacklevel=2)
return self.obj(*args, **kwargs)
def _dep(method):
def _method(self, *args):
message = ('ase.%s is deprecated, use %s.%s instead' %
(self.name, self.newmodule, self.name))
warnings.warn(message, DeprecationWarning, stacklevel=2)
return method(self, *args)
return _method
class DeprecatedFloat(float):
def __new__(cls, value, name, newmodule):
return float.__new__(cls, value)
def __init__(self, value, name, newmodule):
self.name = name
self.newmodule = newmodule
__mul__ = _dep(float.__mul__)
__rmul__ = _dep(float.__rmul__)
__div__ = _dep(float.__div__)
__rdiv__ = _dep(float.__rdiv__)
class DeprecatedNumpyImport:
def __init__(self):
import numpy
self.numpy = numpy
def __getattr__(self, key):
warnings.warn('ase.np is deprecated; use import numpy as np instead')
return getattr(self.numpy, key)
|