[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50398] trunk/blender: code cleanup: python - pass multiple args to string startswith() / endswith() functions rather than calling multiple times.

Campbell Barton ideasman42 at gmail.com
Tue Sep 4 22:26:42 CEST 2012


Revision: 50398
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50398
Author:   campbellbarton
Date:     2012-09-04 20:26:42 +0000 (Tue, 04 Sep 2012)
Log Message:
-----------
code cleanup: python - pass multiple args to string startswith() / endswith() functions rather than calling multiple times.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/addon_utils.py
    trunk/blender/source/blender/makesrna/rna_cleanup/rna_cleaner.py
    trunk/blender/source/tests/pep8.py
    trunk/blender/source/tools/codereview_upload.py

Modified: trunk/blender/release/scripts/modules/addon_utils.py
===================================================================
--- trunk/blender/release/scripts/modules/addon_utils.py	2012-09-04 19:42:09 UTC (rev 50397)
+++ trunk/blender/release/scripts/modules/addon_utils.py	2012-09-04 20:26:42 UTC (rev 50398)
@@ -148,7 +148,7 @@
     for path in path_list:
 
         # force all contrib addons to be 'TESTING'
-        if path.endswith("addons_contrib") or path.endswith("addons_extern"):
+        if path.endswith(("addons_contrib", "addons_extern")):
             force_support = 'TESTING'
         else:
             force_support = None

Modified: trunk/blender/source/blender/makesrna/rna_cleanup/rna_cleaner.py
===================================================================
--- trunk/blender/source/blender/makesrna/rna_cleanup/rna_cleaner.py	2012-09-04 19:42:09 UTC (rev 50397)
+++ trunk/blender/source/blender/makesrna/rna_cleanup/rna_cleaner.py	2012-09-04 20:26:42 UTC (rev 50398)
@@ -60,7 +60,7 @@
         usage()
     if sys.argv[1] == '-h':
         help()
-    elif not (sys.argv[1].endswith(".txt") or sys.argv[1].endswith(".py")):
+    elif not sys.argv[1].endswith((".txt", ".py")):
         print ('\nBad input file extension... exiting.')
         usage()
     else:

Modified: trunk/blender/source/tests/pep8.py
===================================================================
--- trunk/blender/source/tests/pep8.py	2012-09-04 19:42:09 UTC (rev 50397)
+++ trunk/blender/source/tests/pep8.py	2012-09-04 20:26:42 UTC (rev 50398)
@@ -43,7 +43,7 @@
 def file_list_py(path):
     for dirpath, dirnames, filenames in os.walk(path):
         for filename in filenames:
-            if filename.endswith(".py") or filename.endswith(".cfg"):
+            if filename.endswith((".py", ".cfg")):
                 yield os.path.join(dirpath, filename)
 
 

Modified: trunk/blender/source/tools/codereview_upload.py
===================================================================
--- trunk/blender/source/tools/codereview_upload.py	2012-09-04 19:42:09 UTC (rev 50397)
+++ trunk/blender/source/tools/codereview_upload.py	2012-09-04 20:26:42 UTC (rev 50398)
@@ -845,7 +845,7 @@
     """
     files = {}
     for line in diff.splitlines(True):
-      if line.startswith('Index:') or line.startswith('Property changes on:'):
+      if line.startswith(('Index:', 'Property changes on:')):
         unused, filename = line.split(':', 1)
         # On Windows if a file has property changes its filename uses '\'
         # instead of '/'.
@@ -996,7 +996,7 @@
     data = RunShell(cmd)
     count = 0
     for line in data.splitlines():
-      if line.startswith("Index:") or line.startswith("Property changes on:"):
+      if line.startswith(("Index:", "Property changes on:")):
         count += 1
         logging.info(line)
     if not count:




More information about the Bf-blender-cvs mailing list