[Bf-extensions-cvs] [f86f25e6] master: POV: Code formatting and bugfixes

Maurice Raybaud noreply at git.blender.org
Wed Jun 9 03:13:18 CEST 2021


Commit: f86f25e62217264495d05f116ccb09d575fe9841
Author: Maurice Raybaud
Date:   Wed Jun 9 03:13:10 2021 +0200
Branches: master
https://developer.blender.org/rBAf86f25e62217264495d05f116ccb09d575fe9841

POV: Code formatting and bugfixes

* fix: more imports cleanup and formatting
* add: hair shape (from old MaterialStrand for now)
* add: pixel / Non Blender units strand width
* fix: an exception handling of df3_library
* fix: gas flow_type typo

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

M	render_povray/__init__.py
M	render_povray/base_ui.py
M	render_povray/df3_library.py
M	render_povray/object_curve_topology.py
M	render_povray/object_gui.py
M	render_povray/object_mesh_topology.py
M	render_povray/object_particles.py
M	render_povray/object_primitives.py
M	render_povray/object_properties.py
M	render_povray/render.py
M	render_povray/render_gui.py
M	render_povray/render_properties.py
M	render_povray/scenography.py
M	render_povray/scenography_gui.py
M	render_povray/scenography_properties.py
M	render_povray/scripting.py
M	render_povray/scripting_gui.py
M	render_povray/scripting_properties.py
M	render_povray/shading.py
M	render_povray/shading_gui.py
M	render_povray/shading_nodes.py
M	render_povray/shading_properties.py
M	render_povray/texturing.py
M	render_povray/texturing_gui.py
M	render_povray/texturing_properties.py
M	render_povray/update_files.py

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

diff --git a/render_povray/__init__.py b/render_povray/__init__.py
index f0734c5f..2bc4f420 100755
--- a/render_povray/__init__.py
+++ b/render_povray/__init__.py
@@ -94,7 +94,7 @@ scripting_gui.py :
     Display properties from scripting_properties.py for user to add his custom POV code
 
 scripting.py :
-    Insert POV native scene description elements to exported POV file
+    Insert POV native scene description elements into blender scene or to exported POV file
 
 df3_library.py
     Render smoke to *.df3 files
@@ -214,20 +214,26 @@ else:
         scripting_properties,
         render,
         object_primitives,  # for import and export of POV specific primitives
-        update_files,
     )
 
-###############################################################################
+# ---------------------------------------------------------------- #
 # Auto update.
-###############################################################################
+# ---------------------------------------------------------------- #
+
+
 class POV_OT_update_addon(bpy.types.Operator):
     """Update this addon to the latest version."""
 
     bl_idname = "pov.update_addon"
     bl_label = "Update POV addon"
 
-    def execute(self, context):
-        import os, tempfile, shutil, urllib.request, urllib.error, zipfile
+    def execute(self, context):  # sourcery no-metrics
+        import os
+        import tempfile
+        import shutil
+        import urllib.request
+        import urllib.error
+        import zipfile
 
         def recursive_overwrite(src, dest, ignore=None):
             if os.path.isdir(src):
@@ -250,7 +256,8 @@ class POV_OT_update_addon(bpy.types.Operator):
         with tempfile.TemporaryDirectory() as temp_dir_path:
             temp_zip_path = os.path.join(temp_dir_path, 'master.zip')
 
-            # Download zip archive of latest addons master branch commit (So we also get presets)
+            # Download zip archive of latest addons master branch commit
+            # More work needed so we also get files from the shared addons presets /pov folder
             # switch this URL back to the BF hosted one as soon as gitweb snapshot gets fixed
             url = 'https://github.com/blender/blender-addons/archive/refs/heads/master.zip'
             try:
@@ -303,7 +310,8 @@ class POV_OT_update_addon(bpy.types.Operator):
 
             # TODO: Create backup
 
-            # Delete old POV addon files (only directories and *.py files, the user might have other stuff in there!)
+            # Delete old POV addon files
+            # (only directories and *.py files, user might have other stuff in there!)
             print('Deleting old POV addon files')
             # remove __init__.py
             os.remove(os.path.join(render_povray_dir, '__init__.py'))
@@ -328,9 +336,9 @@ class POV_OT_update_addon(bpy.types.Operator):
         return {'FINISHED'}
 
 
-###############################################################################
+# ---------------------------------------------------------------- #
 # Povray Preferences.
-###############################################################################
+# ---------------------------------------------------------------- #
 
 
 class PovrayPreferences(bpy.types.AddonPreferences):
@@ -397,7 +405,10 @@ class PovrayPreferences(bpy.types.AddonPreferences):
         layout.operator("pov.update_addon", icon='FILE_REFRESH')
 
 
-classes = (POV_OT_update_addon, PovrayPreferences)
+classes = (
+    POV_OT_update_addon,
+    PovrayPreferences,
+)
 
 
 def register():
@@ -410,19 +421,15 @@ def register():
     texturing_properties.register()
     object_properties.register()
     scripting_properties.register()
-    scenography.register()
     render.register()
     base_ui.register()
-    scripting.register()
     object_primitives.register()
 
 
 def unregister():
     object_primitives.unregister()
-    scripting.unregister()
     base_ui.unregister()
     render.unregister()
-    scenography.unregister()
     scripting_properties.unregister()
     object_properties.unregister()
     texturing_properties.unregister()
@@ -437,6 +444,6 @@ def unregister():
 if __name__ == "__main__":
     register()
 
-# ------------8<---------[ BREAKPOINT ]--------------8<-----------#  Move this snippet around
-# __import__('code').interact(local=dict(globals(), **locals())) # < and uncomment this line
-# ----------------------------------------------------------------#  to inspect from Terminal
+# ------------8<---------[ BREAKPOINT ]--------------8<----------- #  Move this snippet around
+# __import__('code').interact(local=dict(globals(), **locals()))   # < and uncomment this line
+# ---------------------------------------------------------------- #  to inspect from Terminal
diff --git a/render_povray/base_ui.py b/render_povray/base_ui.py
index 85374ba3..967080fa 100755
--- a/render_povray/base_ui.py
+++ b/render_povray/base_ui.py
@@ -51,12 +51,13 @@ from . import (
     texturing_gui,
     shading_nodes,  # for POV specific nodes
     scripting_gui,
+    update_files,
 )
 
 
-############# POV-Centric WORKSPACE #############
+# ------------ POV-Centric WORKSPACE ------------ #
 @persistent
-def povCentricWorkspace(dummy):
+def pov_centric_moray_like_workspace(dummy):
     """Set up a POV centric Workspace if addon was activated and saved as default renderer.
 
     This would bring a ’_RestrictData’ error because UI needs to be fully loaded before
@@ -121,8 +122,8 @@ def povCentricWorkspace(dummy):
                                 override['area'] = area
                                 override['region'] = region
 
-                                area_x = area.x + (area.width / 2)
-                                area_y = area.y + area.height
+                                # area_x = area.x + (area.width / 2)
+                                # area_y = area.y + area.height
                                 bpy.ops.screen.space_type_set_or_cycle(override, space_type='INFO')
                                 try:
                                     if area == pov_workspace[6] and bpy.ops.screen.area_move.poll(
@@ -219,7 +220,7 @@ def povCentricWorkspace(dummy):
             "\nThe factory 'Scripting' workspace is needed before POV centric "
             "\nworkspace may activate when POV is set as your default renderer"
         )
-    ####################################UTF-8###################################
+    # -----------------------------------UTF-8---------------------------------- #
     # Check and fix all strings in current .blend file to be valid UTF-8 Unicode
     # sometimes needed for old, 2.4x / 2.6x area files
     bpy.ops.wm.blend_strings_utf8_validate()
@@ -237,10 +238,8 @@ def check_material(mat):
 
 
 def simple_material(mat):
-    """Test if a material uses nodes."""
-    if (mat is not None) and (not mat.use_nodes):
-        return True
-    return False
+    """Test if a material is nodeless."""
+    return (mat is not None) and (not mat.use_nodes)
 
 
 def pov_context_tex_datablock(context):
@@ -282,6 +281,7 @@ def pov_context_tex_datablock(context):
 
 
 def register():
+    update_files.register()
     render_gui.register()
     scenography_gui.register()
     object_gui.register()
@@ -290,13 +290,13 @@ def register():
     shading_nodes.register()
     scripting_gui.register()
 
-    if not povCentricWorkspace in bpy.app.handlers.load_post:
-        bpy.app.handlers.load_post.append(povCentricWorkspace)
+    if pov_centric_moray_like_workspace not in bpy.app.handlers.load_post:
+        bpy.app.handlers.load_post.append(pov_centric_moray_like_workspace)
 
 
 def unregister():
-    if povCentricWorkspace in bpy.app.handlers.load_post:
-        bpy.app.handlers.load_post.remove(povCentricWorkspace)
+    if pov_centric_moray_like_workspace in bpy.app.handlers.load_post:
+        bpy.app.handlers.load_post.remove(pov_centric_moray_like_workspace)
 
     scripting_gui.unregister()
     shading_nodes.unregister()
@@ -305,3 +305,4 @@ def unregister():
     object_gui.unregister()
     scenography_gui.unregister()
     render_gui.unregister()
+    update_files.unregister()
diff --git a/render_povray/df3_library.py b/render_povray/df3_library.py
index f802fb2d..b5525741 100755
--- a/render_povray/df3_library.py
+++ b/render_povray/df3_library.py
@@ -19,7 +19,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 #
-################################################################################
+# -----------------------------------------------------------------------------
 #
 # Creation functions
 #     __init__(x=1, y=1, z=1) : default constructor
@@ -42,13 +42,12 @@
 #     exportDF3():
 #     importDF3():
 #
-################################################################################
+# -----------------------------------------------------------------------------
 
 import struct
 import os
 import stat
 import array
-import sys
 
 # -+-+-+- Start df3 Class -+-+-+-
 
@@ -78,7 +77,7 @@ class df3:
             self.voxel[i] = indf3.voxel[i]
         return self
 
-    #### Info Functions
+    # --- Info Functions
 
     def sizeX(self):
         return self.maxX
@@ -90,13 +89,12 @@ class df3:
         return self.maxZ
 
     def size(self):
-        tmp = []
-        tmp.append(self.sizeX())
+        tmp = [self.sizeX()]
         tmp.append(self.sizeY())
         tmp.append(self.sizeZ())
         return tmp
 
-    #### Voxel Access Functions
+    # --- Voxel Access Functions
 
     def get(self, x, y, z):
         return self.voxel[self.__voxa__(x, y, z)]
@@ -124,7 +122,7 @@ class df3:
 
         self.voxel[self.__voxa__(x, y, z)] = val
 
-    #### Scalar Functions
+    # --- Scalar Functions
 
     def mult(self, val):
         for i in range(self.sizeX() * self.sizeY() * self.sizeZ()):
@@ -156,7 +154,7 @@ class df3:
 
         return tmp
 
-    #### Vector Functions
+    # --- Vector Functions
 
     def compare(self, indf3):
         if self.__samesize__(indf3) == 0:
@@ -221,7 +219,7 @@ class df3:
 
         return self
 
-    #### Import/Export Functions
+    # --- Import/Export Functions
 
     def exportDF3(self, file, depth=8, rescale=1):
      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list