[libvirt] [PATCH v5 04/23] build-aux: rewrite header ifdef checker in Python

Ján Tomko jtomko at redhat.com
Tue Nov 19 13:07:12 UTC 2019


On Mon, Nov 11, 2019 at 02:38:07PM +0000, Daniel P. Berrangé wrote:
>As part of an goal to eliminate Perl from libvirt build tools,
>rewrite the header-ifdef.pl tool in Python.
>
>This was a straight conversion, manually going line-by-line to
>change the syntax from Perl to Python. Thus the overall structure
>of the file and approach is the same.
>
>Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
>---
> Makefile.am               |   2 +-
> build-aux/header-ifdef.pl | 182 ------------------------------
> build-aux/syntax-check.mk |   4 +-
> scripts/header-ifdef.py   | 231 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 234 insertions(+), 185 deletions(-)
> delete mode 100644 build-aux/header-ifdef.pl
> create mode 100644 scripts/header-ifdef.py
>

>+    if filename.find("include/") != -1:
>+        publicheader = True
>+
>+    with open(filename, "r") as fh:
>+        for line in fh:
>+            line = line.rstrip("\n")

The stripping was not present in the perl version.

>+            if state == STATE_COPYRIGHT_COMMENT:
>+                if line.find("*/") != -1:

Same comment about find vs in here.

>+                    state = STATE_COPYRIGHT_BLANK
>+            elif state == STATE_COPYRIGHT_BLANK:
>+                if line != "":
>+                    print("%s: missing blank line after copyright header" %
>+                          filename, file=sys.stderr)
>+                    return True
>+

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191119/fe514247/attachment-0001.sig>


More information about the libvir-list mailing list