From patchwork Sat Mar 21 22:17:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1259557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48lFQ14Vh4z9sPF for ; Sun, 22 Mar 2020 09:17:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 3DD1C2002E; Sat, 21 Mar 2020 22:17:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s0fbPvtSzCHh; Sat, 21 Mar 2020 22:17:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id ECA4B20381; Sat, 21 Mar 2020 22:17:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CBC46C089F; Sat, 21 Mar 2020 22:17:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0B9E5C07FF for ; Sat, 21 Mar 2020 22:17:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EDD0187855 for ; Sat, 21 Mar 2020 22:17:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IcjtJCjpUrAp for ; Sat, 21 Mar 2020 22:17:38 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id A5A2D876D9 for ; Sat, 21 Mar 2020 22:17:37 +0000 (UTC) X-Originating-IP: 75.54.222.30 Received: from sigfpe.attlocal.net (75-54-222-30.lightspeed.rdcyca.sbcglobal.net [75.54.222.30]) (Authenticated sender: blp@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id D5DECE0003; Sat, 21 Mar 2020 22:17:32 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Sat, 21 Mar 2020 15:17:27 -0700 Message-Id: <20200321221727.3975073-1-blp@ovn.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] python: Fix plural forms of OVSDB types. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Fixes two problems. First, the plural of chassis is also chassis. Second, for linguistic analysis we need to consider plain words, not words that have (e.g.) \fB and \fR pasted into them for nroff output. This makes the OVN manpage for ovn-sb(5) talk about "set of Chassis" not "set of Chassiss". Signed-off-by: Ben Pfaff Acked-by: Numan Siddique --- python/ovs/db/types.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/python/ovs/db/types.py b/python/ovs/db/types.py index b0eec6165b3b..a8ba01d4f2cc 100644 --- a/python/ovs/db/types.py +++ b/python/ovs/db/types.py @@ -591,9 +591,16 @@ class Type(object): if self.value: return "map of %s%s-%s pairs" % (quantity, keyName, valueName) else: - if keyName.lower() == 'chassis': - plural = '' - elif keyName.endswith('s'): + # Exract the last word from 'keyName' so we can make it plural. + # For linguistic analysis, turn it into English without + # formatting so that we don't consider any prefix or suffix + # added by escapeLiteral. + plainKeyName = (self.key.toEnglish(returnUnchanged) + .rpartition(' ')[2].lower()) + + if plainKeyName == 'chassis': + plural = keyName + elif plainKeyName.endswith('s'): plural = keyName + "es" else: plural = keyName + "s"