[Bf-blender-cvs] [bf010c4] master: Cleanup: pep8

Campbell Barton noreply at git.blender.org
Sun Jun 7 09:41:20 CEST 2015


Commit: bf010c4a15840964ec92912e5582095d029bc314
Author: Campbell Barton
Date:   Sun Jun 7 13:54:13 2015 +1000
Branches: master
https://developer.blender.org/rBbf010c4a15840964ec92912e5582095d029bc314

Cleanup: pep8

===================================================================

M	build_files/cmake/cmake_consistency_check.py
M	release/bin/blender-thumbnailer.py
M	release/scripts/modules/rna_info.py
M	release/scripts/modules/rna_xml.py
M	release/scripts/startup/bl_operators/mesh.py
M	release/scripts/templates_py/ui_previews_dynamic_enum.py
M	tests/python/bl_run_operators.py
M	tests/python/pep8.py
M	tests/python/rst_to_doctree_mini.py

===================================================================

diff --git a/build_files/cmake/cmake_consistency_check.py b/build_files/cmake/cmake_consistency_check.py
index 1a366880..d0bbdda 100755
--- a/build_files/cmake/cmake_consistency_check.py
+++ b/build_files/cmake/cmake_consistency_check.py
@@ -39,8 +39,6 @@ from cmake_consistency_check_config import (
 import os
 from os.path import join, dirname, normpath, splitext
 
-print("Scanning:", SOURCE_DIR)
-
 global_h = set()
 global_c = set()
 global_refs = {}
@@ -211,7 +209,7 @@ def cmake_get_src(f):
                                 if new_path_rel != l:
                                     print("overly relative path:\n  %s:%d\n  %s\n  %s" % (f, i, l, new_path_rel))
 
-                                    ## Save time. just replace the line
+                                    # # Save time. just replace the line
                                     # replace_line(f, i - 1, new_path_rel)
 
                             else:
@@ -242,10 +240,6 @@ def cmake_get_src(f):
     filen.close()
 
 
-for cmake in source_list(SOURCE_DIR, is_cmake):
-    cmake_get_src(cmake)
-
-
 def is_ignore(f):
     for ig in IGNORE:
         if ig in f:
@@ -253,73 +247,83 @@ def is_ignore(f):
     return False
 
 
-# First do stupid check, do these files exist?
-print("\nChecking for missing references:")
-is_err = False
-errs = []
-for f in (global_h | global_c):
-    if f.startswith(BUILD_DIR):
-        continue
-
-    if not os.path.exists(f):
-        refs = global_refs[f]
-        if refs:
-            for cf, i in refs:
-                errs.append((cf, i))
-        else:
-            raise Exception("CMake referenecs missing, internal error, aborting!")
-        is_err = True
-
-errs.sort()
-errs.reverse()
-for cf, i in errs:
-    print("%s:%d" % (cf, i))
-    # Write a 'sed' script, useful if we get a lot of these
-    # print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
-
-
-if is_err:
-    raise Exception("CMake referenecs missing files, aborting!")
-del is_err
-del errs
-
-# now check on files not accounted for.
-print("\nC/C++ Files CMake doesnt know about...")
-for cf in sorted(source_list(SOURCE_DIR, is_c)):
-    if not is_ignore(cf):
-        if cf not in global_c:
-            print("missing_c: ", cf)
-
-        # check if automake builds a corrasponding .o file.
-        '''
-        if cf in global_c:
-            out1 = os.path.splitext(cf)[0] + ".o"
-            out2 = os.path.splitext(cf)[0] + ".Po"
-            out2_dir, out2_file = out2 = os.path.split(out2)
-            out2 = os.path.join(out2_dir, ".deps", out2_file)
-            if not os.path.exists(out1) and not os.path.exists(out2):
-                print("bad_c: ", cf)
-        '''
-
-print("\nC/C++ Headers CMake doesnt know about...")
-for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
-    if not is_ignore(hf):
-        if hf not in global_h:
-            print("missing_h: ", hf)
-
-if UTF8_CHECK:
-    # test encoding
-    import traceback
-    for files in (global_c, global_h):
-        for f in sorted(files):
-            if os.path.exists(f):
-                # ignore outside of our source tree
-                if "extern" not in f:
-                    i = 1
-                    try:
-                        for l in open(f, "r", encoding="utf8"):
-                            i += 1
-                    except UnicodeDecodeError:
-                        print("Non utf8: %s:%d" % (f, i))
-                        if i > 1:
-                            traceback.print_exc()
+def main():
+
+    print("Scanning:", SOURCE_DIR)
+
+    for cmake in source_list(SOURCE_DIR, is_cmake):
+        cmake_get_src(cmake)
+
+    # First do stupid check, do these files exist?
+    print("\nChecking for missing references:")
+    is_err = False
+    errs = []
+    for f in (global_h | global_c):
+        if f.startswith(BUILD_DIR):
+            continue
+
+        if not os.path.exists(f):
+            refs = global_refs[f]
+            if refs:
+                for cf, i in refs:
+                    errs.append((cf, i))
+            else:
+                raise Exception("CMake referenecs missing, internal error, aborting!")
+            is_err = True
+
+    errs.sort()
+    errs.reverse()
+    for cf, i in errs:
+        print("%s:%d" % (cf, i))
+        # Write a 'sed' script, useful if we get a lot of these
+        # print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
+
+
+    if is_err:
+        raise Exception("CMake referenecs missing files, aborting!")
+    del is_err
+    del errs
+
+    # now check on files not accounted for.
+    print("\nC/C++ Files CMake doesnt know about...")
+    for cf in sorted(source_list(SOURCE_DIR, is_c)):
+        if not is_ignore(cf):
+            if cf not in global_c:
+                print("missing_c: ", cf)
+
+            # check if automake builds a corrasponding .o file.
+            '''
+            if cf in global_c:
+                out1 = os.path.splitext(cf)[0] + ".o"
+                out2 = os.path.splitext(cf)[0] + ".Po"
+                out2_dir, out2_file = out2 = os.path.split(out2)
+                out2 = os.path.join(out2_dir, ".deps", out2_file)
+                if not os.path.exists(out1) and not os.path.exists(out2):
+                    print("bad_c: ", cf)
+            '''
+
+    print("\nC/C++ Headers CMake doesnt know about...")
+    for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
+        if not is_ignore(hf):
+            if hf not in global_h:
+                print("missing_h: ", hf)
+
+    if UTF8_CHECK:
+        # test encoding
+        import traceback
+        for files in (global_c, global_h):
+            for f in sorted(files):
+                if os.path.exists(f):
+                    # ignore outside of our source tree
+                    if "extern" not in f:
+                        i = 1
+                        try:
+                            for l in open(f, "r", encoding="utf8"):
+                                i += 1
+                        except UnicodeDecodeError:
+                            print("Non utf8: %s:%d" % (f, i))
+                            if i > 1:
+                                traceback.print_exc()
+
+if __name__ == "__main__":
+    main()
diff --git a/release/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py
index 779c615..d3b31d6 100755
--- a/release/bin/blender-thumbnailer.py
+++ b/release/bin/blender-thumbnailer.py
@@ -170,7 +170,7 @@ def write_png(buf, width, height):
         png_pack(b'IEND', b'')])
 
 
-if __name__ == '__main__':
+def main():
     import sys
 
     if len(sys.argv) < 3:
@@ -186,3 +186,7 @@ if __name__ == '__main__':
             f = open(file_out, "wb")
             f.write(write_png(buf, width, height))
             f.close()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/release/scripts/modules/rna_info.py b/release/scripts/modules/rna_info.py
index ed80423..dae262e 100644
--- a/release/scripts/modules/rna_info.py
+++ b/release/scripts/modules/rna_info.py
@@ -696,7 +696,7 @@ def BuildRNAInfo():
     return InfoStructRNA.global_lookup, InfoFunctionRNA.global_lookup, InfoOperatorRNA.global_lookup, InfoPropertyRNA.global_lookup
 
 
-if __name__ == "__main__":
+def main():
     import rna_info
     struct = rna_info.BuildRNAInfo()[0]
     data = []
@@ -724,3 +724,7 @@ if __name__ == "__main__":
     else:
         text = bpy.data.texts.new(name="api.py")
         text.from_string(data)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py
index 729d623..ad4809e 100644
--- a/release/scripts/modules/rna_xml.py
+++ b/release/scripts/modules/rna_xml.py
@@ -32,7 +32,7 @@ def build_property_typemap(skip_classes, skip_typemap):
         if issubclass(cls, skip_classes):
             continue
 
-        ## to support skip-save we cant get all props
+        # # to support skip-save we cant get all props
         # properties = cls.bl_rna.properties.keys()
         properties = []
         for prop_id, prop in cls.bl_rna.properties.items():
diff --git a/release/scripts/startup/bl_operators/mesh.py b/release/scripts/startup/bl_operators/mesh.py
index f86c31c..ea504d4 100644
--- a/release/scripts/startup/bl_operators/mesh.py
+++ b/release/scripts/startup/bl_operators/mesh.py
@@ -75,7 +75,6 @@ class MeshMirrorUV(Operator):
                 double_warn += co in mirror_lt
                 mirror_lt[co] = i
 
-        #for i, v in enumerate(mesh.vertices):
         vmap = {}
         for mirror_a, mirror_b in ((mirror_gt, mirror_lt),
                                    (mirror_lt, mirror_gt)):
diff --git a/release/scripts/templates_py/ui_previews_dynamic_enum.py b/release/scripts/templates_py/ui_previews_dynamic_enum.py
index 5169b82..0cfa232 100644
--- a/release/scripts/templates_py/ui_previews_dynamic_enum.py
+++ b/release/scripts/templates_py/ui_previews_dynamic_enum.py
@@ -44,7 +44,7 @@ def enum_previews_from_directory_items(self, context):
     if directory and os.path.exists(directory):
         # Scan the directory for png files
         image_paths = []
-        for fn in  os.listdir(directory):
+        for fn in os.listdir(directory):
             if fn.lower().endswith(".png"):
                 image_paths.append(fn)
 
diff --git a/tests/python/bl_run_operators.py b/tests/python/bl_run_operators.py
index d511cd1..f3c553c 100644
--- a/tests/python/bl_run_operators.py
+++ b/tests/python/bl_run_operators.py
@@ -163,7 +163,7 @@ if USE_ATTRSET:
             if issubclass(cls, skip_classes):
                 continue
 
-            ## to support skip-save we cant get all props
+            # # to support skip-save we cant get all props
             # properties = cls.bl_rna.properties.keys()
             properties = []
             for prop_id, prop in cls.bl_rna.properties.items():
diff --git a/tests/python/pep8.py b/tests/python/pep8.py
index 551e2a8..0d6db72 100644
--- a/tests/python/pep8.py
+++ b/tests/python/pep8.py
@@ -117,7 +117,18 @@ def main():
 
     # these are very picky and often hard to follow
     # while keeping common script formatting.
-    ignore = "E122", "E123", "E124", "E125", "E126", "E127", "E128"
+  

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list