From: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/4] KVM test: kvm_config.py: allow 'include' when parsing strings Date: Thu, 17 Feb 2011 19:51:47 +0200 Message-ID: <1297965109-14293-2-git-send-email-mgoldish@redhat.com> References: <1297965109-14293-1-git-send-email-mgoldish@redhat.com> Cc: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56217 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750963Ab1BQRvh (ORCPT ); Thu, 17 Feb 2011 12:51:37 -0500 In-Reply-To: <1297965109-14293-1-git-send-email-mgoldish@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Currently 'include' is only allowed when parsing a file. This patch allows it to be used when parsing a string as well. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_config.py | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index cab0022..27c3171 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -441,11 +441,10 @@ class Parser(object): if len(words) < 2: raise ParserError("Syntax error: missing parameter", line, cr.filename, linenum) - if not isinstance(cr, FileReader): - raise ParserError("Cannot include because no file is " - "currently open", - line, cr.filename, linenum) - filename = os.path.join(os.path.dirname(cr.filename), words[1]) + filename = os.path.expanduser(words[1]) + if isinstance(cr, FileReader) and not os.path.isabs(filename): + filename = os.path.join(os.path.dirname(cr.filename), + filename) if not os.path.isfile(filename): self._warn("%r (%s:%s): file doesn't exist or is not a " "regular file", line, cr.filename, linenum) -- 1.7.3.4