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 94EBF138247 for ; Mon, 13 Jan 2014 06:15:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 356E7E0A70; Mon, 13 Jan 2014 06:15:06 +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 85C32E0A6E for ; Mon, 13 Jan 2014 06:15:05 +0000 (UTC) Received: from [192.168.1.7] (c-67-170-82-28.hsd1.wa.comcast.net [67.170.82.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: nullishzero) by smtp.gentoo.org (Postfix) with ESMTPSA id A44AE33F708 for ; Mon, 13 Jan 2014 06:15:04 +0000 (UTC) Message-ID: <52D38462.9080901@gentoo.org> Date: Sun, 12 Jan 2014 22:14:58 -0800 From: Pavel Kazakov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 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 MIME-Version: 1.0 To: gentoo-portage-dev@lists.gentoo.org Subject: Re: [gentoo-portage-dev] [PATCH] [REV] Added support for variable expansion in source command. wrt bug #490896 References: In-Reply-To: X-Enigmail-Version: 1.6 Content-Type: multipart/mixed; boundary="------------040601070106010606030008" X-Archives-Salt: 376a652f-b871-42d8-bc4b-11f490880de4 X-Archives-Hash: 3c19877b131755d6221168b774c02cfc This is a multi-part message in MIME format. --------------040601070106010606030008 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/12/2014 03:57 PM, Jesus Rivero (Neurogeek) wrote: > Hi all, > > In the previous patch, I didn't notice an error in the unittest I wrote for the feature. > Attached is the correct patch, please disregard the previous one. > > Cheers, > > Jesus Rivero Neurogeek, Looks like we were working on the same patch, but I guess the patch is a good exercise in getting familiar with the portage code :P Overall it looks good. There were some complaints from git apply about trivial spacing issues (trailing whitespace), and there's a space included in indentation that causes python 3.3 to fail: 0002-Added-support-for-variable-expansion-in-source-commandd.patch:61: space before tab in indent. I'm not sure if it matters, but your code seems to do variable expansion for the source command even if the 'expand' variable in the getconfig() function is set to False (unless I'm wrong?). All, Although neurogeek already sent a patch, I figured I'd include mine as well at the request of dol-sen :) This patch does not include unit tests since it's meant to be more of a review against neurogeek's code. Regards, Pavel -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJS04RiAAoJENb1ecI556suiyYP/1X+CXK+WFoURBPUOlOyw9bN jKYg5My7wcz07VnWrIkPiuQf3Pq3bj2ckMc54kiL59bMWQgMXjtZMJzyzfegza/t Ks22+RYxmwdwU9OJ9prknFMLXdibEqT4zBk0MxHHfNeHqJtDM7j2Nc3Xcj+jP93R zRFzFLjWjOeT4kCzUvmnEewjd9WlhycAhXB/MMoEQM/stAROv9sai7RhF+6EpXsE XRP3ZagCdni5YA/Gz+eWZ59rihgo/8X1RLMzoK3MmPmh+LEi1Eop8NaHeTT4FumP 4ftr4mtc84qUpeo+pzzgi40Dse08oaHXCu5IX5lkVh0/Uu2vvVieTORGpLtDv9Mk sK2qCZJ9JQU8l3pE2tRVkZ935IN/DxDoUCt5EosOB5OQ3UG6RkIP+hqNmcpkA6wC OENrV5LCkAGzyuUNOCgqy4sL/rHWpSD+DqToc54vsnWTdkBCYO31AtwSKQ1xkihK gp3Re+7Z6dA6KhjF5ZM6LOd5KyH6gbEH2EqtEuWeNiaeBB+5eYJuhLiqVOrmfgkl nnatebh2DQum52OFDX4Q2M+6Cp0OHuYHUL0HxHcPRzmTnqBkwJtTxFoe2v3nQr5U cTTrkM8t0TD7/CqHTo0JQQBleIEQGaI3jzHBaOS1DWxU4ZXaTbBrq8gng3H7RVW/ 3mbx448SfEyeNGFiZqzE =g+z5 -----END PGP SIGNATURE----- --------------040601070106010606030008 Content-Type: text/x-patch; name="0001-Add-support-for-source-variable-expansion-bug-490896.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Add-support-for-source-variable-expansion-bug-490896.pa"; filename*1="tch" >From 59f30b1901227031531d196bd0dcf59990c68ec3 Mon Sep 17 00:00:00 2001 From: Pavel Kazakov Date: Sun, 12 Jan 2014 21:52:03 -0800 Subject: [PATCH] Add support for source variable expansion, bug #490896 --- pym/portage/util/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py index 24553da..555ac76 100644 --- a/pym/portage/util/__init__.py +++ b/pym/portage/util/__init__.py @@ -592,9 +592,12 @@ class _getconfig_shlex(shlex.shlex): def __init__(self, portage_tolerant=False, **kwargs): shlex.shlex.__init__(self, **kwargs) self.__portage_tolerant = portage_tolerant + self.expand_map = None def sourcehook(self, newfile): try: + if self.expand_map is not None: + newfile = varexpand(newfile, self.expand_map) return shlex.shlex.sourcehook(self, newfile) except EnvironmentError as e: if e.errno == PermissionDenied.errno: @@ -695,6 +698,8 @@ def getconfig(mycfg, tolerant=False, allow_sourcing=False, expand=True, lex.quotes = portage._native_string("\"'") if allow_sourcing: lex.source = portage._native_string("source") + if expand: + lex.expand_map = expand_map while True: key = _unicode_decode(lex.get_token()) -- 1.8.3.2 --------------040601070106010606030008--