From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id C6FE6138A1A for ; Thu, 29 Jan 2015 19:45:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 43057E08A5; Thu, 29 Jan 2015 19:45:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 6048BE08A2 for ; Thu, 29 Jan 2015 19:45:49 +0000 (UTC) Received: from big_daddy.dol-sen.ca (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id 94620340781 for ; Thu, 29 Jan 2015 19:45:48 +0000 (UTC) From: Brian Dolbec To: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-portage-dev] [PATCH 2/3] portage/sync/syncbase.py: Change has_bin to an @property function Date: Thu, 29 Jan 2015 11:45:20 -0800 Message-Id: <1422560721-28354-3-git-send-email-dolsen@gentoo.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422560721-28354-1-git-send-email-dolsen@gentoo.org> References: <1422560721-28354-1-git-send-email-dolsen@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: e5042141-607c-4cbf-915a-5712ca99e997 X-Archives-Hash: b2024c81b617670be2afe97e2d558de2 This avoids that self.logger is None error in the __init__(). --- pym/portage/sync/syncbase.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py index c820bcf..973d545 100644 --- a/pym/portage/sync/syncbase.py +++ b/pym/portage/sync/syncbase.py @@ -35,17 +35,23 @@ class SyncBase(object): self.xterm_titles = None self.spawn_kwargs = None self.bin_command = None - self.has_bin = False + self._bin_command = bin_command + self.bin_pkg = bin_pkg if bin_command: self.bin_command = portage.process.find_binary(bin_command) - if self.bin_command is None: - msg = ["Command not found: %s" % bin_command, - "Type \"emerge %s\" to enable %s support." % (bin_pkg, bin_command)] - for l in msg: - writemsg_level("!!! %s\n" % l, - level=self.logger.ERROR, noiselevel=-1) - else: - self.has_bin = True + + + @property + def has_bin(self): + if self.bin_command is None: + msg = ["Command not found: %s" % self._bin_command, + "Type \"emerge %s\" to enable %s support." + % (self.bin_pkg, self._bin_command)] + for l in msg: + writemsg_level("!!! %s\n" % l, + level=self.logger.ERROR, noiselevel=-1) + return False + return True def _kwargs(self, kwargs): -- 2.2.2