Cleanup: Python code-style
This commit is contained in:
@@ -18,7 +18,11 @@
|
|||||||
|
|
||||||
# <pep8 compliant>
|
# <pep8 compliant>
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.types import Header, Menu, Panel
|
from bpy.types import (
|
||||||
|
Header,
|
||||||
|
Menu,
|
||||||
|
Panel,
|
||||||
|
)
|
||||||
from bpy.app.translations import pgettext_iface as iface_
|
from bpy.app.translations import pgettext_iface as iface_
|
||||||
from bpy.app.translations import contexts as i18n_contexts
|
from bpy.app.translations import contexts as i18n_contexts
|
||||||
|
|
||||||
@@ -270,9 +274,9 @@ class USERPREF_PT_interface(Panel):
|
|||||||
col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
|
col.prop(view, "view2d_grid_spacing_min", text="Minimum Grid Spacing")
|
||||||
col.prop(view, "timecode_style")
|
col.prop(view, "timecode_style")
|
||||||
col.prop(view, "view_frame_type")
|
col.prop(view, "view_frame_type")
|
||||||
if (view.view_frame_type == 'SECONDS'):
|
if view.view_frame_type == 'SECONDS':
|
||||||
col.prop(view, "view_frame_seconds")
|
col.prop(view, "view_frame_seconds")
|
||||||
elif (view.view_frame_type == 'KEYFRAMES'):
|
elif view.view_frame_type == 'KEYFRAMES':
|
||||||
col.prop(view, "view_frame_keyframes")
|
col.prop(view, "view_frame_keyframes")
|
||||||
|
|
||||||
row.separator()
|
row.separator()
|
||||||
@@ -619,7 +623,7 @@ class USERPREF_MT_interface_theme_presets(Menu):
|
|||||||
preset_xml_map = (
|
preset_xml_map = (
|
||||||
("user_preferences.themes[0]", "Theme"),
|
("user_preferences.themes[0]", "Theme"),
|
||||||
("user_preferences.ui_styles[0]", "ThemeStyle"),
|
("user_preferences.ui_styles[0]", "ThemeStyle"),
|
||||||
)
|
)
|
||||||
draw = Menu.draw_preset
|
draw = Menu.draw_preset
|
||||||
|
|
||||||
|
|
||||||
@@ -639,20 +643,20 @@ class USERPREF_PT_theme(Panel):
|
|||||||
"split_normal",
|
"split_normal",
|
||||||
"bone_solid",
|
"bone_solid",
|
||||||
"paint_curve_pivot",
|
"paint_curve_pivot",
|
||||||
},
|
},
|
||||||
'GRAPH_EDITOR': {
|
'GRAPH_EDITOR': {
|
||||||
"handle_vertex_select",
|
"handle_vertex_select",
|
||||||
},
|
},
|
||||||
'IMAGE_EDITOR': {
|
'IMAGE_EDITOR': {
|
||||||
"paint_curve_pivot",
|
"paint_curve_pivot",
|
||||||
},
|
},
|
||||||
'NODE_EDITOR': {
|
'NODE_EDITOR': {
|
||||||
"layout_node",
|
"layout_node",
|
||||||
},
|
},
|
||||||
'CLIP_EDITOR': {
|
'CLIP_EDITOR': {
|
||||||
"handle_vertex_select",
|
"handle_vertex_select",
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _theme_generic(split, themedata, theme_area):
|
def _theme_generic(split, themedata, theme_area):
|
||||||
@@ -938,8 +942,8 @@ class USERPREF_PT_theme(Panel):
|
|||||||
elif theme.theme_area == 'BONE_COLOR_SETS':
|
elif theme.theme_area == 'BONE_COLOR_SETS':
|
||||||
col = split.column()
|
col = split.column()
|
||||||
|
|
||||||
for i, ui in enumerate(theme.bone_color_sets):
|
for i, ui in enumerate(theme.bone_color_sets, 1):
|
||||||
col.label(text=iface_("Color Set %d:") % (i + 1), translate=False) # i starts from 0
|
col.label(text=iface_("Color Set %d:") % 1, translate=False)
|
||||||
|
|
||||||
row = col.row()
|
row = col.row()
|
||||||
|
|
||||||
@@ -1301,22 +1305,23 @@ class USERPREF_MT_addons_online_resources(Menu):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
layout.operator(
|
layout.operator(
|
||||||
"wm.url_open", text="Add-ons Catalog", icon='URL',
|
"wm.url_open", text="Add-ons Catalog", icon='URL',
|
||||||
).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
|
).url = "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts"
|
||||||
|
|
||||||
layout.separator()
|
layout.separator()
|
||||||
|
|
||||||
layout.operator(
|
layout.operator(
|
||||||
"wm.url_open", text="How to share your add-on", icon='URL',
|
"wm.url_open", text="How to share your add-on", icon='URL',
|
||||||
).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
|
).url = "http://wiki.blender.org/index.php/Dev:Py/Sharing"
|
||||||
layout.operator(
|
layout.operator(
|
||||||
"wm.url_open", text="Add-on Guidelines", icon='URL',
|
"wm.url_open", text="Add-on Guidelines", icon='URL',
|
||||||
).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
|
).url = "http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons"
|
||||||
layout.operator(
|
layout.operator(
|
||||||
"wm.url_open", text="API Concepts", icon='URL',
|
"wm.url_open", text="API Concepts", icon='URL',
|
||||||
).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
|
).url = bpy.types.WM_OT_doc_view._prefix + "/info_quickstart.html"
|
||||||
layout.operator("wm.url_open", text="Add-on Tutorial", icon='URL',
|
layout.operator(
|
||||||
).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
|
"wm.url_open", text="Add-on Tutorial", icon='URL',
|
||||||
|
).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
|
||||||
|
|
||||||
|
|
||||||
class USERPREF_PT_addons(Panel):
|
class USERPREF_PT_addons(Panel):
|
||||||
@@ -1341,8 +1346,10 @@ class USERPREF_PT_addons(Panel):
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
if not user_addon_paths:
|
if not user_addon_paths:
|
||||||
for path in (bpy.utils.script_path_user(),
|
for path in (
|
||||||
bpy.utils.script_path_pref()):
|
bpy.utils.script_path_user(),
|
||||||
|
bpy.utils.script_path_pref(),
|
||||||
|
):
|
||||||
if path is not None:
|
if path is not None:
|
||||||
user_addon_paths.append(os.path.join(path, "addons"))
|
user_addon_paths.append(os.path.join(path, "addons"))
|
||||||
|
|
||||||
@@ -1374,7 +1381,10 @@ class USERPREF_PT_addons(Panel):
|
|||||||
scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "addons")
|
scripts_addons_folder = bpy.utils.user_resource('SCRIPTS', "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(refresh=False)]
|
addons = [
|
||||||
|
(mod, addon_utils.module_bl_info(mod))
|
||||||
|
for mod in addon_utils.modules(refresh=False)
|
||||||
|
]
|
||||||
|
|
||||||
split = layout.split(percentage=0.2)
|
split = layout.split(percentage=0.2)
|
||||||
col = split.column()
|
col = split.column()
|
||||||
@@ -1404,10 +1414,11 @@ class USERPREF_PT_addons(Panel):
|
|||||||
|
|
||||||
|
|
||||||
if addon_utils.error_encoding:
|
if addon_utils.error_encoding:
|
||||||
self.draw_error(col,
|
self.draw_error(
|
||||||
"One or more addons do not have UTF-8 encoding\n"
|
col,
|
||||||
"(see console for details)",
|
"One or more addons do not have UTF-8 encoding\n"
|
||||||
)
|
"(see console for details)",
|
||||||
|
)
|
||||||
|
|
||||||
filter = context.window_manager.addon_filter
|
filter = context.window_manager.addon_filter
|
||||||
search = context.window_manager.addon_search.lower()
|
search = context.window_manager.addon_search.lower()
|
||||||
@@ -1430,8 +1441,7 @@ class USERPREF_PT_addons(Panel):
|
|||||||
(filter == "Enabled" and is_enabled) or
|
(filter == "Enabled" and is_enabled) or
|
||||||
(filter == "Disabled" and not is_enabled) or
|
(filter == "Disabled" and not is_enabled) or
|
||||||
(filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
|
(filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder))))
|
||||||
):
|
):
|
||||||
|
|
||||||
if search and search not in info["name"].lower():
|
if search and search not in info["name"].lower():
|
||||||
if info["author"]:
|
if info["author"]:
|
||||||
if search not in info["author"].lower():
|
if search not in info["author"].lower():
|
||||||
@@ -1446,16 +1456,16 @@ class USERPREF_PT_addons(Panel):
|
|||||||
row = colsub.row(align=True)
|
row = colsub.row(align=True)
|
||||||
|
|
||||||
row.operator(
|
row.operator(
|
||||||
"wm.addon_expand",
|
"wm.addon_expand",
|
||||||
icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
|
icon='TRIA_DOWN' if info["show_expanded"] else 'TRIA_RIGHT',
|
||||||
emboss=False,
|
emboss=False,
|
||||||
).module = module_name
|
).module = module_name
|
||||||
|
|
||||||
row.operator(
|
row.operator(
|
||||||
"wm.addon_disable" if is_enabled else "wm.addon_enable",
|
"wm.addon_disable" if is_enabled else "wm.addon_enable",
|
||||||
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
|
icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="",
|
||||||
emboss=False,
|
emboss=False,
|
||||||
).module = module_name
|
).module = module_name
|
||||||
|
|
||||||
sub = row.row()
|
sub = row.row()
|
||||||
sub.active = is_enabled
|
sub.active = is_enabled
|
||||||
@@ -1500,12 +1510,19 @@ class USERPREF_PT_addons(Panel):
|
|||||||
split = colsub.row().split(percentage=0.15)
|
split = colsub.row().split(percentage=0.15)
|
||||||
split.label(text="Internet:")
|
split.label(text="Internet:")
|
||||||
if info["wiki_url"]:
|
if info["wiki_url"]:
|
||||||
split.operator("wm.url_open", text="Documentation", icon='HELP').url = info["wiki_url"]
|
split.operator(
|
||||||
split.operator("wm.url_open", text="Report a Bug", icon='URL').url = info.get(
|
"wm.url_open", text="Documentation", icon='HELP',
|
||||||
"tracker_url",
|
).url = info["wiki_url"]
|
||||||
"https://developer.blender.org/maniphest/task/edit/form/2")
|
split.operator(
|
||||||
|
"wm.url_open", text="Report a Bug", icon='URL',
|
||||||
|
).url = info.get(
|
||||||
|
"tracker_url",
|
||||||
|
"https://developer.blender.org/maniphest/task/edit/form/2",
|
||||||
|
)
|
||||||
if user_addon:
|
if user_addon:
|
||||||
split.operator("wm.addon_remove", text="Remove", icon='CANCEL').module = mod.__name__
|
split.operator(
|
||||||
|
"wm.addon_remove", text="Remove", icon='CANCEL',
|
||||||
|
).module = mod.__name__
|
||||||
|
|
||||||
for i in range(4 - tot_row):
|
for i in range(4 - tot_row):
|
||||||
split.separator()
|
split.separator()
|
||||||
@@ -1548,7 +1565,9 @@ class USERPREF_PT_addons(Panel):
|
|||||||
row.label(text="", icon='ERROR')
|
row.label(text="", icon='ERROR')
|
||||||
|
|
||||||
if is_enabled:
|
if is_enabled:
|
||||||
row.operator("wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False).module = module_name
|
row.operator(
|
||||||
|
"wm.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False,
|
||||||
|
).module = module_name
|
||||||
|
|
||||||
row.label(text=module_name, translate=False)
|
row.label(text=module_name, translate=False)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user