Cleanup: line length in Python scripts

This commit is contained in:
Campbell Barton 2021-10-24 19:12:34 +11:00
parent dc2524eaae
commit e288e392a8
7 changed files with 90 additions and 24 deletions

View File

@ -743,7 +743,9 @@ def dump_src_messages(msgs, reports, settings):
def clean_str(s):
# The encode/decode to/from 'raw_unicode_escape' allows to transform the C-type unicode hexadecimal escapes
# (like '\u2715' for the '×' symbol) back into a proper unicode character.
return "".join(m.group("clean") for m in _clean_str(s)).encode('raw_unicode_escape').decode('raw_unicode_escape')
return "".join(
m.group("clean") for m in _clean_str(s)
).encode('raw_unicode_escape').decode('raw_unicode_escape')
def dump_src_file(path, rel_path, msgs, reports, settings):
def process_entry(_msgctxt, _msgid):
@ -870,7 +872,10 @@ def dump_messages(do_messages, do_checks, settings):
dump_src_messages(msgs, reports, settings)
# Get strings from addons' categories.
for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items'](bpy.context.window_manager, bpy.context):
for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items'](
bpy.context.window_manager,
bpy.context,
):
process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings)
if tip:
process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings)

View File

@ -483,19 +483,44 @@ def main():
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
parser = argparse.ArgumentParser(
description="Use Blender to generate previews for currently open Blender file's items.")
parser.add_argument('--clear', default=False, action="store_true",
help="Clear previews instead of generating them.")
parser.add_argument('--no_backups', default=False, action="store_true",
help="Do not generate a backup .blend1 file when saving processed ones.")
parser.add_argument('--no_scenes', default=True, action="store_false",
help="Do not generate/clear previews for scene IDs.")
parser.add_argument('--no_collections', default=True, action="store_false",
help="Do not generate/clear previews for collection IDs.")
parser.add_argument('--no_objects', default=True, action="store_false",
help="Do not generate/clear previews for object IDs.")
parser.add_argument('--no_data_intern', default=True, action="store_false",
help="Do not generate/clear previews for mat/tex/image/etc. IDs (those handled by core Blender code).")
description="Use Blender to generate previews for currently open Blender file's items.",
)
parser.add_argument(
'--clear',
default=False,
action="store_true",
help="Clear previews instead of generating them.",
)
parser.add_argument(
'--no_backups',
default=False,
action="store_true",
help="Do not generate a backup .blend1 file when saving processed ones.",
)
parser.add_argument(
'--no_scenes',
default=True,
action="store_false",
help="Do not generate/clear previews for scene IDs.",
)
parser.add_argument(
'--no_collections',
default=True,
action="store_false",
help="Do not generate/clear previews for collection IDs.",
)
parser.add_argument(
'--no_objects',
default=True,
action="store_false",
help="Do not generate/clear previews for object IDs.",
)
parser.add_argument(
'--no_data_intern',
default=True,
action="store_false",
help="Do not generate/clear previews for mat/tex/image/etc. IDs (those handled by core Blender code).",
)
args = parser.parse_args(argv)
orig_save_version = bpy.context.preferences.filepaths.save_version

View File

@ -1327,7 +1327,10 @@ class WM_OT_properties_edit(Operator):
use_soft_limits: BoolProperty(
name="Use Soft Limits",
description="Limits the Property Value slider to a range, values outside the range must be inputted numerically",
description=(
"Limits the Property Value slider to a range, "
"values outside the range must be inputted numerically"
),
)
array_length: IntProperty(
name="Array Length",

View File

@ -227,7 +227,12 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
split.enabled = note_flag and ob.mode == 'OBJECT'
bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
if domain.cache_resumable and domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
if (
domain.cache_resumable and
domain.has_cache_baked_data and
not domain.is_cache_baking_data and
bake_incomplete
):
col = split.column()
col.operator("fluid.bake_data", text="Resume")
col = split.column()
@ -1249,7 +1254,12 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
split.enabled = ob.mode == 'OBJECT'
bake_incomplete = (domain.cache_frame_pause_data < domain.cache_frame_end)
if domain.cache_resumable and domain.has_cache_baked_data and not domain.is_cache_baking_data and bake_incomplete:
if (
domain.cache_resumable and
domain.has_cache_baked_data and
not domain.is_cache_baking_data and
bake_incomplete
):
col = split.column()
col.operator("fluid.bake_all", text="Resume")
col = split.column()

View File

@ -109,7 +109,11 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
@classmethod
def poll(cls, context):
obj = context.object
if obj.parent is not None and obj.parent.rigid_body is not None and not obj.parent.rigid_body.collision_shape == 'COMPOUND':
if (
(obj.parent is not None) and
(obj.parent.rigid_body is not None) and
(not obj.parent.rigid_body.collision_shape == 'COMPOUND')
):
return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))
@ -124,7 +128,11 @@ class PHYSICS_PT_rigid_body_collisions(PHYSICS_PT_rigidbody_panel, Panel):
layout.prop(rbo, "collision_shape", text="Shape")
if rbo.collision_shape == 'COMPOUND':
if parent is not None and parent.rigid_body is not None and parent.rigid_body.collision_shape == 'COMPOUND':
if (
(parent is not None) and
(parent.rigid_body is not None) and
(parent.rigid_body.collision_shape == 'COMPOUND')
):
rigid_body_warning(layout, "Sub compound shapes are not allowed")
else:
found = False
@ -179,7 +187,11 @@ class PHYSICS_PT_rigid_body_collisions_sensitivity(PHYSICS_PT_rigidbody_panel, P
@classmethod
def poll(cls, context):
obj = context.object
if obj.parent is not None and obj.parent.rigid_body is not None and not obj.parent.rigid_body.collision_shape == 'COMPOUND':
if (
(obj.parent is not None) and
(obj.parent.rigid_body is not None) and
(not obj.parent.rigid_body.collision_shape == 'COMPOUND')
):
return False
return (obj and obj.rigid_body and (context.engine in cls.COMPAT_ENGINES))

View File

@ -614,7 +614,10 @@ class ASSETBROWSER_PT_filter(asset_utils.AssetBrowserPanel, Panel):
filter_id = params.filter_asset_id
for identifier in dir(filter_id):
if identifier.startswith("filter_") or (identifier.startswith("experimental_filter_") and use_extended_browser):
if (
identifier.startswith("filter_") or
(identifier.startswith("experimental_filter_") and use_extended_browser)
):
row = col.row()
row.label(icon=filter_id.bl_rna.properties[identifier].icon)
row.prop(filter_id, identifier, toggle=False)

View File

@ -786,8 +786,16 @@ class NodeTreeInterfacePanel:
if tree.type == 'GEOMETRY':
layout.prop(active_socket, "description")
field_socket_prefixes = {
"NodeSocketInt", "NodeSocketColor", "NodeSocketVector", "NodeSocketBool", "NodeSocketFloat"}
is_field_type = any(active_socket.bl_socket_idname.startswith(prefix) for prefix in field_socket_prefixes)
"NodeSocketInt",
"NodeSocketColor",
"NodeSocketVector",
"NodeSocketBool",
"NodeSocketFloat",
}
is_field_type = any(
active_socket.bl_socket_idname.startswith(prefix)
for prefix in field_socket_prefixes
)
if in_out == 'OUT' and is_field_type:
layout.prop(active_socket, "attribute_domain")
active_socket.draw(context, layout)