From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aamXH-0006q3-JG for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:48:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aamXG-00037f-I8 for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:48:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aamXG-00037U-Dh for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:48:30 -0500 From: Stefan Hajnoczi Date: Tue, 1 Mar 2016 15:48:07 +0000 Message-Id: <1456847294-13576-7-git-send-email-stefanha@redhat.com> In-Reply-To: <1456847294-13576-1-git-send-email-stefanha@redhat.com> References: <1456847294-13576-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 06/13] trace: Extend API to manage event arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= , Stefan Hajnoczi From: Llu=C3=ADs Vilanova Lets the user manage event arguments as a list, and simplifies argument concatenation. Signed-off-by: Llu=C3=ADs Vilanova Reviewed-by: Eric Blake Message-id: 145641858432.30295.3069911069472672646.stgit@localhost Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.p= y index 181675f..0663e7f 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -50,9 +50,14 @@ class Arguments: Parameters ---------- args : - List of (type, name) tuples. + List of (type, name) tuples or Arguments objects. """ - self._args =3D args + self._args =3D [] + for arg in args: + if isinstance(arg, Arguments): + self._args.extend(arg._args) + else: + self._args.append(arg) =20 def copy(self): """Create a new copy.""" @@ -83,6 +88,12 @@ class Arguments: res.append((arg_type, identifier)) return Arguments(res) =20 + def __getitem__(self, index): + if isinstance(index, slice): + return Arguments(self._args[index]) + else: + return self._args[index] + def __iter__(self): """Iterate over the (type, name) pairs.""" return iter(self._args) --=20 2.5.0