[elbe-devel] [PATCH 08/75] commands adjustpkgs: Fix Pylint
Olivier Dion
dion at linutronix.de
Mon May 25 17:42:01 CEST 2020
10:0: W0611: (unused-import)
21:0: R0205: (useless-object-inheritance)
Removed the class and just make set_pkgs a function.
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/commands/adjustpkgs.py | 85 ++++++++++++++++-----------------
1 file changed, 40 insertions(+), 45 deletions(-)
diff --git a/elbepack/commands/adjustpkgs.py b/elbepack/commands/adjustpkgs.py
index f6bd58db..e2640e54 100644
--- a/elbepack/commands/adjustpkgs.py
+++ b/elbepack/commands/adjustpkgs.py
@@ -7,7 +7,6 @@
from __future__ import print_function
import logging
-import os
import sys
from optparse import OptionParser
@@ -18,61 +17,57 @@ from elbepack.treeutils import etree
from elbepack.log import elbe_logging
-class adjpkg(object):
- def __init__(self, name):
- logging.info("ELBE Report for Project %s", name)
+def set_pkgs(pkglist):
- def set_pkgs(self, pkglist):
+ cache = apt.Cache()
+ cache.update()
+ cache.open(None)
- cache = apt.Cache()
- cache.update()
- cache.open(None)
-
- errors = 0
+ errors = 0
- with cache.actiongroup():
+ with cache.actiongroup():
- for p in cache:
- if not p.is_installed:
- continue
- if p.essential or \
- p.is_auto_installed or \
- p.name in pkglist or \
- p.installed.priority == "important" or \
- p.installed.priority == "required":
- continue
- logging.info("MARK REMOVE %s", p.name)
- p.mark_delete(auto_fix=False, purge=True)
+ for p in cache:
+ if not p.is_installed:
+ continue
+ if p.essential or \
+ p.is_auto_installed or \
+ p.name in pkglist or \
+ p.installed.priority == "important" or \
+ p.installed.priority == "required":
+ continue
+ logging.info("MARK REMOVE %s", p.name)
+ p.mark_delete(auto_fix=False, purge=True)
- for name in pkglist:
+ for name in pkglist:
- if name not in cache:
- logging.warning('Package "%s" does not exist', name)
- errors += 1
- continue
+ if name not in cache:
+ logging.warning('Package "%s" does not exist', name)
+ errors += 1
+ continue
- cp = cache[name]
+ cp = cache[name]
- cp.mark_install()
- logging.info("MARK INSTALL %s", cp.name)
+ cp.mark_install()
+ logging.info("MARK INSTALL %s", cp.name)
- cache.commit(apt.progress.base.AcquireProgress(),
- apt.progress.base.InstallProgress())
+ cache.commit(apt.progress.base.AcquireProgress(),
+ apt.progress.base.InstallProgress())
- cache.update()
- cache.open(None)
+ cache.update()
+ cache.open(None)
- for p in cache:
- if not p.is_installed:
- continue
- if p.is_auto_removable:
- p.mark_delete(purge=True)
- logging.info("MARKED AS AUTOREMOVE %s", p.name)
+ for p in cache:
+ if not p.is_installed:
+ continue
+ if p.is_auto_removable:
+ p.mark_delete(purge=True)
+ logging.info("MARKED AS AUTOREMOVE %s", p.name)
- cache.commit(apt.progress.base.AcquireProgress(),
- apt.progress.base.InstallProgress())
+ cache.commit(apt.progress.base.AcquireProgress(),
+ apt.progress.base.InstallProgress())
- return errors
+ return errors
def run_command(argv):
@@ -108,8 +103,8 @@ def run_command(argv):
with elbe_logging({"files":opt.output}):
- adj = adjpkg(opt.name)
- return adj.set_pkgs(xml_pkgs + buildenv_pkgs)
+ logging.info("ELBE Report for Project %s", opt.name)
+ return set_pkgs(xml_pkgs + buildenv_pkgs)
if __name__ == "__main__":
--
2.26.2
More information about the elbe-devel
mailing list