summaryrefslogtreecommitdiffstats
path: root/scripts/qapi/source.py
diff options
context:
space:
mode:
authorPeter Maydell2021-05-20 21:17:55 +0200
committerPeter Maydell2021-05-20 21:17:55 +0200
commit0b5acf89c1b197fc8f36db0896f652a4c577352f (patch)
tree6d2404d7a8f30c97f44d44c031c4793f06535758 /scripts/qapi/source.py
parentMerge remote-tracking branch 'remotes/cohuck-gitlab/tags/s390x-20210520-v2' i... (diff)
parentqapi/parser: add docstrings (diff)
downloadqemu-0b5acf89c1b197fc8f36db0896f652a4c577352f.tar.gz
qemu-0b5acf89c1b197fc8f36db0896f652a4c577352f.tar.xz
qemu-0b5acf89c1b197fc8f36db0896f652a4c577352f.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-05-20' into staging
QAPI patches patches for 2021-05-20 # gpg: Signature made Thu 20 May 2021 16:10:21 BST # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-05-20: qapi/parser: add docstrings qapi/parser: allow 'ch' variable name qapi/parser: Remove superfluous list comprehension qapi/parser: add type hint annotations qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard qapi/parser: Fix token membership tests when token can be None qapi: add must_match helper qapi/parser: Use @staticmethod where appropriate qapi/parser: assert object keys are strings qapi/parser: enforce all top-level expressions must be dict in _parse() qapi/parser: Assert lexer value is a string qapi/parser: factor parsing routine into method qapi/source: Remove line number from QAPISourceInfo initializer qapi: Add test for nonexistent schema file qapi/parser: Don't try to handle file errors Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/source.py')
-rw-r--r--scripts/qapi/source.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py
index 03b6ede082..04193cc964 100644
--- a/scripts/qapi/source.py
+++ b/scripts/qapi/source.py
@@ -10,7 +10,6 @@
# See the COPYING file in the top-level directory.
import copy
-import sys
from typing import List, Optional, TypeVar
@@ -32,10 +31,9 @@ class QAPISchemaPragma:
class QAPISourceInfo:
T = TypeVar('T', bound='QAPISourceInfo')
- def __init__(self, fname: str, line: int,
- parent: Optional['QAPISourceInfo']):
+ def __init__(self, fname: str, parent: Optional['QAPISourceInfo']):
self.fname = fname
- self.line = line
+ self.line = 1
self.parent = parent
self.pragma: QAPISchemaPragma = (
parent.pragma if parent else QAPISchemaPragma()
@@ -53,12 +51,7 @@ class QAPISourceInfo:
return info
def loc(self) -> str:
- if self.fname is None:
- return sys.argv[0]
- ret = self.fname
- if self.line is not None:
- ret += ':%d' % self.line
- return ret
+ return f"{self.fname}:{self.line}"
def in_defn(self) -> str:
if self.defn_name: