blob: 90b03aec6121a85d64a0eeaff9dea33f718246fd [file] [log] [blame]
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This module contains stuff for reporting deprecation.
TODO(ayatane): The reason for putting this module here is so client tests can use it.
"""
import urllib
import warnings
class APIDeprecationWarning(UserWarning):
"""API deprecation warning.
This is different from DeprecationWarning. DeprecationWarning is
for Python deprecations, this class is for our deprecations.
"""
def __init__(self, deprecated_name):
"""Initialize instance.
@param deprecated_name: The name of the deprecated function or module
"""
super(APIDeprecationWarning, self).__init__(deprecated_name)
self._deprecated_name = deprecated_name
def __str__(self):
return ('(NOT AN ERROR) %s is deprecated;'
' please file a fixit bug: %s'
% (self._deprecated_name, self._get_fixit_bug_url()))
def _get_fixit_bug_url(self):
"""Return the URL for making a fixit bug."""
return ('https://bugs.chromium.org/p/chromium/issues/entry?'
+ urllib.urlencode({
'summary': 'Deprecated use of %s' % self._deprecated_name,
'description': 'Please paste the warning message below\n',
'components': 'Infra>Client>ChromeOS',
'labels': 'Pri-3,Type-Bug,Hotlist-Fixit',
}))