Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-02-01 05:58:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-02-01 05:58:44 +0300
commit10fec1f153295c9bd60eaa96dfcd09d8cf1b3d91 (patch)
tree5dc23cd4c0d132761fae552de23c1a1bee985356 /release
parent078e012cd9711e3d9b88bdf437f31e39518315df (diff)
Cleanup: Python code-style (addons, wm)
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/addon_utils.py35
-rw-r--r--release/scripts/startup/bl_operators/wm.py51
-rw-r--r--release/scripts/startup/bl_ui/__init__.py51
3 files changed, 77 insertions, 60 deletions
diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py
index 51e3e65b78c..97fc45189f2 100644
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@ -77,8 +77,8 @@ def modules_refresh(module_cache=addons_fake_modules):
ModuleType = type(ast)
try:
file_mod = open(mod_path, "r", encoding='UTF-8')
- except OSError as e:
- print("Error opening file %r: %s" % (mod_path, e))
+ except OSError as ex:
+ print("Error opening file %r: %s" % (mod_path, ex))
return None
with file_mod:
@@ -89,10 +89,10 @@ def modules_refresh(module_cache=addons_fake_modules):
while not l.startswith("bl_info"):
try:
l = line_iter.readline()
- except UnicodeDecodeError as e:
+ except UnicodeDecodeError as ex:
if not error_encoding:
error_encoding = True
- print("Error reading file as UTF-8:", mod_path, e)
+ print("Error reading file as UTF-8:", mod_path, ex)
return None
if len(l) == 0:
@@ -101,10 +101,10 @@ def modules_refresh(module_cache=addons_fake_modules):
lines.append(l)
try:
l = line_iter.readline()
- except UnicodeDecodeError as e:
+ except UnicodeDecodeError as ex:
if not error_encoding:
error_encoding = True
- print("Error reading file as UTF-8:", mod_path, e)
+ print("Error reading file as UTF-8:", mod_path, ex)
return None
data = "".join(lines)
@@ -182,9 +182,11 @@ def modules_refresh(module_cache=addons_fake_modules):
mod = None
if mod is None:
- mod = fake_module(mod_name,
- mod_path,
- force_support=force_support)
+ mod = fake_module(
+ mod_name,
+ mod_path,
+ force_support=force_support,
+ )
if mod:
module_cache[mod_name] = mod
@@ -200,9 +202,12 @@ def modules(module_cache=addons_fake_modules, *, refresh=True):
modules._is_first = False
mod_list = list(module_cache.values())
- mod_list.sort(key=lambda mod: (mod.bl_info["category"],
- mod.bl_info["name"],
- ))
+ mod_list.sort(
+ key=lambda mod: (
+ mod.bl_info["category"],
+ mod.bl_info["name"],
+ )
+ )
return mod_list
modules._is_first = True
@@ -220,8 +225,10 @@ def check(module_name):
loaded_default = module_name in _user_preferences.addons
mod = sys.modules.get(module_name)
- loaded_state = ((mod is not None) and
- getattr(mod, "__addon_enabled__", Ellipsis))
+ loaded_state = (
+ (mod is not None) and
+ getattr(mod, "__addon_enabled__", Ellipsis)
+ )
if loaded_state is Ellipsis:
print("Warning: addon-module %r found module "
diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 2f3569338d5..cf07152d979 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -59,8 +59,8 @@ rna_relative_prop = BoolProperty(
def context_path_validate(context, data_path):
try:
value = eval("context.%s" % data_path) if data_path else Ellipsis
- except AttributeError as e:
- if str(e).startswith("'NoneType'"):
+ except AttributeError as ex:
+ if str(ex).startswith("'NoneType'"):
# One of the items in the rna path is None, just ignore this
value = Ellipsis
else:
@@ -159,11 +159,12 @@ class BRUSH_OT_active_index_set(Operator):
description="Brush number",
)
- _attr_dict = {"sculpt": "use_paint_sculpt",
- "vertex_paint": "use_paint_vertex",
- "weight_paint": "use_paint_weight",
- "image_paint": "use_paint_image",
- }
+ _attr_dict = {
+ "sculpt": "use_paint_sculpt",
+ "vertex_paint": "use_paint_vertex",
+ "weight_paint": "use_paint_weight",
+ "image_paint": "use_paint_image",
+ }
def execute(self, context):
attr = self._attr_dict.get(self.mode)
@@ -1018,11 +1019,12 @@ class WM_OT_doc_view_manual(Operator):
if url is None:
self.report(
- {'WARNING'},
- "No reference available %r, "
- "Update info in 'rna_manual_reference.py' "
- "or callback to bpy.utils.manual_map()" %
- self.doc_id)
+ {'WARNING'},
+ "No reference available %r, "
+ "Update info in 'rna_manual_reference.py' "
+ "or callback to bpy.utils.manual_map()" %
+ self.doc_id
+ )
return {'CANCELLED'}
else:
import webbrowser
@@ -1112,7 +1114,7 @@ class WM_OT_properties_edit(Operator):
"use_soft_limits": self.use_soft_limits,
"soft_range": (self.soft_min, self.soft_max),
"hard_range": (self.min, self.max),
- }
+ }
def execute(self, context):
from rna_prop_ui import (
@@ -1233,8 +1235,9 @@ class WM_OT_properties_edit(Operator):
self.soft_min = prop_ui.get("soft_min", self.min)
self.soft_max = prop_ui.get("soft_max", self.max)
self.use_soft_limits = (
- self.min != self.soft_min or
- self.max != self.soft_max)
+ self.min != self.soft_min or
+ self.max != self.soft_max
+ )
# store for comparison
self._cmp_props = self._cmp_props_get()
@@ -1603,8 +1606,8 @@ class WM_OT_keyconfig_import(Operator):
shutil.copy(self.filepath, path)
else:
shutil.move(self.filepath, path)
- except Exception as e:
- self.report({'ERROR'}, "Installing keymap failed: %s" % e)
+ except Exception as ex:
+ self.report({'ERROR'}, "Installing keymap failed: %s" % ex)
return {'CANCELLED'}
# sneaky way to check we're actually running the code.
@@ -1838,12 +1841,14 @@ class WM_OT_addon_enable(Operator):
info_ver = info.get("blender", (0, 0, 0))
if info_ver > bpy.app.version:
- self.report({'WARNING'},
- ("This script was written Blender "
- "version %d.%d.%d and might not "
- "function (correctly), "
- "though it is enabled" %
- info_ver))
+ self.report(
+ {'WARNING'},
+ "This script was written Blender "
+ "version %d.%d.%d and might not "
+ "function (correctly), "
+ "though it is enabled" %
+ info_ver
+ )
return {'FINISHED'}
else:
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index 5b609605cee..0a7b2cd2e8b 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -99,17 +99,21 @@ def register():
register_class(cls)
# space_userprefs.py
- from bpy.props import StringProperty, EnumProperty
+ from bpy.props import (
+ EnumProperty,
+ StringProperty,
+ )
from bpy.types import WindowManager
def addon_filter_items(self, context):
import addon_utils
- items = [('All', "All", "All Add-ons"),
- ('User', "User", "All Add-ons Installed by User"),
- ('Enabled', "Enabled", "All Enabled Add-ons"),
- ('Disabled', "Disabled", "All Disabled Add-ons"),
- ]
+ items = [
+ ('All', "All", "All Add-ons"),
+ ('User', "User", "All Add-ons Installed by User"),
+ ('Enabled', "Enabled", "All Enabled Add-ons"),
+ ('Disabled', "Disabled", "All Disabled Add-ons"),
+ ]
items_unique = set()
@@ -121,26 +125,27 @@ def register():
return items
WindowManager.addon_search = StringProperty(
- name="Search",
- description="Search within the selected filter",
- options={'TEXTEDIT_UPDATE'},
- )
+ name="Search",
+ description="Search within the selected filter",
+ options={'TEXTEDIT_UPDATE'},
+ )
WindowManager.addon_filter = EnumProperty(
- items=addon_filter_items,
- name="Category",
- description="Filter add-ons by category",
- )
+ items=addon_filter_items,
+ name="Category",
+ description="Filter add-ons by category",
+ )
WindowManager.addon_support = EnumProperty(
- items=[('OFFICIAL', "Official", "Officially supported"),
- ('COMMUNITY', "Community", "Maintained by community developers"),
- ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
- ],
- name="Support",
- description="Display support level",
- default={'OFFICIAL', 'COMMUNITY'},
- options={'ENUM_FLAG'},
- )
+ items=[
+ ('OFFICIAL', "Official", "Officially supported"),
+ ('COMMUNITY', "Community", "Maintained by community developers"),
+ ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
+ ],
+ name="Support",
+ description="Display support level",
+ default={'OFFICIAL', 'COMMUNITY'},
+ options={'ENUM_FLAG'},
+ )
# done...