qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com
Subject: [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to ._parser, ._section
Date: Mon,  2 Oct 2017 16:13:40 +0200	[thread overview]
Message-ID: <20171002141341.24616-11-armbru@redhat.com> (raw)
In-Reply-To: <20171002141341.24616-1-armbru@redhat.com>

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 52 ++++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index e338868a52..43a54bf40f 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -120,11 +120,11 @@ class QAPIDoc(object):
             self.member = member
 
     def __init__(self, parser, info):
-        # self.parser is used to report errors with QAPIParseError.  The
+        # self._parser is used to report errors with QAPIParseError.  The
         # resulting error position depends on the state of the parser.
         # It happens to be the beginning of the comment.  More or less
         # servicable, but action at a distance.
-        self.parser = parser
+        self._parser = parser
         self.info = info
         self.symbol = None
         self.body = QAPIDoc.Section()
@@ -133,7 +133,7 @@ class QAPIDoc(object):
         # a list of Section
         self.sections = []
         # the current section
-        self.section = self.body
+        self._section = self.body
 
     def has_section(self, name):
         """Return True if we have a section with this name."""
@@ -150,7 +150,7 @@ class QAPIDoc(object):
             return
 
         if line[0] != ' ':
-            raise QAPIParseError(self.parser, "Missing space after #")
+            raise QAPIParseError(self._parser, "Missing space after #")
         line = line[1:]
 
         # FIXME not nice: things like '#  @foo:' and '# @foo: ' aren't
@@ -159,11 +159,11 @@ class QAPIDoc(object):
             self._append_symbol_line(line)
         elif not self.body.text and line.startswith('@'):
             if not line.endswith(':'):
-                raise QAPIParseError(self.parser, "Line should end with :")
+                raise QAPIParseError(self._parser, "Line should end with :")
             self.symbol = line[1:-1]
             # FIXME invalid names other than the empty string aren't flagged
             if not self.symbol:
-                raise QAPIParseError(self.parser, "Invalid name")
+                raise QAPIParseError(self._parser, "Invalid name")
         else:
             self._append_freeform(line)
 
@@ -189,48 +189,48 @@ class QAPIDoc(object):
     def _start_args_section(self, name):
         # FIXME invalid names other than the empty string aren't flagged
         if not name:
-            raise QAPIParseError(self.parser, "Invalid parameter name")
+            raise QAPIParseError(self._parser, "Invalid parameter name")
         if name in self.args:
-            raise QAPIParseError(self.parser,
+            raise QAPIParseError(self._parser,
                                  "'%s' parameter name duplicated" % name)
         if self.sections:
-            raise QAPIParseError(self.parser,
+            raise QAPIParseError(self._parser,
                                  "'@%s:' can't follow '%s' section"
                                  % (name, self.sections[0].name))
         self._end_section()
-        self.section = QAPIDoc.ArgSection(name)
-        self.args[name] = self.section
+        self._section = QAPIDoc.ArgSection(name)
+        self.args[name] = self._section
 
     def _start_section(self, name=None):
         if name in ('Returns', 'Since') and self.has_section(name):
-            raise QAPIParseError(self.parser,
+            raise QAPIParseError(self._parser,
                                  "Duplicated '%s' section" % name)
         self._end_section()
-        self.section = QAPIDoc.Section(name)
-        self.sections.append(self.section)
+        self._section = QAPIDoc.Section(name)
+        self.sections.append(self._section)
 
     def _end_section(self):
-        if self.section:
-            text = self.section.text = self.section.text.strip()
-            if self.section.name and (not text or text.isspace()):
-                raise QAPIParseError(self.parser, "Empty doc section '%s'"
-                                     % self.section.name)
-            self.section = None
+        if self._section:
+            text = self._section.text = self._section.text.strip()
+            if self._section.name and (not text or text.isspace()):
+                raise QAPIParseError(self._parser, "Empty doc section '%s'"
+                                     % self._section.name)
+            self._section = None
 
     def _append_freeform(self, line):
-        in_arg = isinstance(self.section, QAPIDoc.ArgSection)
-        if (in_arg and self.section.text.endswith('\n\n')
+        in_arg = isinstance(self._section, QAPIDoc.ArgSection)
+        if (in_arg and self._section.text.endswith('\n\n')
                 and line and not line[0].isspace()):
             self._start_section()
-        if (in_arg or not self.section.name
-                or not self.section.name.startswith('Example')):
+        if (in_arg or not self._section.name
+                or not self._section.name.startswith('Example')):
             line = line.strip()
         match = re.match(r'(@\S+:)', line)
         if match:
-            raise QAPIParseError(self.parser,
+            raise QAPIParseError(self._parser,
                                  "'%s' not allowed in free-form documentation"
                                  % match.group(1))
-        self.section.append(line)
+        self._section.append(line)
 
     def connect_member(self, member):
         if member.name not in self.args:
-- 
2.13.6

  parent reply	other threads:[~2017-10-02 14:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02 14:13 [Qemu-devel] [PATCH 00/11] qapi: Cleanups around qapi2texi Markus Armbruster
2017-10-02 14:13 ` [Qemu-devel] [PATCH 01/11] qapi-schema: Fix query-vm-generation-id's doc comment markup Markus Armbruster
2017-10-04 10:12   ` Marc-André Lureau
2017-10-04 13:03     ` Markus Armbruster
2017-10-04 14:09       ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 02/11] qapi: Stop rejecting #optional Markus Armbruster
2017-10-04 10:15   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 03/11] qapi: Eliminate QAPISchemaParser.__init__()'s local fname Markus Armbruster
2017-10-04 10:15   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 04/11] qapi: Make cur_doc local to QAPISchemaParser.__init__() Markus Armbruster
2017-10-04 10:18   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 05/11] tests/qapi-schema/doc-bad-section: New, factored out of doc-good Markus Armbruster
2017-10-04 10:22   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 06/11] qapi2texi: Clean up texi_sections() Markus Armbruster
2017-10-04 10:24   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 07/11] qapi: Unify representation of doc section without name Markus Armbruster
2017-10-04 10:26   ` Marc-André Lureau
2017-10-04 10:26   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 08/11] qapi: Simplify representation of QAPIDoc section text Markus Armbruster
2017-10-04 10:30   ` Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 09/11] qapi2texi: Simplify representation of " Markus Armbruster
2017-10-04 10:29   ` Marc-André Lureau
2017-10-02 14:13 ` Markus Armbruster [this message]
2017-10-04 10:31   ` [Qemu-devel] [PATCH 10/11] qapi: Rename QAPIDoc.parser, .section to ._parser, ._section Marc-André Lureau
2017-10-02 14:13 ` [Qemu-devel] [PATCH 11/11] qapi2texi: De-duplicate code to add blank line before symbol Markus Armbruster
2017-10-04 10:35   ` Marc-André Lureau

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=20171002141341.24616-11-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).