minor edits to recent fix for addons
This commit is contained in:
parent
f7c8ea702f
commit
c658b74db5
@ -33,11 +33,7 @@ import bpy as _bpy
|
|||||||
|
|
||||||
error_duplicates = False
|
error_duplicates = False
|
||||||
error_encoding = False
|
error_encoding = False
|
||||||
|
addons_fake_modules = {}
|
||||||
_addons_fake_modules = {}
|
|
||||||
|
|
||||||
def module_get(mod_name):
|
|
||||||
return _addons_fake_modules[mod_name]
|
|
||||||
|
|
||||||
|
|
||||||
def paths():
|
def paths():
|
||||||
|
@ -27,9 +27,6 @@ from bpy.props import (StringProperty,
|
|||||||
EnumProperty,
|
EnumProperty,
|
||||||
)
|
)
|
||||||
|
|
||||||
import addon_utils
|
|
||||||
import os
|
|
||||||
|
|
||||||
from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear
|
from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear
|
||||||
|
|
||||||
|
|
||||||
@ -758,6 +755,7 @@ class WM_OT_path_open(Operator):
|
|||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
filepath = bpy.path.abspath(self.filepath)
|
filepath = bpy.path.abspath(self.filepath)
|
||||||
@ -1102,6 +1100,7 @@ class WM_OT_appconfig_default(Operator):
|
|||||||
bl_label = "Default Application Configuration"
|
bl_label = "Default Application Configuration"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import os
|
||||||
|
|
||||||
context.window_manager.keyconfigs.active = context.window_manager.keyconfigs.default
|
context.window_manager.keyconfigs.active = context.window_manager.keyconfigs.default
|
||||||
|
|
||||||
@ -1123,6 +1122,7 @@ class WM_OT_appconfig_activate(Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import os
|
||||||
bpy.utils.keyconfig_set(self.filepath)
|
bpy.utils.keyconfig_set(self.filepath)
|
||||||
|
|
||||||
filepath = self.filepath.replace("keyconfig", "interaction")
|
filepath = self.filepath.replace("keyconfig", "interaction")
|
||||||
@ -1150,6 +1150,7 @@ class WM_OT_copy_prev_settings(Operator):
|
|||||||
bl_label = "Copy Previous Settings"
|
bl_label = "Copy Previous Settings"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
ver = bpy.app.version
|
ver = bpy.app.version
|
||||||
ver_old = ((ver[0] * 100) + ver[1]) - 1
|
ver_old = ((ver[0] * 100) + ver[1]) - 1
|
||||||
@ -1608,6 +1609,8 @@ class WM_OT_addon_enable(Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import addon_utils
|
||||||
|
|
||||||
mod = addon_utils.enable(self.module)
|
mod = addon_utils.enable(self.module)
|
||||||
|
|
||||||
if mod:
|
if mod:
|
||||||
@ -1637,6 +1640,8 @@ class WM_OT_addon_disable(Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import addon_utils
|
||||||
|
|
||||||
addon_utils.disable(self.module)
|
addon_utils.disable(self.module)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -1690,6 +1695,7 @@ class WM_OT_addon_install(Operator):
|
|||||||
os.remove(f_full)
|
os.remove(f_full)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import addon_utils
|
||||||
import traceback
|
import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
@ -1725,7 +1731,7 @@ class WM_OT_addon_install(Operator):
|
|||||||
del pyfile_dir
|
del pyfile_dir
|
||||||
# done checking for exceptional case
|
# done checking for exceptional case
|
||||||
|
|
||||||
addons_old = {mod.__name__ for mod in addon_utils.modules(addon_utils._addons_fake_modules)}
|
addons_old = {mod.__name__ for mod in addon_utils.modules(addon_utils.addons_fake_modules)}
|
||||||
|
|
||||||
#check to see if the file is in compressed format (.zip)
|
#check to see if the file is in compressed format (.zip)
|
||||||
if zipfile.is_zipfile(pyfile):
|
if zipfile.is_zipfile(pyfile):
|
||||||
@ -1774,7 +1780,7 @@ class WM_OT_addon_install(Operator):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
addons_new = {mod.__name__ for mod in addon_utils.modules(addon_utils._addons_fake_modules)} - addons_old
|
addons_new = {mod.__name__ for mod in addon_utils.modules(addon_utils.addons_fake_modules)} - addons_old
|
||||||
addons_new.discard("modules")
|
addons_new.discard("modules")
|
||||||
|
|
||||||
# disable any addons we may have enabled previously and removed.
|
# disable any addons we may have enabled previously and removed.
|
||||||
@ -1784,7 +1790,7 @@ class WM_OT_addon_install(Operator):
|
|||||||
|
|
||||||
# possible the zip contains multiple addons, we could disallow this
|
# possible the zip contains multiple addons, we could disallow this
|
||||||
# but for now just use the first
|
# but for now just use the first
|
||||||
for mod in addon_utils.modules(addon_utils._addons_fake_modules):
|
for mod in addon_utils.modules(addon_utils.addons_fake_modules):
|
||||||
if mod.__name__ in addons_new:
|
if mod.__name__ in addons_new:
|
||||||
info = addon_utils.module_bl_info(mod)
|
info = addon_utils.module_bl_info(mod)
|
||||||
|
|
||||||
@ -1818,7 +1824,9 @@ class WM_OT_addon_remove(Operator):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def path_from_addon(module):
|
def path_from_addon(module):
|
||||||
for mod in addon_utils.modules(addon_utils._addons_fake_modules):
|
import addon_utils
|
||||||
|
|
||||||
|
for mod in addon_utils.modules(addon_utils.addons_fake_modules):
|
||||||
if mod.__name__ == module:
|
if mod.__name__ == module:
|
||||||
filepath = mod.__file__
|
filepath = mod.__file__
|
||||||
if os.path.exists(filepath):
|
if os.path.exists(filepath):
|
||||||
@ -1829,6 +1837,8 @@ class WM_OT_addon_remove(Operator):
|
|||||||
return None, False
|
return None, False
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import addon_utils
|
||||||
|
|
||||||
path, isdir = WM_OT_addon_remove.path_from_addon(self.module)
|
path, isdir = WM_OT_addon_remove.path_from_addon(self.module)
|
||||||
if path is None:
|
if path is None:
|
||||||
self.report('WARNING', "Addon path %r could not be found" % path)
|
self.report('WARNING', "Addon path %r could not be found" % path)
|
||||||
@ -1868,12 +1878,14 @@ class WM_OT_addon_expand(Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
|
import addon_utils
|
||||||
|
|
||||||
module_name = self.module
|
module_name = self.module
|
||||||
|
|
||||||
# unlikely to fail, module should have already been imported
|
# unlikely to fail, module should have already been imported
|
||||||
try:
|
try:
|
||||||
# mod = __import__(module_name)
|
# mod = __import__(module_name)
|
||||||
mod = addon_utils.module_get(module_name)
|
mod = addon_utils.addons_fake_modules.get(module_name)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
@ -77,7 +77,6 @@ del _namespace
|
|||||||
|
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import addon_utils
|
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
@ -97,7 +96,7 @@ def register():
|
|||||||
|
|
||||||
items_unique = set()
|
items_unique = set()
|
||||||
|
|
||||||
for mod in addon_utils.modules(addon_utils._addons_fake_modules):
|
for mod in addon_utils.modules(addon_utils.addons_fake_modules):
|
||||||
info = addon_utils.module_bl_info(mod)
|
info = addon_utils.module_bl_info(mod)
|
||||||
items_unique.add(info["category"])
|
items_unique.add(info["category"])
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ class USERPREF_PT_addons(Panel):
|
|||||||
used_ext = {ext.module for ext in userpref.addons}
|
used_ext = {ext.module for ext in userpref.addons}
|
||||||
|
|
||||||
# collect the categories that can be filtered on
|
# collect the categories that can be filtered on
|
||||||
addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(addon_utils._addons_fake_modules)]
|
addons = [(mod, addon_utils.module_bl_info(mod)) for mod in addon_utils.modules(addon_utils.addons_fake_modules)]
|
||||||
|
|
||||||
split = layout.split(percentage=0.2)
|
split = layout.split(percentage=0.2)
|
||||||
col = split.column()
|
col = split.column()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user