Change in vdsm[master]: Add a non-ascii charactor checker to vdsm
lvroyce at linux.vnet.ibm.com
lvroyce at linux.vnet.ibm.com
Mon Nov 19 10:04:24 UTC 2012
Royce Lv has uploaded a new change for review.
Change subject: Add a non-ascii charactor checker to vdsm
......................................................................
Add a non-ascii charactor checker to vdsm
non-ascii charactor is not allowed in python code and comments
see http://www.python.org/peps/pep-0263.html
pep8 will not check this,
if non-ascii charactors are carelessly added in comments,
autobuild now not shout out,
this results in fatal failure when you run .py:
Sytax Error: Non-ASCII charactor in xxx
This patch is for early discovery for non-ascii charactor.
Change-Id: Ie4abdd1eb34db6a70335459e54dc8b38729f8e92
Signed-off-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
---
M Makefile.am
M vdsm-tool/Makefile.am
A vdsm-tool/non-ascii-check.py
3 files changed, 14 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/21/9321/1
diff --git a/Makefile.am b/Makefile.am
index e15d709..9c44570 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -126,6 +126,7 @@
check-local:
find . -path './.git' -prune -type f -o \
-name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES)
+ find . -type f -name '*.py' | xargs python $(top_srcdir)/vdsm-tool/non-ascii-check.py
$(PEP8) --exclude="$(PEP8_BLACKLIST)" --filename '*.py,*.py.in' \
--ignore=E121,E122,E123,E124,E125,E126,E127,E128,E241 \
$(PEP8_WHITELIST)
diff --git a/vdsm-tool/Makefile.am b/vdsm-tool/Makefile.am
index 997e339..2625d45 100644
--- a/vdsm-tool/Makefile.am
+++ b/vdsm-tool/Makefile.am
@@ -23,7 +23,9 @@
vdsm-tool
EXTRA_DIST = \
- validate_ovirt_certs.py.in
+ validate_ovirt_certs.py.in \
+ non-ascii-check.py \
+ $(NULL)
dist_vdsmtool_DATA = \
__init__.py \
diff --git a/vdsm-tool/non-ascii-check.py b/vdsm-tool/non-ascii-check.py
new file mode 100644
index 0000000..25d6631
--- /dev/null
+++ b/vdsm-tool/non-ascii-check.py
@@ -0,0 +1,10 @@
+import sys
+
+if __name__ == '__main__':
+ fileNames = sys.argv[1:]
+ for f in fileNames:
+ try:
+ open(f).read().decode('ascii')
+ except UnicodeDecodeError:
+ print "file %s contains non-ascii charactor" % f
+ sys.exit(1)
--
To view, visit http://gerrit.ovirt.org/9321
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4abdd1eb34db6a70335459e54dc8b38729f8e92
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce at linux.vnet.ibm.com>
More information about the vdsm-patches
mailing list