From nobody Tue Feb 10 01:20:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604452163; cv=none; d=zohomail.com; s=zohoarc; b=TIrcUwMkmWZ21x6sIR9K5E1oTvAkDv7SLswKU6lycGyxTnvShXvBiuGL2SZbchgBCGINv1Q+yWyWQVHWX+GkAeimIPCMLBn/tZs13BRw1ue+oa/Spw5MVBa1B8xJobTWCQEmjvjRtwJZuz4mZjzlzHvAypfnK5m/t21Z9VZolVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604452163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=78jL6/OaCghfIdn9yhVtvUgPfPribGKLhjg9bPI806Y=; b=KO+24P/U1hgAgznoePdOo/bo9y5e0cSNC4rpRFA09E/jRo+SmRY2224VxVsVNbSqw69Dluoo1RW41bkguYq+BUlUCtxCNo08cqIPLwSGMPYWa+zFiCuMziwcHZPm0oq9SEvNfhkfyrltDNMLOuCNAtCN4VL2HNnF9YhVECNdCVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160445216393062.12061440942318; Tue, 3 Nov 2020 17:09:23 -0800 (PST) Received: from localhost ([::1]:58916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ka7Ig-0003I0-UM for importer@patchew.org; Tue, 03 Nov 2020 20:09:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ka6o0-0007Zs-Bi for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1ka6ny-0004yh-97 for qemu-devel@nongnu.org; Tue, 03 Nov 2020 19:37:39 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-FbBq82JjMISjrOc-V7aaEA-1; Tue, 03 Nov 2020 19:37:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32E5C6D242 for ; Wed, 4 Nov 2020 00:37:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-97.rdu2.redhat.com [10.10.119.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74E296266E; Wed, 4 Nov 2020 00:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604450257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=78jL6/OaCghfIdn9yhVtvUgPfPribGKLhjg9bPI806Y=; b=SgOGhdarFhb2LK3WrGu7V0JL1X+dabRwx/VVtG68tHATFcCrThYk56/BtFlkSDM4Mgsn+O QB0IaY1pjQa2Ld2nnQD93qK0TD4kmvJSwI9NETtRSTMqudMBkpnhLpdb5wdXJvY877N0Dt DXBxkpKbHakWBM98htvZXhIrCr4ugKw= X-MC-Unique: FbBq82JjMISjrOc-V7aaEA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v2 67/72] scripts/qmp-shell: remove double-underscores Date: Tue, 3 Nov 2020 19:35:57 -0500 Message-Id: <20201104003602.1293560-68-jsnow@redhat.com> In-Reply-To: <20201104003602.1293560-1-jsnow@redhat.com> References: <20201104003602.1293560-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 00:03:41 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cleber Rosa , John Snow , Markus Armbruster , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" They're not needed; single underscore is enough to express intent that these methods are "internal". double underscore is used as a weak name mangling, but that isn't beneficial for us here. Signed-off-by: John Snow --- scripts/qmp/qmp-shell | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell index 82fe16cff820..40ff9e0a82bd 100755 --- a/scripts/qmp/qmp-shell +++ b/scripts/qmp/qmp-shell @@ -171,7 +171,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): for cmd in cmds['return']: self._completer.append(cmd['name']) =20 - def __completer_setup(self) -> None: + def _completer_setup(self) -> None: self._completer =3D QMPCompleter() self._fill_completion() readline.set_history_length(1024) @@ -196,7 +196,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): LOG.warning(msg) =20 @classmethod - def __parse_value(cls, val: str) -> object: + def _parse_value(cls, val: str) -> object: try: return int(val) except ValueError: @@ -221,9 +221,9 @@ class QMPShell(qmp.QEMUMonitorProtocol): pass return val =20 - def __cli_expr(self, - tokens: Sequence[str], - parent: qmp.QMPObject) -> None: + def _cli_expr(self, + tokens: Sequence[str], + parent: qmp.QMPObject) -> None: for arg in tokens: (key, sep, val) =3D arg.partition('=3D') if sep !=3D '=3D': @@ -231,7 +231,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): f"Expected a key=3Dvalue pair, got '{arg!s}'" ) =20 - value =3D self.__parse_value(val) + value =3D self._parse_value(val) optpath =3D key.split('.') curpath =3D [] for path in optpath[:-1]: @@ -249,7 +249,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): raise QMPShellError(f'Cannot set "{key}" multiple times') parent[optpath[-1]] =3D value =20 - def __build_cmd(self, cmdline: str) -> Optional[QMPMessage]: + def _build_cmd(self, cmdline: str) -> Optional[QMPMessage]: """ Build a QMP input object from a user provided command-line in the following format: @@ -289,13 +289,13 @@ class QMPShell(qmp.QEMUMonitorProtocol): if cmdargs[-1] =3D=3D ')': cmdargs.pop(-1) finalize =3D True - self.__cli_expr(cmdargs[1:], action['data']) + self._cli_expr(cmdargs[1:], action['data']) self._actions.append(action) - return self.__build_cmd(')') if finalize else None + return self._build_cmd(')') if finalize else None =20 # Standard command: parse and return it to be executed. qmpcmd =3D {'execute': cmdargs[0], 'arguments': {}} - self.__cli_expr(cmdargs[1:], qmpcmd['arguments']) + self._cli_expr(cmdargs[1:], qmpcmd['arguments']) return qmpcmd =20 def _print(self, qmp_message: object) -> None: @@ -306,7 +306,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 def _execute_cmd(self, cmdline: str) -> bool: try: - qmpcmd =3D self.__build_cmd(cmdline) + qmpcmd =3D self._build_cmd(cmdline) except QMPShellError as err: print( f"Error while parsing command line: {err!s}\n" @@ -329,7 +329,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): =20 def connect(self, negotiate: bool =3D True) -> None: self._greeting =3D super().connect(negotiate) - self.__completer_setup() + self._completer_setup() =20 def show_banner(self, msg: str =3D 'Welcome to the QMP low-level shell!') ->= None: @@ -377,10 +377,10 @@ class HMPShell(QMPShell): def __init__(self, address: qmp.SocketAddrT, pretty: bool =3D False, verbose: bool =3D False): super().__init__(address, pretty, verbose) - self.__cpu_index =3D 0 + self._cpu_index =3D 0 =20 - def __cmd_completion(self) -> None: - for cmd in self.__cmd_passthrough('help')['return'].split('\r\n'): + def _cmd_completion(self) -> None: + for cmd in self._cmd_passthrough('help')['return'].split('\r\n'): if cmd and cmd[0] !=3D '[' and cmd[0] !=3D '\t': name =3D cmd.split()[0] # drop help text if name =3D=3D 'info': @@ -396,22 +396,22 @@ class HMPShell(QMPShell): self._completer.append(name) self._completer.append('help ' + name) # help completion =20 - def __info_completion(self) -> None: - for cmd in self.__cmd_passthrough('info')['return'].split('\r\n'): + def _info_completion(self) -> None: + for cmd in self._cmd_passthrough('info')['return'].split('\r\n'): if cmd: self._completer.append('info ' + cmd.split()[1]) =20 - def __other_completion(self) -> None: + def _other_completion(self) -> None: # special cases self._completer.append('help info') =20 def _fill_completion(self) -> None: - self.__cmd_completion() - self.__info_completion() - self.__other_completion() + self._cmd_completion() + self._info_completion() + self._other_completion() =20 - def __cmd_passthrough(self, cmdline: str, - cpu_index: int =3D 0) -> QMPMessage: + def _cmd_passthrough(self, cmdline: str, + cpu_index: int =3D 0) -> QMPMessage: return self.cmd_obj({ 'execute': 'human-monitor-command', 'arguments': { @@ -425,14 +425,14 @@ class HMPShell(QMPShell): # trap the cpu command, it requires special setting try: idx =3D int(cmdline.split()[1]) - if 'return' not in self.__cmd_passthrough('info version', = idx): + if 'return' not in self._cmd_passthrough('info version', i= dx): print('bad CPU index') return True - self.__cpu_index =3D idx + self._cpu_index =3D idx except ValueError: print('cpu command takes an integer argument') return True - resp =3D self.__cmd_passthrough(cmdline, self.__cpu_index) + resp =3D self._cmd_passthrough(cmdline, self._cpu_index) if resp is None: print('Disconnected') return False --=20 2.26.2