Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 2/3] portage/sync/syncbase.py: Change has_bin to an @property function
Date: Thu, 29 Jan 2015 19:45:55
Message-Id: 1422560721-28354-3-git-send-email-dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] portage sync changes, fixes by Brian Dolbec
1 This avoids that self.logger is None error in the __init__().
2 ---
3 pym/portage/sync/syncbase.py | 24 +++++++++++++++---------
4 1 file changed, 15 insertions(+), 9 deletions(-)
5
6 diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py
7 index c820bcf..973d545 100644
8 --- a/pym/portage/sync/syncbase.py
9 +++ b/pym/portage/sync/syncbase.py
10 @@ -35,17 +35,23 @@ class SyncBase(object):
11 self.xterm_titles = None
12 self.spawn_kwargs = None
13 self.bin_command = None
14 - self.has_bin = False
15 + self._bin_command = bin_command
16 + self.bin_pkg = bin_pkg
17 if bin_command:
18 self.bin_command = portage.process.find_binary(bin_command)
19 - if self.bin_command is None:
20 - msg = ["Command not found: %s" % bin_command,
21 - "Type \"emerge %s\" to enable %s support." % (bin_pkg, bin_command)]
22 - for l in msg:
23 - writemsg_level("!!! %s\n" % l,
24 - level=self.logger.ERROR, noiselevel=-1)
25 - else:
26 - self.has_bin = True
27 +
28 +
29 + @property
30 + def has_bin(self):
31 + if self.bin_command is None:
32 + msg = ["Command not found: %s" % self._bin_command,
33 + "Type \"emerge %s\" to enable %s support."
34 + % (self.bin_pkg, self._bin_command)]
35 + for l in msg:
36 + writemsg_level("!!! %s\n" % l,
37 + level=self.logger.ERROR, noiselevel=-1)
38 + return False
39 + return True
40
41
42 def _kwargs(self, kwargs):
43 --
44 2.2.2

Replies