Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/emaint/modules/logs/
Date: Sun, 26 Feb 2017 20:12:25
Message-Id: 1488139670.fe5154cbe5300ac7f20bc6bba57dca14e6114d02.zmedico@gentoo
1 commit: fe5154cbe5300ac7f20bc6bba57dca14e6114d02
2 Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 27 23:02:28 2017 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 26 20:07:50 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fe5154cb
7
8 emaint logs: remove excessive kwargs tests
9
10 Testing kwargs not being empty just makes code look more
11 complicated than necessary.
12
13 pym/portage/emaint/modules/logs/logs.py | 26 ++++++++++++--------------
14 1 file changed, 12 insertions(+), 14 deletions(-)
15
16 diff --git a/pym/portage/emaint/modules/logs/logs.py b/pym/portage/emaint/modules/logs/logs.py
17 index 631aeefe0..dfe0ef0a4 100644
18 --- a/pym/portage/emaint/modules/logs/logs.py
19 +++ b/pym/portage/emaint/modules/logs/logs.py
20 @@ -28,10 +28,9 @@ class CleanLogs(object):
21
22
23 def check(self, **kwargs):
24 - if kwargs:
25 - options = kwargs.get('options', None)
26 - if options:
27 - options['pretend'] = True
28 + options = kwargs.get('options', None)
29 + if options:
30 + options['pretend'] = True
31 return self.clean(**kwargs)
32
33
34 @@ -48,16 +47,15 @@ class CleanLogs(object):
35 """
36 num_of_days = None
37 pretend = False
38 - if kwargs:
39 - # convuluted, I know, but portage.settings does not exist in
40 - # kwargs.get() when called from _emerge.main.clean_logs()
41 - settings = kwargs.get('settings', None)
42 - if not settings:
43 - settings = portage.settings
44 - options = kwargs.get('options', None)
45 - if options:
46 - num_of_days = options.get('NUM', None)
47 - pretend = options.get('pretend', False)
48 +
49 + # convoluted, I know, but portage.settings does not exist in
50 + # kwargs.get() when called from _emerge.main.clean_logs()
51 + settings = kwargs.get('settings', getattr(portage, 'settings', {}))
52 +
53 + options = kwargs.get('options', None)
54 + if options:
55 + num_of_days = options.get('NUM', None)
56 + pretend = options.get('pretend', False)
57
58 clean_cmd = settings.get("PORT_LOGDIR_CLEAN")
59 if clean_cmd: