Revert "Enhance versionutils.deprecated to work with classes"

This reverts commit f72d7ea1a0.

* The reverted change being merged into oslo-incubator upstream
* Also, change icehouse -> juno

Change-Id: Ie12fcef5777ae724bf687ca1ad064aef6670f097
This commit is contained in:
Ekaterina Fedorova 2014-08-29 17:59:45 +04:00 committed by Ekaterina Chernova
parent 54c9bb389d
commit 5884076af6
3 changed files with 5 additions and 57 deletions

View File

@ -14,12 +14,6 @@
import string
from openstack_dashboard.openstack.common import log
from muranodashboard.openstack.common import versionutils
LOG = log.getLogger(__name__)
def ensure_python_obj(obj):
mappings = {'True': True, 'False': False, 'None': None}
@ -60,31 +54,3 @@ class BlankFormatter(string.Formatter):
return kwargs.get(key, self.default)
else:
return string.Formatter.get_value(self, key, args, kwargs)
class deprecated(versionutils.deprecated):
"""A decorator to mark both functions and classes as deprecated."""
JUNO = 'J'
_RELEASES = {
'F': 'Folsom',
'G': 'Grizzly',
'H': 'Havana',
'I': 'Icehouse',
'J': 'Juno'
}
def __call__(self, func_or_cls):
if hasattr(func_or_cls, 'func_code'):
return super(deprecated, self).__call__(func_or_cls)
else:
if not self.what:
self.what = func_or_cls.__name__ + '()'
msg, details = self._build_message()
class cls(func_or_cls):
def __init__(self, *args, **kwargs):
LOG.deprecated(msg, details)
super(cls, self).__init__(*args, **kwargs)
return cls

View File

@ -36,8 +36,8 @@ import yaql
from muranoclient.common import exceptions as muranoclient_exc
from muranodashboard.api import packages as pkg_api
from muranodashboard.common import utils
from muranodashboard.environments import api as env_api
from muranodashboard.openstack.common import versionutils
LOG = logging.getLogger(__name__)
@ -557,8 +557,8 @@ class BooleanField(forms.BooleanField, CustomPropertiesField):
super(BooleanField, self).__init__(*args, **kwargs)
@utils.deprecated(
as_of=utils.deprecated.JUNO,
@versionutils.deprecated(
as_of=versionutils.deprecated.JUNO,
in_favor_of='type boolean (regular BooleanField)',
remove_in=1)
class FloatingIpBooleanField(BooleanField):
@ -716,8 +716,8 @@ def make_select_cls(fqns):
return DynamicSelect
@utils.deprecated(
as_of=utils.deprecated.JUNO,
@versionutils.deprecated(
as_of=versionutils.deprecated.JUNO,
in_favor_of='type io.murano.windows.ActiveDirectory with a custom '
'emptyValueMessage attribute',
remove_in=1)

View File

@ -14,8 +14,6 @@
import testtools
import mock
from muranodashboard.common import utils
@ -69,19 +67,3 @@ class BunchTests(testtools.TestCase):
del obj['two']
self.assertNotIn('two', obj)
class DeprecatedDecoratorTests(testtools.TestCase):
@mock.patch('muranodashboard.common.utils.LOG')
def test_decorating_class(self, LOG):
dec = utils.deprecated(utils.deprecated.JUNO,
in_favor_of='some class yet to be designed',
remove_in=1)
@dec
class SampleClass(object):
pass
SampleClass()
self.assertEqual(type, SampleClass.__class__)
LOG.deprecated.assert_called_once_with(*dec._build_message())