[elbe-devel] [PATCH 5/6] Remove filtering a deprecation warning

bage at linutronix.de bage at linutronix.de
Fri Aug 30 12:58:29 CEST 2019


From: Bastian Germann <bage at linutronix.de>

The newer function is now used, so the filtering of the deprecation warning
is not in use anymore.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/dump.py        |  9 +++------
 elbepack/rpcaptcache.py | 43 +++++++++++++----------------------------
 2 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/elbepack/dump.py b/elbepack/dump.py
index d73b3789..b9de6c0e 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -5,7 +5,6 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-import warnings
 from datetime import datetime
 
 from apt import Cache
@@ -18,11 +17,9 @@ from elbepack.aptpkgutils import APTPackage
 
 
 def get_initvm_pkglist():
-    with warnings.catch_warnings():
-        warnings.filterwarnings("ignore", category=DeprecationWarning)
-        cache = Cache()
-        cache.open()
-        pkglist = [APTPackage(p) for p in cache if p.is_installed]
+    cache = Cache()
+    cache.open()
+    pkglist = [APTPackage(p) for p in cache if p.is_installed]
 
     return pkglist
 
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index 71358767..eeafad48 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -9,7 +9,6 @@
 import os
 import sys
 import time
-import warnings
 
 from multiprocessing.util import Finalize
 from multiprocessing.managers import BaseManager
@@ -185,16 +184,12 @@ class RPCAPTCache(InChRootObject):
         return [APTPackage(p, cache=self.cache) for p in deps]
 
     def get_installed_pkgs(self, section='all'):
-        # avoid DeprecationWarning: MD5Hash is deprecated, use Hashes instead
-        # triggerd by python-apt
-        with warnings.catch_warnings():
-            warnings.filterwarnings("ignore", category=DeprecationWarning)
-            if section == 'all':
-                pl = [APTPackage(p) for p in self.cache if p.is_installed]
-            else:
-                pl = [APTPackage(p) for p in self.cache if (
-                    p.section == section and p.is_installed)]
-            return pl
+        if section == 'all':
+            pl = [APTPackage(p) for p in self.cache if p.is_installed]
+        else:
+            pl = [APTPackage(p) for p in self.cache if (
+                p.section == section and p.is_installed)]
+        return pl
 
     def get_fileindex(self):
         index = {}
@@ -255,15 +250,9 @@ class RPCAPTCache(InChRootObject):
             pkgver = p.installed
         else:
             pkgver = p.versions[version]
-        # avoid DeprecationWarning:
-        # "MD5Hash is deprecated, use Hashes instead"
-        # triggerd by python-apt
-        with warnings.catch_warnings():
-            warnings.filterwarnings("ignore",
-                                    category=DeprecationWarning)
-            rel_filename = pkgver.fetch_binary(path,
-                                               ElbeAcquireProgress())
-            return self.rfs.fname(rel_filename)
+        rel_filename = pkgver.fetch_binary(path,
+                                           ElbeAcquireProgress())
+        return self.rfs.fname(rel_filename)
 
     def download_source(self, pkgname, path, version=None):
         p = self.cache[pkgname]
@@ -272,16 +261,10 @@ class RPCAPTCache(InChRootObject):
         else:
             pkgver = p.versions[version]
 
-        # avoid DeprecationWarning:
-        # "MD5Hash is deprecated, use Hashes instead"
-        # triggerd by python-apt
-        with warnings.catch_warnings():
-            warnings.filterwarnings("ignore",
-                                    category=DeprecationWarning)
-            rel_filename = pkgver.fetch_source(path,
-                                               ElbeAcquireProgress(),
-                                               unpack=False)
-            return self.rfs.fname(rel_filename)
+        rel_filename = pkgver.fetch_source(path,
+                                           ElbeAcquireProgress(),
+                                           unpack=False)
+        return self.rfs.fname(rel_filename)
 
 
 class MyMan(BaseManager):
-- 
2.20.1




More information about the elbe-devel mailing list