Re: [PATCH v5 11/23] src: rewrite driver impl checker in Python

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/11/19 9:38 AM, Daniel P. Berrangé wrote:
> As part of an goal to eliminate Perl from libvirt build tools,
> rewrite the check-driverimpls.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@xxxxxxxxxx>
> ---
>  Makefile.am                  |   1 +
>  scripts/check-driverimpls.py | 102 +++++++++++++++++++++++++++++++++++
>  src/Makefile.am              |   4 +-
>  src/check-driverimpls.pl     |  80 ---------------------------
>  4 files changed, 105 insertions(+), 82 deletions(-)
>  create mode 100755 scripts/check-driverimpls.py
>  delete mode 100755 src/check-driverimpls.pl
> 
> diff --git a/Makefile.am b/Makefile.am
> index 7155ab6ce9..407a664626 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -48,6 +48,7 @@ EXTRA_DIST = \
>    scripts/augeas-gentest.py \
>    scripts/check-aclperms.py \
>    scripts/check-drivername.py \
> +  scripts/check-driverimpls.py \
>    scripts/check-spacing.py \
>    scripts/check-symfile.py \
>    scripts/check-symsorting.py \
> diff --git a/scripts/check-driverimpls.py b/scripts/check-driverimpls.py
> new file mode 100755
> index 0000000000..78d53e75a4
> --- /dev/null
> +++ b/scripts/check-driverimpls.py
> @@ -0,0 +1,102 @@
> +#!/usr/bin/env python
> +#
> +# Copyright (C) 2013-2019 Red Hat, Inc.
> +#
> +# This library is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU Lesser General Public
> +# License as published by the Free Software Foundation; either
> +# version 2.1 of the License, or (at your option) any later version.
> +#
> +# This library is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +# Lesser General Public License for more details.
> +#
> +# You should have received a copy of the GNU Lesser General Public
> +# License along with this library.  If not, see
> +# <http://www.gnu.org/licenses/>.
> +#
> +
> +from __future__ import print_function
> +
> +import re
> +import sys
> +
> +
> +def checkdriverimpls(filename):
> +    intable = False
> +    mainprefix = None
> +
> +    errs = False
> +    with open(filename, "r") as fh:
> +        lineno = 0
> +        for line in fh:
> +            lineno = lineno + 1
> +            if intable:
> +                if line.find("}") != -1:
> +                    intable = False
> +                    mainprefix = None
> +                    continue
> +
> +                m = re.search(r'''\.(\w+)\s*=\s*(\w+),?/''', line)

The ending / here breaks things. If the intent is to match lines like:

.connectSupportsFeature = qemuConnectSupportsFeature, /* 0.5.0 */

Then there needs to be something between '?' and '/'. But this script
could still be useful for sanitizing virStateDriver structs too, which
don't have those ending comments, so maybe just drop the / entirely.

With that and the pep8 issues fixed, all the errors trigger as expected

Tested-by: Cole Robinson <crobinso@xxxxxxxxxx>

- Cole

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux