[elbe-devel] [PATCH 08/75] commands adjustpkgs: Fix Pylint
Torben Hohn
torben.hohn at linutronix.de
Fri May 29 10:52:13 CEST 2020
On Mon, May 25, 2020 at 11:42:01AM -0400, Olivier Dion wrote:
> 10:0: W0611: (unused-import)
> 21:0: R0205: (useless-object-inheritance)
i am not sure, if we dont want to disable this one until
we have py2 removed.
however, it seems, like it pointed you to this problem.
>
> Removed the class and just make set_pkgs a function.
>
> Signed-off-by: Olivier Dion <dion at linutronix.de>
Reviewed-by: Torben Hohn <torben.hohn 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
>
>
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
More information about the elbe-devel
mailing list