diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-01 17:14:30 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-06-01 17:14:30 +0200 |
| commit | 015acac98dc88fbbca5672c6be678c8dea491a8e (patch) | |
| tree | ea4c6b4a385aa25d96746886589f2928e58891af /apt | |
| parent | e74ead9f918b38bfe8ae5cfe941df4057dcc509e (diff) | |
| download | python-apt-015acac98dc88fbbca5672c6be678c8dea491a8e.tar.gz | |
revert commit 346 (this re-enable the deprecation warnings)
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/__init__.py | 5 | ||||
| -rw-r--r-- | apt/deprecation.py | 13 | ||||
| -rw-r--r-- | apt/package.py | 2 | ||||
| -rw-r--r-- | apt/progress/old.py | 25 |
4 files changed, 20 insertions, 25 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index a8a8b8fc..8b66ad13 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -17,6 +17,11 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA +import os +import warnings +if not "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: + warnings.simplefilter('ignore', DeprecationWarning) + # import the core of apt_pkg """High-Level Interface for working with apt.""" import apt_pkg diff --git a/apt/deprecation.py b/apt/deprecation.py index cd33a51b..0f39ad63 100644 --- a/apt/deprecation.py +++ b/apt/deprecation.py @@ -24,7 +24,6 @@ not use it for anything outside the apt package. """ import re import operator -import os import warnings import apt_pkg @@ -50,14 +49,12 @@ class AttributeDeprecatedBy(object): """Issue a DeprecationWarning and return the requested value.""" if obj is None: return getattr(type_, self.attribute, self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) return self.getter(obj or type_) def __set__(self, obj, value): """Issue a DeprecationWarning and set the requested value.""" - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) + warnings.warn(self.__doc__, DeprecationWarning, stacklevel=2) setattr(obj, self.attribute, value) @@ -74,8 +71,7 @@ def function_deprecated_by(func, convert_names=True): def deprecated_function(*args, **kwds): """Wrapper around a deprecated function.""" - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn(warning, DeprecationWarning, stacklevel=2) + warnings.warn(warning, DeprecationWarning, stacklevel=2) if convert_names: for key in kwds.keys(): kwds[re.sub('([A-Z])', '_\\1', key).lower()] = kwds.pop(key) @@ -97,8 +93,7 @@ def deprecated_args(func): for key in kwds.keys(): new_key = re.sub('([A-Z])', '_\\1', key).lower() if new_key != key: - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("Deprecated parameter %r" % key) + warnings.warn("Deprecated parameter %r" % key) kwds[new_key] = kwds.pop(key) return func(*args, **kwds) diff --git a/apt/package.py b/apt/package.py index 7dcead02..228a3385 100644 --- a/apt/package.py +++ b/apt/package.py @@ -120,7 +120,7 @@ class DeprecatedProperty(property): self.__doc__ = (doc or fget.__doc__ or '') def __get__(self, obj, type_=None): - if obj is not None and "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: + if obj is not None: warnings.warn("Accessed deprecated property %s.%s, please see the " "Version class for alternatives." % ((obj.__class__.__name__ or type_.__name__), diff --git a/apt/progress/old.py b/apt/progress/old.py index 2d3fdb59..4bd79f2e 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -42,9 +42,8 @@ class OpProgress(base.OpProgress): def __init__(self): base.OpProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.OpProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.OpProgress is deprecated.", + DeprecationWarning, stacklevel=2) subOp = AttributeDeprecatedBy('subop') Op = AttributeDeprecatedBy('op') @@ -55,9 +54,8 @@ class OpTextProgress(OpProgress, text.OpProgress): def __init__(self): text.OpProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.OpTextProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.OpTextProgress is deprecated.", + DeprecationWarning, stacklevel=2) class FetchProgress(object): @@ -77,9 +75,8 @@ class FetchProgress(object): self.totalBytes = 0 self.totalItems = 0 self.currentCPS = 0 - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.FetchProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.FetchProgress is deprecated.", + DeprecationWarning, stacklevel=2) def start(self): """Called when the fetching starts.""" @@ -178,9 +175,8 @@ class CdromProgress(object): """Report the cdrom add progress.""" def __init__(self): - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.CdromProgress is deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.CdromProgress is deprecated.", + DeprecationWarning, stacklevel=2) def askCdromName(self): """Ask for a cdrom name""" @@ -197,9 +193,8 @@ class DumbInstallProgress(base.InstallProgress): def __init__(self): base.InstallProgress.__init__(self) - if "PYTHON_APT_DEPRECATION_WARNINGS" in os.environ: - warnings.warn("apt.progress.*InstallProgress are deprecated.", - DeprecationWarning, stacklevel=2) + warnings.warn("apt.progress.*InstallProgress are deprecated.", + DeprecationWarning, stacklevel=2) def updateInterface(self): # *_stream were not available in the old progress reporting classes, |
