Cleanup: Python code-style

This commit is contained in:
Campbell Barton
2018-02-01 14:58:05 +11:00
parent 10fec1f153
commit 4d96202c9e

View File

@@ -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()
@@ -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()
@@ -1315,7 +1319,8 @@ class USERPREF_MT_addons_online_resources(Menu):
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(
"wm.url_open", text="Add-on Tutorial", icon='URL',
).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html" ).url = bpy.types.WM_OT_doc_view._prefix + "/info_tutorial_addon.html"
@@ -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,7 +1414,8 @@ class USERPREF_PT_addons(Panel):
if addon_utils.error_encoding: if addon_utils.error_encoding:
self.draw_error(col, self.draw_error(
col,
"One or more addons do not have UTF-8 encoding\n" "One or more addons do not have UTF-8 encoding\n"
"(see console for details)", "(see console for details)",
) )
@@ -1431,7 +1442,6 @@ class USERPREF_PT_addons(Panel):
(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():
@@ -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',
).url = info["wiki_url"]
split.operator(
"wm.url_open", text="Report a Bug", icon='URL',
).url = info.get(
"tracker_url", "tracker_url",
"https://developer.blender.org/maniphest/task/edit/form/2") "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)