From nobody Sat Jul 5 15:59:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521296691298279.3349432283226; Sat, 17 Mar 2018 07:24:51 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 8759223E6F3; Sat, 17 Mar 2018 14:24:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6104C5D70B; Sat, 17 Mar 2018 14:24:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 29CD7180BADA; Sat, 17 Mar 2018 14:24:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2HEOCrY000677 for ; Sat, 17 Mar 2018 10:24:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id B9A47608F4; Sat, 17 Mar 2018 14:24:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B41D4183C6 for ; Sat, 17 Mar 2018 14:24:11 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC4DC80F79 for ; Sat, 17 Mar 2018 14:24:10 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id a20so6480198wmd.1 for ; Sat, 17 Mar 2018 07:24:10 -0700 (PDT) Received: from rst.Home ([2a02:c7d:692a:c500:1ebc:73f3:5f60:b131]) by smtp.gmail.com with ESMTPSA id i66sm11060550wmd.0.2018.03.17.07.24.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Mar 2018 07:24:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CRUTCos3C8MmrS5v+ijK20QoCh3BKr2xG4vyiSN4hg8=; b=ZgpQ/T+c28GBC30WlzKvC/GMkAoJH+VXlDPl9LyklqZx4r4Wfd+rohh11n1aLwXB4V 7XZ5Bree1eWnZi/nayRJ3LmtWWOzvFiAFxJLnxVaGBN862HCAJfVCtE20BKJjHdgMSOG +0KOmiULUSI1FpR4w9+RY8gCmcC2yuly20a9e0+nOSeXtHCHrthixU2U4Shn0FN54mtK uPar+DgM/98UDk8kn+MMSBN+jVWH1nLvhkt26GRw6WXEreloyIj4VsRKr8+znom+wA0v Qy2dML58tqTHnxjNcbR2GxvsgwtBTqIJRBf3YqpSwHDWg9KAbtIab98iltIAEs0tZZfX /QQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CRUTCos3C8MmrS5v+ijK20QoCh3BKr2xG4vyiSN4hg8=; b=N7eb/M/HsmSGkDwZxyccfBQtjQG6lhrgSAbGqJp5EGSNaavY8Pp3lQSspwTKa1rLup LNJByl1ymMUvfaVcNsQ9JM5fsoc+VpM4CsU9s7sz0lSGuiRTLf9KvRKckMbDaO51oGbL 60v0TpY0XVV78auSRrxyZDt1cmxQwV5n3OAa4QrzXFp1OWDVkQ9roLLoEBNGgIK+4VDc zC6b5irN1nXSNd4D1jUmakC3xM2R8PG7YmqQ+keuzSPR5CJ5TFIeup41uZ8Jy4L5zCgh t1trSBVTG3IbvRv47A3nAVhbpn/+7GV2Z2iuR0UAsxIZ5sQ+t5wQlO0TuTUM/q/rpDA0 Dq+A== X-Gm-Message-State: AElRT7G2oG8nXmytSXEBwdHlVCWCm7wSGkDR6Lq+fGK0C3quEisfhh7N zdvhoV11+bMVgWxQIaCfYYoQaKR6 X-Google-Smtp-Source: AG47ELtzp8C01sh3Ha/LlxMbTK+LyoRj1UV8+UjC+7n1cEGVV5t7+nkp/OAJqID28l9b4ACe6uelpA== X-Received: by 10.28.9.19 with SMTP id 19mr4774965wmj.114.1521296649217; Sat, 17 Mar 2018 07:24:09 -0700 (PDT) From: Radostin Stoyanov To: libvir-list@redhat.com Date: Sat, 17 Mar 2018 14:23:36 +0000 Message-Id: <20180317142340.11653-19-rstoyanov1@gmail.com> In-Reply-To: <20180317142340.11653-1-rstoyanov1@gmail.com> References: <20180317142340.11653-1-rstoyanov1@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:24:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sat, 17 Mar 2018 14:24:11 +0000 (UTC) for IP:'74.125.82.66' DOMAIN:'mail-wm0-f66.google.com' HELO:'mail-wm0-f66.google.com' FROM:'rstoyanov1@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.12 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 74.125.82.66 mail-wm0-f66.google.com 74.125.82.66 mail-wm0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Radostin Stoyanov Subject: [libvirt] [PATCH 18/22] apibuild: Simplify parseTypeComment() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 17 Mar 2018 14:24:50 +0000 (UTC) X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Improve readability and reduce complexity the method parseTypeComment(). Signed-off-by: Radostin Stoyanov Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/apibuild.py | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/docs/apibuild.py b/docs/apibuild.py index b914b1dce..fd1ee7958 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -757,48 +757,38 @@ class CParser: # # Parse a comment block associate to a typedef # - def parseTypeComment(self, name, quiet=3D0): + def parseTypeComment(self, name, quiet=3DFalse): if name[0:2] =3D=3D '__': - quiet =3D 1 - - args =3D [] - desc =3D "" + quiet =3D True =20 if self.comment is None: if not quiet: self.warning("Missing comment for type %s" % (name)) - return((args, desc)) - if self.comment[0] !=3D '*': + return None + if not self.comment.startswith('*'): if not quiet: self.warning("Missing * in type comment for %s" % (name)) - return((args, desc)) + return None + lines =3D self.comment.split('\n') - if lines[0] =3D=3D '*': - del lines[0] + # Remove lines that contain only single asterisk + lines[:] =3D [line for line in lines if line.strip() !=3D '*'] + if lines[0] !=3D "* %s:" % (name): if not quiet: self.warning("Misformatted type comment for %s" % (name)) self.warning(" Expecting '* %s:' got '%s'" % (name, lines= [0])) - return((args, desc)) + return None del lines[0] - while len(lines) > 0 and lines[0] =3D=3D '*': - del lines[0] - desc =3D "" - while len(lines) > 0: - l =3D lines[0] - while len(l) > 0 and l[0] =3D=3D '*': - l =3D l[1:] - l =3D l.strip() - desc =3D desc + " " + l - del lines[0] =20 - desc =3D desc.strip() + # Concatenate all remaining lines by striping leading asterisks + desc =3D " ".join([line.lstrip("*").strip() for line in lines]).st= rip() =20 - if quiet =3D=3D 0: - if desc =3D=3D "": - self.warning("Type comment for %s lack description of the = macro" % (name)) + if not (quiet or desc): + self.warning("Type comment for %s lack description of the macr= o" + % (name)) =20 - return(desc) + return desc # # Parse a comment block associate to a macro # --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list