[Erp5-report] r28868 - /erp5/trunk/utils/zylint

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Sep 8 14:40:56 CEST 2009


Author: vincent
Date: Tue Sep  8 14:40:55 2009
New Revision: 28868

URL: http://svn.erp5.org?rev=28868&view=rev
Log:
Add a small pylint wrapper to allow easily checking Python Scripts, as edited in webdav mode.

Added:
    erp5/trunk/utils/zylint   (with props)

Added: erp5/trunk/utils/zylint
URL: http://svn.erp5.org/erp5/trunk/utils/zylint?rev=28868&view=auto
==============================================================================
--- erp5/trunk/utils/zylint (added)
+++ erp5/trunk/utils/zylint [utf8] Tue Sep  8 14:40:55 2009
@@ -1,0 +1,42 @@
+#!/usr/bin/python
+import sys
+import os
+
+# TODO: parse parameters to allow checking more than one file at a time, and
+# propagating parameters to pylint.
+assert len(sys.argv) == 2, 'One and only one parameter expected.'
+
+source_file_name = sys.argv[1]
+source_file = open(source_file_name, 'r')
+
+line = source_file.readline()
+assert line.startswith('## Script (Python)'), repr(line)
+
+builtin_list = []
+append = builtin_list.append
+while line.startswith('##'):
+  line = line.lstrip('#').strip()
+  if line.startswith('bind'):
+    assert '=' in line, repr(line)
+    value = line.split('=', 1)[1]
+    if value:
+      append(value)
+  elif line.startswith('parameters'):
+    assert '=' in line, repr(line)
+    for param in line.split('=', 1)[1].split(','):
+      if '=' in param:
+        param = param.split('=', 1)[0]
+      append(param.strip(' *'))
+  line = source_file.readline()
+
+# Call pylint with given Python Script file.
+# - add script parameters as additional built-ins
+# - disable E0104 (return outside of function), as top-level block behaves just
+#   as a function.
+# - disable persistence of results
+os.system('pylint --additional-builtins=%(builtins)s --disable-msg=E0104 ' \
+  '--persistent=n %(file)s' % {
+  'file': source_file_name,
+  'builtins': ','.join(builtin_list)
+})
+

Propchange: erp5/trunk/utils/zylint
------------------------------------------------------------------------------
    svn:executable = *




More information about the Erp5-report mailing list