Archimesh: Update panel Rename, replace deprecated imp call

Bumped version to 1.1.4
Replace the deprecated imp import with importlib
As a part of the task T50726:
Update the Panel rename code to more generic one
Note: there is the import sys and os that should be maybe
removed
This commit is contained in:
Vuk Gardašević 2017-05-05 00:12:41 +02:00
parent efa2c23a7e
commit 70529875c6
1 changed files with 52 additions and 29 deletions

View File

@ -29,7 +29,7 @@ bl_info = {
"name": "Archimesh",
"author": "Antonio Vazquez (antonioya)",
"location": "View3D > Add > Mesh > Archimesh",
"version": (1, 1, 3),
"version": (1, 1, 4),
"blender": (2, 6, 8),
"description": "Generate rooms, doors, windows, and other architecture objects",
"wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Archimesh",
@ -43,21 +43,21 @@ import os
# Import modules
# ----------------------------------------------
if "bpy" in locals():
import imp
imp.reload(achm_room_maker)
imp.reload(achm_door_maker)
imp.reload(achm_window_maker)
imp.reload(achm_roof_maker)
imp.reload(achm_column_maker)
imp.reload(achm_stairs_maker)
imp.reload(achm_kitchen_maker)
imp.reload(achm_shelves_maker)
imp.reload(achm_books_maker)
imp.reload(achm_lamp_maker)
imp.reload(achm_curtain_maker)
imp.reload(achm_venetian_maker)
imp.reload(achm_main_panel)
imp.reload(achm_window_panel)
import importlib
importlib.reload(achm_room_maker)
importlib.reload(achm_door_maker)
importlib.reload(achm_window_maker)
importlib.reload(achm_roof_maker)
importlib.reload(achm_column_maker)
importlib.reload(achm_stairs_maker)
importlib.reload(achm_kitchen_maker)
importlib.reload(achm_shelves_maker)
importlib.reload(achm_books_maker)
importlib.reload(achm_lamp_maker)
importlib.reload(achm_curtain_maker)
importlib.reload(achm_venetian_maker)
importlib.reload(achm_main_panel)
importlib.reload(achm_window_panel)
print("archimesh: Reloaded multifiles")
else:
from . import achm_books_maker
@ -80,9 +80,21 @@ else:
# noinspection PyUnresolvedReferences
import bpy
# noinspection PyUnresolvedReferences
from bpy.props import BoolProperty, FloatVectorProperty, IntProperty, FloatProperty
from bpy.props import (
BoolProperty,
FloatVectorProperty,
IntProperty,
FloatProperty,
StringProperty,
)
# noinspection PyUnresolvedReferences
from bpy.types import Menu, Scene, INFO_MT_mesh_add, WindowManager
from bpy.types import (
AddonPreferences,
Menu,
Scene,
INFO_MT_mesh_add,
WindowManager,
)
# ----------------------------------------------------------
# Decoration assets
@ -128,24 +140,34 @@ class AchmInfoMtMeshCustomMenuAdd(Menu):
# Register all operators and panels
# --------------------------------------------------------------
## Addons Preferences Update Panel
from bpy.types import (
AddonPreferences,
)
from bpy.props import (
StringProperty,
# Add-ons Preferences Update Panel
# Define Panel classes for updating
panels = (
achm_main_panel.ArchimeshMainPanel,
)
def update_panel(self, context):
message = "Archimesh: Updating Panel locations has failed"
try:
bpy.utils.unregister_class(achm_main_panel.ArchimeshMainPanel)
except:
for panel in panels:
if "bl_rna" in panel.__dict__:
bpy.utils.unregister_class(panel)
for panel in panels:
panel.bl_category = context.user_preferences.addons[__name__].preferences.category
bpy.utils.register_class(panel)
except Exception as e:
print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
pass
achm_main_panel.ArchimeshMainPanel.bl_category = context.user_preferences.addons[__name__].preferences.category
bpy.utils.register_class(achm_main_panel.ArchimeshMainPanel)
class Archi_Pref(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __name__
category = StringProperty(
@ -156,13 +178,14 @@ class Archi_Pref(AddonPreferences):
)
def draw(self, context):
layout = self.layout
row = layout.row()
col = row.column()
col.label(text="Tab Category:")
col.prop(self, "category", text="")
# Define menu
# noinspection PyUnusedLocal
def AchmMenu_func(self, context):