Merlijn van Deen has uploaded a new change for review. https://gerrit.wikimedia.org/r/99745
Change subject: Add Python 3.3 syntax checker ...................................................................... Add Python 3.3 syntax checker Change-Id: I71a5091d530449804bde5ab0b94c5c9456b31dae --- A bin/py33checker.py 1 file changed, 60 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/integration/jenkins refs/changes/45/99745/1 diff --git a/bin/py33checker.py b/bin/py33checker.py new file mode 100755 index 0000000..2d82d8c --- /dev/null +++ b/bin/py33checker.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3.3 +""" Script to parse files and check their Python 3.3+ syntax + +This script will run on all .py files in a directory tree, +ignoring the ./.git directory. It will then try to +byte-compile each .py file using py_compile. Errors are +printed to stderr and the number of failing files is returned +as exit status. +""" + +__license__ = """ +The MIT License (MIT) + +Copyright (c) 2013 Merlijn van Deen <valhall...@arctus.nl> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +""" + +import sys +import os +import py_compile + +def check_file(f): + if f.startswith('./.git/'): + return False + if not f.endswith('.py'): + return False + return True + +def main(): + files = (fullfn + for dirpath, dirnames, files in os.walk('.') + for fullfn in (os.path.join(dirpath, f) for f in files) + if check_file(fullfn)) + + failures = 0 + for f in files: + result = py_compile.compile(f.strip(), doraise=False) + if result is None: + failures += 1 + return failures + +if __name__ == "__main__": + sys.exit(main()) -- To view, visit https://gerrit.wikimedia.org/r/99745 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I71a5091d530449804bde5ab0b94c5c9456b31dae Gerrit-PatchSet: 1 Gerrit-Project: integration/jenkins Gerrit-Branch: master Gerrit-Owner: Merlijn van Deen <valhall...@arctus.nl> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits