public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: [KVM-AUTOTEST PATCH 3/5] kvm_config: store filename on configreader
Date: Thu,  6 Jan 2011 14:12:34 -0200	[thread overview]
Message-ID: <1294330356-17043-4-git-send-email-ehabkost@redhat.com> (raw)
In-Reply-To: <1294330356-17043-1-git-send-email-ehabkost@redhat.com>

From: Eduardo Habkost <ehabkost@raisama.net>

It will be useful to generate better error messages.

Signed-off-by: Eduardo Habkost <ehabkost@raisama.net>
---
 client/tests/kvm/kvm_config.py |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py
index 5be2e66..35e2ab9 100755
--- a/client/tests/kvm/kvm_config.py
+++ b/client/tests/kvm/kvm_config.py
@@ -48,7 +48,7 @@ class config:
             raise IOError("File %s not found" % filename)
         self.filename = filename
         str = open(filename).read()
-        self.list = self.parse(configreader(str), self.list)
+        self.list = self.parse(configreader(filename, str), self.list)
 
 
     def parse_string(self, str):
@@ -57,7 +57,7 @@ class config:
 
         @param str: String to parse.
         """
-        self.list = self.parse(configreader(str), self.list)
+        self.list = self.parse(configreader('<string>', str), self.list)
 
 
     def fork_and_parse(self, filename=None, str=None):
@@ -342,7 +342,7 @@ class config:
                                             words[1])
                     if os.path.exists(filename):
                         str = open(filename).read()
-                        list = self.parse(configreader(str), list, restricted)
+                        list = self.parse(configreader(filename, str), list, restricted)
                         if self.debug and not restricted:
                             _debug_print("", "Leaving file %s" % words[1])
                     else:
@@ -539,12 +539,13 @@ class configreader:
     whose readline() and/or seek() methods seem to be slow.
     """
 
-    def __init__(self, str):
+    def __init__(self, filename, str):
         """
         Initialize the reader.
 
         @param str: The string to parse.
         """
+        self.filename = filename
         self.line_index = 0
         self.lines = []
         for line in str.splitlines():
-- 
1.7.3.2

  parent reply	other threads:[~2011-01-06 16:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-06 16:12 [KVM-AUTOTEST PATCH 0/5] small kvm_config usability changes Eduardo Habkost
2011-01-06 16:12 ` [KVM-AUTOTEST PATCH 1/5] kvm_config: accept multiple filenames as argument Eduardo Habkost
2011-01-06 16:12 ` [KVM-AUTOTEST PATCH 2/5] kvm_config: print directly to stdout instead of using logging Eduardo Habkost
2011-01-06 16:12 ` Eduardo Habkost [this message]
2011-01-06 16:12 ` [KVM-AUTOTEST PATCH 4/5] kvm_config: add helper to raise exception informing line number Eduardo Habkost
2011-01-11  3:48   ` Lucas Meneghel Rodrigues
2011-01-11 12:52     ` Eduardo Habkost
2011-01-06 16:12 ` [KVM-AUTOTEST PATCH 5/5] kvm_config: inform filename and line number on error message Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294330356-17043-4-git-send-email-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox