[libvirt] [PATCH v5 07/23] src: rewrite symfile library checker in Python
Ján Tomko
jtomko at redhat.com
Wed Nov 20 05:59:09 UTC 2019
On Mon, Nov 11, 2019 at 02:38:10PM +0000, Daniel P. Berrangé wrote:
>As part of an goal to eliminate Perl from libvirt build tools,
>rewrite the check-symfile.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 | 1 +
> scripts/check-symfile.py | 80 +++++++++++++++++++++++++++++++++++++++
> src/Makefile.am | 5 +--
> src/admin/Makefile.inc.am | 4 +-
> src/check-symfile.pl | 70 ----------------------------------
> 5 files changed, 85 insertions(+), 75 deletions(-)
> create mode 100755 scripts/check-symfile.py
> delete mode 100755 src/check-symfile.pl
>
>+with open(symfile, "r") as fh:
>+ for line in fh:
>+ line = line.strip()
>+ if line.find("{") != -1:
>+ continue
>+ if line.find("}") != -1:
>+ continue
>+ if line in ["global:", "local:"]:
>+ continue
>+ if line == "":
>+ continue
>+ if line[0] == '#':
>+ continue
>+ if line.find("*") != -1:
>+ continue
>+
>+ line = line.strip(";")
Unlike the perl version, this quietly ignores a missing semicolon.
But that will be caught by the linker earlier.
>+
>+ if line in wantsyms:
>+ print("Symbol $1 is listed twice", file=sys.stderr)
>+ ret = 1
>+ else:
>+ wantsyms[line] = 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/20191120/69140721/attachment-0001.sig>
More information about the libvir-list
mailing list