diff options
| author | Julian Andres Klode <jak@debian.org> | 2010-03-03 16:25:30 +0100 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2010-03-03 16:25:30 +0100 |
| commit | 8cb1f8fb9968d91f8f1bbece3f93aaeda36f0801 (patch) | |
| tree | 11c55bcfbdc2772d0720c923e7028159f50e62b7 | |
| parent | a5f0b3a05f85e5c24d0cbc6f5cfd3834346e79aa (diff) | |
| download | python-apt-8cb1f8fb9968d91f8f1bbece3f93aaeda36f0801.tar.gz | |
* apt/progress/old.py:
- Let the new method call the old one; e.g. status_update() now calls
self.statusUpdate(). This improves compatibility for sub classes.
| -rw-r--r-- | apt/progress/old.py | 89 | ||||
| -rw-r--r-- | debian/changelog | 3 |
2 files changed, 67 insertions, 25 deletions
diff --git a/apt/progress/old.py b/apt/progress/old.py index c64eee57..0d75b756 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -40,6 +40,10 @@ __all__ = [] class OpProgress(base.OpProgress): """Abstract class to implement reporting on cache opening.""" + def __init__(self): + warnings.warn("apt.progress.OpProgress is deprecated.", + DeprecationWarning, stacklevel=2) + subOp = AttributeDeprecatedBy('subop') Op = AttributeDeprecatedBy('op') @@ -47,6 +51,11 @@ class OpProgress(base.OpProgress): class OpTextProgress(OpProgress, text.OpProgress): """A simple text based cache open reporting class.""" + def __init__(self): + text.OpProgress.__init__(self) + warnings.warn("apt.progress.OpTextProgress is deprecated.", + DeprecationWarning, stacklevel=2) + class FetchProgress(object): """Report the download/fetching progress.""" @@ -65,7 +74,8 @@ class FetchProgress(object): self.totalBytes = 0 self.totalItems = 0 self.currentCPS = 0 - warnings.warn("FetchProgress() is deprecated.", DeprecationWarning) + warnings.warn("apt.progress.FetchProgress is deprecated.", + DeprecationWarning, stacklevel=2) def start(self): """Called when the fetching starts.""" @@ -160,27 +170,54 @@ class TextFetchProgress(FetchProgress): return raw_input() not in ('c', 'C') -class CdromProgress(base.CdromProgress): - """Report the cdrom add progress. +class CdromProgress(object): + """Report the cdrom add progress.""" - This class has been replaced by apt_pkg.CdromProgress. - """ - _basetype = base.CdromProgress - askCdromName = function_deprecated_by(_basetype.ask_cdrom_name) - changeCdrom = function_deprecated_by(_basetype.change_cdrom) - del _basetype + def __init__(self): + warnings.warn("apt.progress.CdromProgress is deprecated.", + DeprecationWarning, stacklevel=2) + + def askCdromName(self): + """Ask for a cdrom name""" + + def changeCdrom(self): + """Change cdrom""" + + def update(self, text, current): + """Update.""" class DumbInstallProgress(base.InstallProgress): - """Report the install progress. + """Report the install progress.""" - Subclass this class to implement install progress reporting. - """ + def __init__(self): + warnings.warn("apt.progress.*InstallProgress are deprecated.", + DeprecationWarning, stacklevel=2) + + def updateInterface(self): + # *_stream were not available in the old progress reporting classes, + # create the attributes if they do not exist yet; as they are used + # in base.InstallProgress.update_interface(). + if hasattr(self, "writefd") and not hasattr(self, "write_stream"): + self.write_stream = os.fdopen(self.writefd, "w") + if hasattr(self, "statusfd") and not hasattr(self, "status_stream"): + self.status_stream = os.fdopen(self.statusfd, "r") + base.InstallProgress.update_interface(self) + + def update_interface(self): + self.updateInterface() + + def startUpdate(self): + base.InstallProgress.start_update(self) + + def start_update(self): + self.startUpdate() - startUpdate = function_deprecated_by(base.InstallProgress.start_update) - finishUpdate = function_deprecated_by(base.InstallProgress.finish_update) - updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) + def finishUpdate(self): + base.InstallProgress.finish_update(self) + + def finish_update(self): + self.finishUpdate() class InstallProgress(DumbInstallProgress, base.InstallProgress): @@ -191,16 +228,18 @@ class InstallProgress(DumbInstallProgress, base.InstallProgress): """ selectTimeout = AttributeDeprecatedBy('select_timeout') - statusChange = function_deprecated_by(base.InstallProgress.status_change) - updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) - waitChild = function_deprecated_by(base.InstallProgress.wait_child) + + def statusChange(self, pkg, percent, status): + base.InstallProgress.status_change(self, pkg, percent, status) def status_change(self, pkg, percent, status): - """(Abstract) Called when the APT status changed.""" - # compat with 0.7 - if apt_pkg._COMPAT_0_7 and hasattr(self, "statusChange"): - self.statusChange(pkg, percent, status) + self.statusChange(pkg, percent, status) + + def waitChild(self): + base.InstallProgress.wait_child(self) + + def wait_child(self): + self.waitChild() class DpkgInstallProgress(InstallProgress): @@ -214,4 +253,4 @@ class DpkgInstallProgress(InstallProgress): # Deprecated stuff self.debfile = debfile self.debname = os.path.basename(debfile).split("_")[0] - return base.InstallProgress(self, debfile) + return base.InstallProgress.run(self, debfile) diff --git a/debian/changelog b/debian/changelog index 30a1182a..79b3d810 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ python-apt (0.7.93.4) unstable; urgency=low source version is not specified (i.e. in the normal case). * apt/progress/text.py: - Drop InstallProgress, it's useless to keep this alias around. + * apt/progress/old.py: + - Let the new method call the old one; e.g. status_update() now calls + self.statusUpdate(). This improves compatibility for sub classes. -- Julian Andres Klode <jak@debian.org> Mon, 01 Mar 2010 16:13:22 +0100 |
