[Kimchi-devel] [PATCH V2 4/4] run pyflakes when make check

Zhou Zheng Sheng zhshzhou at linux.vnet.ibm.com
Wed Mar 19 08:58:22 UTC 2014


于 2014年03月17日 17:44, shaohef at linux.vnet.ibm.com 写道:
> From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> 
> Pyflakes analyzes programs and detects various errors. It works by
> parsing the source file, not importing it, so it is safe to use on
> modules with side effects. It's also much faster.
> 
> This is important to improve the code quality.
> 
> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
> Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
> ---
>  Makefile.am                   | 7 +++++++
>  configure.ac                  | 7 +++++++
>  contrib/DEBIAN/control.in     | 1 +
>  contrib/kimchi.spec.fedora.in | 1 +
>  docs/README.md                | 6 +++---
>  5 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 2fdafb1..c8fba26 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -71,7 +71,14 @@ PEP8_WHITELIST = \
>  	tests/utils.py \
>  	$(NULL)
> 
> +SKIP_PYFLAKES_ERR = src/kimchi/websocket.py

It's better to make the match strict. So I'd suggest
  SKIP_PYFLAKES_ERR = 'src/kimchi/websocket\.py'

We are using "grep -w", it works in word regexp mode. It only matches a
line beginning with the pattern. The find prints the file names in a
form like ./src/kimchi/websocket.py. Combine these two reasons, I'd
suggest the pattern should be like this:
  SKIP_PYFLAKES_ERR = '\./src/kimchi/websocket\.py'

> +
>  check-local:
> +	find . -path './.git' -prune -type f -o \
> +		-name '*.py' -o -name '*.py.in'  | xargs $(PYFLAKES) | \
> +		grep -w -v $(SKIP_PYFLAKES_ERR) | \
> +		while read LINE; do echo "$$LINE"; false; done
> +
>  	$(PEP8) --version
>  	$(PEP8) --filename '*.py,*.py.in' $(PEP8_WHITELIST)
> 
> diff --git a/configure.ac b/configure.ac
> index 365348f..a625f35 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -42,6 +42,13 @@ AM_GNU_GETTEXT([external])
>  AM_GNU_GETTEXT_VERSION([0.10])
>  AC_PATH_PROG([CHEETAH], [cheetah], [/usr/bin/cheetah])
> 
> +# Checking for pyflakes
> +AC_PATH_PROG([PYFLAKES], [pyflakes])
> +if test "x$PYFLAKES" = "x"; then
> +  AC_MSG_WARN([pyflakes not found])
> +fi
> +
> +
>  AC_CONFIG_FILES([
>      po/Makefile.in
>      po/gen-pot
> diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in
> index c2b2a40..75c42a6 100644
> --- a/contrib/DEBIAN/control.in
> +++ b/contrib/DEBIAN/control.in
> @@ -24,6 +24,7 @@ Depends: python-cherrypy3 (>= 3.2.0),
>           open-iscsi,
>           firewalld
>  Build-Depends: libxslt,
> +               pyflakes,
>                 python-libxml2
>  Maintainer: Aline Manera <alinefm at br.ibm.com>
>  Description: Kimchi web server
> diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in
> index bf80104..1d51c87 100644
> --- a/contrib/kimchi.spec.fedora.in
> +++ b/contrib/kimchi.spec.fedora.in
> @@ -31,6 +31,7 @@ Requires:	nfs-utils
>  Requires:	iscsi-initiator-utils
>  BuildRequires:	libxslt
>  BuildRequires:	libxml2-python
> +BuildRequires:  pyflakes
> 
>  %if 0%{?rhel} == 6
>  Requires:	python-ordereddict
> diff --git a/docs/README.md b/docs/README.md
> index 4be0e53..9c82540 100644
> --- a/docs/README.md
> +++ b/docs/README.md
> @@ -53,7 +53,7 @@ Install Dependencies
>                          PyPAM m2crypto python-jsonschema rpm-build \
>                          qemu-kvm python-psutil python-ethtool sos \
>                          python-ipaddr python-lxml nfs-utils \
> -                        iscsi-initiator-utils libxslt pyparted
> +                        iscsi-initiator-utils libxslt pyparted pyflakes
>       # If using RHEL6, install the following additional packages:
>       $ sudo yum install python-unittest2 python-ordereddict
>       # Restart libvirt to allow configuration changes to take effect
> @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository.
>                             python-pam python-m2crypto python-jsonschema \
>                             qemu-kvm libtool python-psutil python-ethtool \
>                             sosreport python-ipaddr python-lxml nfs-common \
> -                           open-iscsi lvm2 xsltproc python-parted
> +                           open-iscsi lvm2 xsltproc python-parted pyflakes
> 
>      Packages version requirement:
>          python-jsonschema >= 1.3.0
> @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository.
>                            python-pam python-M2Crypto python-jsonschema \
>                            rpm-build kvm python-psutil python-ethtool \
>                            python-ipaddr python-lxml nfs-client open-iscsi \
> -                          libxslt-tools python-xml python-parted
> +                          libxslt-tools python-xml python-parted pyflakes
> 
>      Packages version requirement:
>          python-psutil >= 0.6.0
> 


-- 
Thanks and best regards!

Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397




More information about the Kimchi-devel mailing list