[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46372] trunk/blender/source/tools/ check_style_c.py: Add option to skip line length check to check_style_c.py.

Nicholas Bishop nicholasbishop at gmail.com
Mon May 7 01:32:40 CEST 2012


Revision: 46372
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46372
Author:   nicholasbishop
Date:     2012-05-06 23:32:40 +0000 (Sun, 06 May 2012)
Log Message:
-----------
Add option to skip line length check to check_style_c.py.

A lot of the warnings currently showing up are lines just a bit over
120, figured it's worth making it easy to skip them. The new option
can be invoked as either '-l' or '--no-length-check'.

Modified Paths:
--------------
    trunk/blender/source/tools/check_style_c.py

Modified: trunk/blender/source/tools/check_style_c.py
===================================================================
--- trunk/blender/source/tools/check_style_c.py	2012-05-06 23:06:24 UTC (rev 46371)
+++ trunk/blender/source/tools/check_style_c.py	2012-05-06 23:32:40 UTC (rev 46372)
@@ -45,6 +45,8 @@
 
 from pygments.token import Token
 
+import argparse
+
 PRINT_QTC_TASKFORMAT = False
 
 TAB_SIZE = 4
@@ -338,7 +340,7 @@
                 warning("line length %d > %d" % (len(l), LIN_SIZE), index_start, index_end)
 
 
-def scan_source(fp):
+def scan_source(fp, args):
     # print("scanning: %r" % fp)
 
     global filepath
@@ -377,7 +379,7 @@
                 blender_check_operator(i, index_kw_end, op)
 
         # ensure line length
-        if tok.type == Token.Text and tok.text == "\n":
+        if (not args.no_length_check) and tok.type == Token.Text and tok.text == "\n":
             # check line len
             blender_check_linelength(index_line_start, i - 1, col)
 
@@ -396,7 +398,7 @@
     #    #print(value, end="")
 
 
-def scan_source_recursive(dirpath):
+def scan_source_recursive(dirpath, args):
     import os
     from os.path import join, splitext
 
@@ -426,7 +428,7 @@
                 filepath.endswith("md5.c")):
             continue
 
-        scan_source(filepath)
+        scan_source(filepath, args)
 
 
 if __name__ == "__main__":
@@ -439,10 +441,17 @@
         scan_source_recursive(os.path.join(SOURCE_DIR, "source", "blender", "modifiers"))
         sys.exit(0)
 
-    for filepath in sys.argv[1:]:
+    desc = 'Check C/C++ code for conformance with blenders style guide:\nhttp://wiki.blender.org/index.php/Dev:Doc/CodeStyle)'
+    parser = argparse.ArgumentParser(description=desc)
+    parser.add_argument("paths", nargs='+', help="list of files or directories to check")
+    parser.add_argument("-l", "--no-length-check", action="store_true",
+                        help="skip warnings for long lines")
+    args = parser.parse_args()
+
+    for filepath in args.paths:
         if os.path.isdir(filepath):
             # recursive search
-            scan_source_recursive(filepath)
+            scan_source_recursive(filepath, args)
         else:
             # single file
-            scan_source(filepath)
+            scan_source(filepath, args)




More information about the Bf-blender-cvs mailing list