[Bf-extensions-cvs] [e93499db] master: Fix T51618: Add a warning message override, poll check

lijenstina noreply at git.blender.org
Sat Jul 15 08:56:47 CEST 2017


Commit: e93499db2ffc93f41d7374004f002b5b0813e1ad
Author: lijenstina
Date:   Sat Jul 15 08:55:54 2017 +0200
Branches: master
https://developer.blender.org/rBAe93499db2ffc93f41d7374004f002b5b0813e1ad

Fix T51618: Add a warning message override, poll check

Bumped version to 1.0.2
Add a poll for the bpy.app.path is not an empty string
that can happen if the file is not saved
Add and override to the warning_messages that will allow to
show up the message no matter what the setting is
Small UI fixes

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

M	materials_utils/__init__.py
M	materials_utils/material_converter.py
M	materials_utils/materials_cycles_converter.py
M	materials_utils/texture_rename.py
M	materials_utils/warning_messages_utils.py

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

diff --git a/materials_utils/__init__.py b/materials_utils/__init__.py
index 09342408..c001a882 100644
--- a/materials_utils/__init__.py
+++ b/materials_utils/__init__.py
@@ -15,24 +15,24 @@
 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ##### END GPL LICENSE BLOCK #####
+
 #  (c) 2016 meta-androcto, parts based on work by Saidenka, lijenstina
-#           Materials Utils: by MichaleW, lijenstina,
-#                           (some code thanks to: CoDEmanX, SynaGl0w,
-#                                                 ideasman42)
-#           Materials Conversion: Silvio Falcinelli, johnzero7#,
-#                                  fixes by angavrilov and others
-#           Link to base names: Sybren, Texture renamer: Yadoob
+#  Materials Utils: by MichaleW, lijenstina,
+#       (some code thanks to: CoDEmanX, SynaGl0w, ideasman42)
+#  Materials Conversion: Silvio Falcinelli, johnzero7#,
+#        fixes by angavrilov and others
+#  Link to base names: Sybren, Texture renamer: Yadoob
 
 bl_info = {
     "name": "Materials Utils Specials",
     "author": "Community",
-    "version": (1, 0, 1),
+    "version": (1, 0, 2),
     "blender": (2, 77, 0),
-    "location": "Materials Properties Specials/Shift Q",
-    "description": "Materials Utils & Convertors",
+    "location": "Materials Properties Specials > Shift Q",
+    "description": "Materials Utils and Convertors",
     "warning": "",
-    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/Materials_Utils",
-    "tracker_url": "",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+                "Scripts/3D_interaction/Materials_Utils",
     "category": "Material"
     }
 
@@ -51,29 +51,30 @@ else:
 import bpy
 import os
 from os import (
-            path as os_path,
-            access as os_access,
-            remove as os_remove,
-            )
+        path as os_path,
+        access as os_access,
+        remove as os_remove,
+        )
 from bpy.props import (
-            StringProperty,
-            BoolProperty,
-            EnumProperty,
-            )
+        StringProperty,
+        BoolProperty,
+        EnumProperty,
+        PointerProperty,
+        )
 from bpy.types import (
-            Menu,
-            Operator,
-            Panel,
-            AddonPreferences,
-            PropertyGroup,
-            )
+        Menu,
+        Operator,
+        Panel,
+        AddonPreferences,
+        PropertyGroup,
+        )
 from .warning_messages_utils import (
-            warning_messages,
-            c_data_has_materials,
-            )
+        warning_messages,
+        c_data_has_materials,
+        )
 
 
-# Functions #
+# Functions
 
 def fake_user_set(fake_user='ON', materials='UNUSED', operator=None):
     warn_mesg, w_mesg = '', ""
@@ -420,8 +421,7 @@ def cleanmatslots(operator=None):
             bpy.ops.object.mode_set(mode='EDIT')
 
 
-# separate edit mode mesh function
-# (faster than iterating through all faces)
+# separate edit mode mesh function (faster than iterating through all faces)
 
 def assign_mat_mesh_edit(matname="Default", operator=None):
     actob = bpy.context.active_object
@@ -733,8 +733,7 @@ def remove_materials_all(operator=None):
 class VIEW3D_OT_show_mat_preview(Operator):
     bl_label = "Preview Active Material"
     bl_idname = "view3d.show_mat_preview"
-    bl_description = ("Show the preview of Active Material \n"
-                      "and context related settings")
+    bl_description = "Show the preview of Active Material and context related settings"
     bl_options = {'REGISTER', 'UNDO'}
 
     is_not_undo = False     # prevent drawing props on undo
@@ -1193,9 +1192,8 @@ class VIEW3D_OT_fake_user_set(Operator):
 class MATERIAL_OT_set_transparent_back_side(Operator):
     bl_idname = "material.set_transparent_back_side"
     bl_label = "Transparent back (BI)"
-    bl_description = ("Creates BI nodes with Alpha output connected to"
-                      "Front/Back Geometry node \n"
-                      "on Object's Active Material Slot")
+    bl_description = ("Creates BI nodes with Alpha output connected to Front/Back\n"
+                      "Geometry node on Object's Active Material Slot")
     bl_options = {'REGISTER', 'UNDO'}
 
     @classmethod
@@ -1346,8 +1344,7 @@ class MATERIAL_OT_link_to_base_names(Operator):
         return context.window_manager.invoke_props_dialog(self)
 
     def replace_name(self):
-        # use the chosen material as a base one
-        # check if there is a name
+        # use the chosen material as a base one, check if there is a name
         self.check_no_name = (False if self.mat_keep in {""} else True)
 
         if self.check_no_name is True:
@@ -1356,7 +1353,7 @@ class MATERIAL_OT_link_to_base_names(Operator):
                 if name == self.mat_keep:
                     try:
                         base, suffix = name.rsplit('.', 1)
-                        # trigger the except
+                        # trigger the exception
                         num = int(suffix, 10)
                         self.mat_keep = base
                         mat.name = self.mat_keep
@@ -1376,7 +1373,7 @@ class MATERIAL_OT_link_to_base_names(Operator):
         base, suffix = name.rsplit('.', 1)
 
         try:
-            # trigger the except
+            # trigger the exception
             num = int(suffix, 10)
         except ValueError:
             # Not a numeric suffix
@@ -1442,18 +1439,17 @@ class MATERIAL_OT_link_to_base_names(Operator):
 class MATERIAL_OT_check_converter_path(Operator):
     bl_idname = "material.check_converter_path"
     bl_label = "Check Converters images/data save path"
-    bl_description = ("Checks if the given path is writeable \n"
-                      "(has OS writing privileges)")
+    bl_description = "Check if the given path is writeable (has OS writing privileges)"
     bl_options = {'REGISTER', 'INTERNAL'}
 
-    @classmethod
-    def poll(cls, context):
-        return True
-
     def check_valid_path(self, context):
         sc = context.scene
         paths = bpy.path.abspath(sc.mat_specials.conv_path)
 
+        if bpy.data.filepath == "":
+            warning_messages(self, "DIR_PATH_EMPTY", override=True)
+            return False
+
         if os_path.exists(paths):
             if os_access(paths, os.W_OK | os.X_OK):
                 try:
@@ -1463,13 +1459,13 @@ class MATERIAL_OT_check_converter_path(Operator):
                     os_remove(path_test)
                     return True
                 except (OSError, IOError):
-                    warning_messages(self, 'DIR_PATH_W_ERROR')
+                    warning_messages(self, 'DIR_PATH_W_ERROR', override=True)
                     return False
             else:
-                warning_messages(self, 'DIR_PATH_A_ERROR')
+                warning_messages(self, 'DIR_PATH_A_ERROR', override=True)
                 return False
         else:
-            warning_messages(self, 'DIR_PATH_N_ERROR')
+            warning_messages(self, 'DIR_PATH_N_ERROR', override=True)
             return False
 
         return True
@@ -1477,13 +1473,13 @@ class MATERIAL_OT_check_converter_path(Operator):
     def execute(self, context):
         if not self.check_valid_path(context):
             return {'CANCELLED'}
-        else:
-            warning_messages(self, 'DIR_PATH_W_OK')
+
+        warning_messages(self, 'DIR_PATH_W_OK', override=True)
 
         return {'FINISHED'}
 
 
-# Menu classes #
+# Menu classes
 
 class VIEW3D_MT_assign_material(Menu):
     bl_label = "Assign Material"
@@ -1759,19 +1755,17 @@ class MATERIAL_PT_scenemassive(Panel):
                        text="Convert All to Cycles", icon='MATERIAL')
         split.operator("ml.refresh_active",
                        text="Convert Active to Cycles", icon='MATERIAL')
-        box = box.box()
-        ml_restore = box.operator("ml.restore",
-                                  text="To BI Nodes Off",
+        row = box.row()
+        ml_restore = row.operator("ml.restore", text="To BI Nodes Off",
                                   icon='MATERIAL')
         ml_restore.switcher = False
         ml_restore.renderer = "BI"
 
-        row = layout.row()
-        box = row.box()
-        box.menu("scenemassive.opt", text="Advanced Options", icon='SCRIPTWIN')
-        box = row.box()
-        box.menu("help.biconvert",
-                 text="Usage Information Guide", icon='MOD_EXPLODE')
+        box = layout.box()
+        row = box.row()
+        row.menu("scenemassive.opt", text="Advanced Options", icon='SCRIPTWIN')
+        row.menu("help.biconvert",
+                 text="Usage Information Guide", icon="INFO")
 
         box = layout.box()
         box.label("Save Directory")
@@ -1804,18 +1798,15 @@ class MATERIAL_PT_xps_convert(Panel):
         split.operator("xps_tools.convert_to_cycles_selected",
                        text="Convert Selected to Nodes", icon="TEXTURE")
 
-        col = layout.column()
-        row = col.row()
-        box = row.box()
-        ml_restore = box.operator("ml.restore",
-                                  text="To BI Nodes ON",
+        box = layout.box()
+        row = box.row()
+        ml_restore = row.operator("ml.restore", text="To BI Nodes ON",
                                   icon='MATERIAL')
         ml_restore.switcher = True
         ml_restore.renderer = "BI"
 
-        box = row.box()
-        box.menu("help.nodeconvert",
-                 text="Usage Information Guide", icon="MOD_EXPLODE")
+        row.menu("help.nodeconvert",
+                 text="Usage Information Guide", icon="INFO")
 
 
 # Converters Help #
@@ -1891,7 +1882,7 @@ class MATERIAL_MT_nodeconv_help(Menu):
         layout.label(text="Convert Materials/Image Textures from Imports:", icon="INFO")
 
 
-# Make Report #
+# Make Report
 class material_converter_report(Operator):
     bl_idname = "mat_converter.reports"
     bl_label = "Material Converter Report"
@@ -1902,14 +1893,12 @@ class material_converter_report(Operator):
 
     def draw(self, context):
         layout = self.layout
-        box = layout.box()
-
-        box.label(text="Converter

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list