Cleanup: consistent quotes for Python scripts

This commit is contained in:
Campbell Barton 2024-03-29 10:06:17 +11:00
parent 6e997cc757
commit a2dae7e4b4
8 changed files with 40 additions and 37 deletions

View File

@ -530,7 +530,7 @@ class ARMATURE_OT_copy_bone_color_to_selected(Operator):
def _armature_from_context(context):
pin_armature = getattr(context, 'armature', None)
pin_armature = getattr(context, "armature", None)
if pin_armature:
return pin_armature
if context.object and context.object.type == 'ARMATURE':

View File

@ -270,8 +270,8 @@ class WM_OT_blend_strings_utf8_validate(Operator):
continue
if prop.type == 'STRING':
val_bytes = item.path_resolve(prop.identifier, False).as_bytes()
val_utf8 = val_bytes.decode('utf-8', 'replace')
val_bytes_valid = val_utf8.encode('utf-8')
val_utf8 = val_bytes.decode("utf-8", "replace")
val_bytes_valid = val_utf8.encode("utf-8")
if val_bytes_valid != val_bytes:
print("found bad utf8 encoded string %r, fixing to %r (%r)..."
"" % (val_bytes, val_bytes_valid, val_utf8))

View File

@ -145,7 +145,7 @@ class AddPresetBase:
file_preset.write("%s = %r\n" % (rna_path_step, value))
file_preset = open(filepath, 'w', encoding="utf-8")
file_preset = open(filepath, "w", encoding="utf-8")
file_preset.write("import bpy\n")
if hasattr(self, "preset_defines"):

View File

@ -674,7 +674,7 @@ class PREFERENCES_OT_addon_install(Operator):
# check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(pyfile):
try:
file_to_extract = zipfile.ZipFile(pyfile, 'r')
file_to_extract = zipfile.ZipFile(pyfile, "r")
except BaseException:
traceback.print_exc()
return {'CANCELLED'}
@ -926,7 +926,7 @@ class PREFERENCES_OT_app_template_install(Operator):
# check to see if the file is in compressed format (.zip)
if zipfile.is_zipfile(filepath):
try:
file_to_extract = zipfile.ZipFile(filepath, 'r')
file_to_extract = zipfile.ZipFile(filepath, "r")
except BaseException:
traceback.print_exc()
return {'CANCELLED'}

View File

@ -3367,10 +3367,13 @@ class WM_MT_splash_about(Menu):
col.scale_y = 0.8
col.label(text=iface_("Version: %s") % bpy.app.version_string, translate=False)
col.separator(factor=2.5)
col.label(text=iface_("Date: %s %s") % (bpy.app.build_commit_date.decode('utf-8', 'replace'),
bpy.app.build_commit_time.decode('utf-8', 'replace')), translate=False)
col.label(text=iface_("Hash: %s") % bpy.app.build_hash.decode('ascii'), translate=False)
col.label(text=iface_("Branch: %s") % bpy.app.build_branch.decode('utf-8', 'replace'), translate=False)
col.label(text=iface_("Date: %s %s") % (
bpy.app.build_commit_date.decode("utf-8", "replace"),
bpy.app.build_commit_time.decode("utf-8", "replace")),
translate=False
)
col.label(text=iface_("Hash: %s") % bpy.app.build_hash.decode("ascii"), translate=False)
col.label(text=iface_("Branch: %s") % bpy.app.build_branch.decode("utf-8", "replace"), translate=False)
# This isn't useful information on MS-Windows or Apple systems as dynamically switching
# between windowing systems is only supported between X11/WAYLAND.

View File

@ -258,9 +258,9 @@ class ToolSelectPanelHelper:
# tool flattening
#
# usually 'tools' is already expanded into `ToolDef`
# usually "tools" is already expanded into `ToolDef`
# but when registering a tool, this can still be a function
# (_tools_flatten is usually called with cls.tools_from_context(context)
# (`_tools_flatten` is usually called with `cls.tools_from_context(context)`
# [that already yields from the function])
# so if item is still a function (e.g._defs_XXX.generate_from_brushes)
# seems like we cannot expand here (have no context yet)

View File

@ -409,27 +409,27 @@ class USERPREF_PT_edit_objects_duplicate_data(EditingPanel, CenterAlignMixIn, Pa
flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
datablock_types = (
("use_duplicate_action", "Action", 'ACTION', ''),
("use_duplicate_armature", "Armature", 'OUTLINER_DATA_ARMATURE', ''),
("use_duplicate_camera", "Camera", 'OUTLINER_DATA_CAMERA', ''),
("use_duplicate_curve", "Curve", 'OUTLINER_DATA_CURVE', ''),
("use_duplicate_curves", "Curves", 'OUTLINER_DATA_CURVES', ''),
("use_duplicate_grease_pencil", "Grease Pencil", 'OUTLINER_OB_GREASEPENCIL', ''),
("use_duplicate_lattice", "Lattice", 'OUTLINER_DATA_LATTICE', ''),
("use_duplicate_action", "Action", 'ACTION', ""),
("use_duplicate_armature", "Armature", 'OUTLINER_DATA_ARMATURE', ""),
("use_duplicate_camera", "Camera", 'OUTLINER_DATA_CAMERA', ""),
("use_duplicate_curve", "Curve", 'OUTLINER_DATA_CURVE', ""),
("use_duplicate_curves", "Curves", 'OUTLINER_DATA_CURVES', ""),
("use_duplicate_grease_pencil", "Grease Pencil", 'OUTLINER_OB_GREASEPENCIL', ""),
("use_duplicate_lattice", "Lattice", 'OUTLINER_DATA_LATTICE', ""),
(None, None, None, None),
("use_duplicate_light", "Light", 'OUTLINER_DATA_LIGHT', ''),
("use_duplicate_lightprobe", "Light Probe", 'OUTLINER_DATA_LIGHTPROBE', ''),
("use_duplicate_material", "Material", 'MATERIAL_DATA', ''),
("use_duplicate_mesh", "Mesh", 'OUTLINER_DATA_MESH', ''),
("use_duplicate_metaball", "Metaball", 'OUTLINER_DATA_META', ''),
("use_duplicate_node_tree", "Node Tree", 'NODETREE', ''),
("use_duplicate_particle", "Particle", 'PARTICLES', ''),
("use_duplicate_light", "Light", 'OUTLINER_DATA_LIGHT', ""),
("use_duplicate_lightprobe", "Light Probe", 'OUTLINER_DATA_LIGHTPROBE', ""),
("use_duplicate_material", "Material", 'MATERIAL_DATA', ""),
("use_duplicate_mesh", "Mesh", 'OUTLINER_DATA_MESH', ""),
("use_duplicate_metaball", "Metaball", 'OUTLINER_DATA_META', ""),
("use_duplicate_node_tree", "Node Tree", 'NODETREE', ""),
("use_duplicate_particle", "Particle", 'PARTICLES', ""),
(None, None, None, None),
("use_duplicate_pointcloud", "Point Cloud", 'OUTLINER_DATA_POINTCLOUD', ''),
("use_duplicate_speaker", "Speaker", 'OUTLINER_DATA_SPEAKER', ''),
("use_duplicate_surface", "Surface", 'OUTLINER_DATA_SURFACE', ''),
("use_duplicate_text", "Text", 'OUTLINER_DATA_FONT', ''),
("use_duplicate_volume", "Volume", 'OUTLINER_DATA_VOLUME', 'i18n_contexts.id_id'),
("use_duplicate_pointcloud", "Point Cloud", 'OUTLINER_DATA_POINTCLOUD', ""),
("use_duplicate_speaker", "Speaker", 'OUTLINER_DATA_SPEAKER', ""),
("use_duplicate_surface", "Surface", 'OUTLINER_DATA_SURFACE', ""),
("use_duplicate_text", "Text", 'OUTLINER_DATA_FONT', ""),
("use_duplicate_volume", "Volume", 'OUTLINER_DATA_VOLUME', "i18n_contexts.id_id"),
)
col = flow.column()
@ -2726,7 +2726,7 @@ class USERPREF_PT_experimental_debugging(ExperimentalPanel, Panel):
# Class Registration
# Order of registration defines order in UI,
# so dynamically generated classes are 'injected' in the intended order.
# so dynamically generated classes are "injected" in the intended order.
classes = (
USERPREF_PT_theme_user_interface,
*ThemeGenericClassGenerator.generate_panel_classes_for_wcols(),

View File

@ -1938,7 +1938,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_paint_falloff(GreasePencilBrushFalloff
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool and tool.idname != 'builtin_brush.Tint':
if tool and tool.idname != "builtin_brush.Tint":
return False
gptool = brush.gpencil_tool
@ -2349,7 +2349,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}:
if tool and tool.idname in {"builtin.cutter", "builtin.eyedropper", "builtin.interpolate"}:
return False
if brush.gpencil_tool == 'TINT':
@ -2410,7 +2410,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}:
if tool and tool.idname in {"builtin.cutter", "builtin.eyedropper", "builtin.interpolate"}:
return False
if brush.gpencil_tool == 'TINT':
@ -2575,7 +2575,7 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mixcolor(View3DPanel, Panel):
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}:
if tool and tool.idname in {"builtin.cutter", "builtin.eyedropper", "builtin.interpolate"}:
return False
if brush.gpencil_tool == 'TINT':
@ -2632,7 +2632,7 @@ class VIEW3D_PT_tools_grease_pencil_v3_brush_mix_palette(View3DPanel, Panel):
from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
tool = ToolSelectPanelHelper.tool_active_from_context(context)
if tool and tool.idname in {'builtin.cutter', 'builtin.eyedropper', 'builtin.interpolate'}:
if tool and tool.idname in {"builtin.cutter", "builtin.eyedropper", "builtin.interpolate"}:
return False
if brush.gpencil_tool == 'TINT':