[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2794] trunk/py/scripts/addons/ render_copy_settings: pep8 edits and a few other code styling.

Bastien Montagne montagne29 at wanadoo.fr
Mon Dec 19 15:38:11 CET 2011


Revision: 2794
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2794
Author:   mont29
Date:     2011-12-19 14:38:06 +0000 (Mon, 19 Dec 2011)
Log Message:
-----------
pep8 edits and a few other code styling. Non functionnaly changes.

Modified Paths:
--------------
    trunk/py/scripts/addons/render_copy_settings/__init__.py
    trunk/py/scripts/addons/render_copy_settings/operator.py
    trunk/py/scripts/addons/render_copy_settings/panel.py
    trunk/py/scripts/addons/render_copy_settings/presets.py

Modified: trunk/py/scripts/addons/render_copy_settings/__init__.py
===================================================================
--- trunk/py/scripts/addons/render_copy_settings/__init__.py	2011-12-19 14:19:23 UTC (rev 2793)
+++ trunk/py/scripts/addons/render_copy_settings/__init__.py	2011-12-19 14:38:06 UTC (rev 2794)
@@ -33,30 +33,23 @@
 #      Renamed in “Render Copy Settings”.
 #      Huge changes:
 #        * It is now possible to individually copy each render setting.
-#        * It is now possible to individually select each affected scene, and then filter them out
-#          even further with a regex.
-#      WARNING: this addon now needs a Blender patched with the ui_template_list diff, else it won’t
-#               be fully functional…
+#        * It is now possible to individually select each affected scene, and
+#          then filter them out even further with a regex.
 #
 #  0.1.1
 #      Minor changes:
 #        * PEP8 compliant.
 #        * Moved to contrib…
-#      WARNING: this addon now needs a Blender patched with the ui_template_list diff, else it won’t
-#               be fully functional (even though working)…
 #
 #  0.1.2
 #      Minor changes:
-#        * Updated accordingly to the changes in enhanced ui_template_list proposal.
-#      WARNING: this addon now needs a Blender patched with the ui_template_list diff, else it won’t
-#               be fully functional (even though working)…
+#        * Updated accordingly to the changes in enhanced ui_template_list
+#          proposal.
 #
 #  0.1.3
 #      Minor changes:
-#        * Fixed a small bug that was disabling the whole UI when entering a filtering regex
-#          matching no scene.
-#      WARNING: this addon now needs a Blender patched with the ui_template_list diff, else it won’t
-#               be fully functional (even though working)…
+#        * Fixed a small bug that was disabling the whole UI when entering a
+#          filtering regex matching no scene.
 #
 # ##### END OF CHANGELOG #####
 
@@ -67,10 +60,12 @@
     "blender": (2, 6, 1),
     "api": 42648,
     "location": "Render buttons (Properties window)",
-    "description": "Allows to copy a selection of render settings from current scene to others.",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/"\
+    "description": "Allows to copy a selection of render settings from " \
+                   "current scene to others.",
+    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" \
                 "Scripts/Render/Copy Settings",
-    "tracker_url": "http://projects.blender.org/tracker/index.php?func=detail&aid=25832",
+    "tracker_url": "http://projects.blender.org/tracker/index.php?" \
+                   "func=detail&aid=25832",
     "category": "Render"}
 
 
@@ -84,28 +79,32 @@
 
 
 import bpy
-from bpy.props import StringProperty, BoolProperty, IntProperty, CollectionProperty
+from bpy.props import StringProperty, BoolProperty, \
+                      IntProperty, CollectionProperty
 
 
-####################################################################################################
-# Global properties for the script, for UI (as there’s no way to let them in the operator…).
-####################################################################################################
+###############################################################################
+# Global properties for the script, for UI (as there’s no way to let them in
+# the operator…).
+###############################################################################
 
 class RenderCopySettingsScene(bpy.types.PropertyGroup):
     allowed = BoolProperty(default=True)
 
-    # A string of identifiers (colon delimited) which property’s controls should be displayed
-    # in a template_list.
-    template_list_controls = StringProperty(default="allowed", options={"HIDDEN"})
+    # A string of identifiers (colon delimited) which property’s controls
+    # should be displayed in a template_list.
+    template_list_controls = StringProperty(default="allowed",
+                                            options={"HIDDEN"})
 
 
 class RenderCopySettingsSetting(bpy.types.PropertyGroup):
     strid = StringProperty(default="")
     copy = BoolProperty(default=False)
 
-    # A string of identifiers (colon delimited) which property’s controls should be displayed
-    # in a template_list.
-    template_list_controls = StringProperty(default="copy", options={"HIDDEN"})
+    # A string of identifiers (colon delimited) which property’s controls
+    # should be displayed in a template_list.
+    template_list_controls = StringProperty(default="copy",
+                                            options={"HIDDEN"})
 
 
 class RenderCopySettings(bpy.types.PropertyGroup):
@@ -113,7 +112,9 @@
     #      It should only contain one element for each render setting.
     affected_settings = CollectionProperty(type=RenderCopySettingsSetting,
                                            name="Affected Settings",
-                                           description="The list of all available render settings")
+                                           description="The list of all " \
+                                                       "available render " \
+                                                       "settings")
     # XXX Unused, but needed for template_list…
     aff_sett_idx = IntProperty()
 
@@ -121,12 +122,14 @@
     #      It should only contain one element for each scene.
     allowed_scenes = CollectionProperty(type=RenderCopySettingsScene,
                                         name="Allowed Scenes",
-                                        description="The list all scenes in the file")
+                                        description="The list all scenes " \
+                                                    "in the file")
     # XXX Unused, but needed for template_list…
     allw_scenes_idx = IntProperty()
 
     filter_scene = StringProperty(name="Filter Scene",
-                                  description="Regex to only affect scenes which name matches it",
+                                  description="Regex to only affect scenes " \
+                                              "which name matches it",
                                   default="")
 
 

Modified: trunk/py/scripts/addons/render_copy_settings/operator.py
===================================================================
--- trunk/py/scripts/addons/render_copy_settings/operator.py	2011-12-19 14:19:23 UTC (rev 2793)
+++ trunk/py/scripts/addons/render_copy_settings/operator.py	2011-12-19 14:38:06 UTC (rev 2794)
@@ -21,13 +21,14 @@
 import bpy
 from . import presets
 
-# These operators are only defined because it seems impossible to directly edit properties from
-# UI code…
+# These operators are only defined because it seems impossible to directly
+# edit properties from UI code…
 
 
 # A sorting func for collections (working in-place).
 # XXX Not optimized at all…
-# XXX If some items in the collection do not have the sortkey property, they are just ignored…
+# XXX If some items in the collection do not have the sortkey property,
+#     they are just ignored…
 def collection_property_sort(collection, sortkey, start_idx=0):
     while start_idx + 1 < len(collection):
         while not hasattr(collection[start_idx], sortkey):
@@ -49,8 +50,8 @@
 
 class RenderCopySettingsPrepare(bpy.types.Operator):
     '''
-    Prepare internal data for render_copy_settings (gathering all existing render settings,
-    and scenes)
+    Prepare internal data for render_copy_settings (gathering all existing
+    render settings, and scenes)
     '''
     bl_idname = "scene.render_copy_settings_prepare"
     bl_label = "Render: Copy Settings Prepare"
@@ -63,7 +64,8 @@
     def execute(self, context):
         cp_sett = context.scene.render_copy_settings
 
-        # Get all available render settings, and update accordingly affected_settings…
+        # Get all available render settings, and update accordingly
+        # affected_settings…
         props = {}
         for prop in context.scene.render.bl_rna.properties:
             if prop.identifier in {'rna_type'}:
@@ -74,7 +76,7 @@
         corr = 0
         for i, sett in enumerate(cp_sett.affected_settings):
             if sett.strid not in props:
-                cp_sett.affected_settings.remove(i-corr)
+                cp_sett.affected_settings.remove(i - corr)
                 corr += 1
             else:
                 del props[sett.strid]
@@ -92,18 +94,19 @@
                 try:
                     regex = re.compile(cp_sett.filter_scene)
                 except Exception as e:
-                    self.report('ERROR_INVALID_INPUT', "The filter-scene regex " \
-                                "did not compile:\n    (%s)." % str(e))
+                    self.report('ERROR_INVALID_INPUT', "The filter-scene " \
+                                "regex did not compile:\n    (%s)." % str(e))
                     return {'CANCELLED'}
             except:
                 regex = None
-                self.report('WARNING', "Unable to import the re module. Regex " \
-                            "scene filtering will be disabled!")
+                self.report('WARNING', "Unable to import the re module. " \
+                            "Regex scene filtering will be disabled!")
         scenes = set()
         for scene in bpy.data.scenes:
             if scene == bpy.context.scene:  # Exclude current scene!
                 continue
-            if regex:  # If a valid filtering regex, only keep scenes matching it.
+            # If a valid filtering regex, only keep scenes matching it.
+            if regex:
                 if regex.match(scene.name):
                     scenes.add(scene.name)
             else:
@@ -163,7 +166,8 @@
 
 def do_copy(context, affected_settings, allowed_scenes):
     # Stores render settings from current scene.
-    p = {sett: getattr(context.scene.render, sett) for sett in affected_settings}
+    p = {sett: getattr(context.scene.render, sett) \
+         for sett in affected_settings}
     # put it in all other (valid) scenes’ render settings!
     for scene in bpy.data.scenes:
         # If scene not in allowed scenes, skip.
@@ -188,9 +192,12 @@
     def execute(self, context):
         regex = None

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-extensions-cvs mailing list