From 448eeb681aa414257a75356d7e6c65e0672980d5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Jun 2021 03:12:45 +1000 Subject: Update for changes in the Python API using keyword only arguments --- add_curve_extra_objects/__init__.py | 7 ++----- archipack/archipack_gl.py | 2 +- archipack/archipack_material.py | 4 +--- archipack/archipack_preset.py | 8 +++----- archipack/archipack_rendering.py | 6 ++---- archipack/bmesh_utils.py | 2 +- blender_id/profiles.py | 2 +- io_export_paper_model.py | 4 ++-- materials_library_vx/__init__.py | 2 +- mesh_looptools.py | 3 +-- mesh_tiny_cad/CCEN.py | 2 +- mesh_tiny_cad/E2F.py | 2 +- mesh_tiny_cad/VTX.py | 2 +- mesh_tools/mesh_cut_faces.py | 2 +- mesh_tools/mesh_edge_roundifier.py | 2 +- mesh_tools/mesh_edges_floor_plan.py | 4 ++-- mesh_tools/mesh_edges_length.py | 2 +- mesh_tools/split_solidify.py | 2 +- object_print3d_utils/mesh_helpers.py | 2 +- precision_drawing_tools/pdt_etof.py | 2 +- render_povray/render_gui.py | 6 +++--- rigify/utils/mechanism.py | 4 ++-- space_view3d_pie_menus/pie_sculpt_menu.py | 2 +- ui_translate/edit_translation.py | 9 ++++++--- ui_translate/update_addon.py | 2 +- 25 files changed, 39 insertions(+), 46 deletions(-) diff --git a/add_curve_extra_objects/__init__.py b/add_curve_extra_objects/__init__.py index 7a1a3ba7..22910bf9 100644 --- a/add_curve_extra_objects/__init__.py +++ b/add_curve_extra_objects/__init__.py @@ -80,8 +80,7 @@ def convert_old_presets(data_path, msg_data_path, old_preset_subdir, import os target_path = os.path.join("presets", old_preset_subdir) - target_path = bpy.utils.user_resource('SCRIPTS', - target_path) + target_path = bpy.utils.user_resource('SCRIPTS', path=target_path) # created an anytype op to run against preset op = type('', (), {})() @@ -93,9 +92,7 @@ def convert_old_presets(data_path, msg_data_path, old_preset_subdir, return None new_target_path = os.path.join("presets", new_preset_subdir) - new_target_path = bpy.utils.user_resource('SCRIPTS', - new_target_path, - create=True) + new_target_path = bpy.utils.user_resource('SCRIPTS', path=new_target_path, create=True) for f in files: file = open(os.path.join(target_path, f)) for line in file: diff --git a/archipack/archipack_gl.py b/archipack/archipack_gl.py index f0bf8482..8f69bea8 100644 --- a/archipack/archipack_gl.py +++ b/archipack/archipack_gl.py @@ -259,7 +259,7 @@ class Gl(): return self.get_render_location(context, coord) region = context.region rv3d = context.region_data - loc = view3d_utils.location_3d_to_region_2d(region, rv3d, coord, self.pos_2d) + loc = view3d_utils.location_3d_to_region_2d(region, rv3d, coord, default=self.pos_2d) return Vector(loc) def get_render_location(self, context, coord): diff --git a/archipack/archipack_material.py b/archipack/archipack_material.py index 27aaefab..e363f304 100644 --- a/archipack/archipack_material.py +++ b/archipack/archipack_material.py @@ -231,9 +231,7 @@ class MaterialSetManager(): def get_filename(self, object_type): target_path = os.path.join("presets", "archipack_materials") - target_path = bpy.utils.user_resource('SCRIPTS', - target_path, - create=True) + target_path = bpy.utils.user_resource('SCRIPTS', path=target_path, create=True) return os.path.join(target_path, object_type) + '.txt' def cleanup(self): diff --git a/archipack/archipack_preset.py b/archipack/archipack_preset.py index ae230295..fe4b9307 100644 --- a/archipack/archipack_preset.py +++ b/archipack/archipack_preset.py @@ -34,8 +34,8 @@ from .archipack_gl import ( ThumbHandle, Screen, GlRect, GlPolyline, GlPolygon, GlText, GlHandle ) -preset_paths = bpy.utils.script_paths("presets") -addons_paths = bpy.utils.script_paths("addons") +preset_paths = bpy.utils.script_paths(subdir="presets") +addons_paths = bpy.utils.script_paths(subdir="addons") class CruxHandle(GlHandle): @@ -570,9 +570,7 @@ class ArchipackPreset(AddPresetBase): filename = self.as_filename(name) target_path = os.path.join("presets", self.preset_subdir) - target_path = bpy.utils.user_resource('SCRIPTS', - target_path, - create=True) + target_path = bpy.utils.user_resource('SCRIPTS', path=target_path, create=True) preset = os.path.join(target_path, filename) + ".py" cls = self.preset_subdir[10:] diff --git a/archipack/archipack_rendering.py b/archipack/archipack_rendering.py index 09650ec8..f8bb07f9 100644 --- a/archipack/archipack_rendering.py +++ b/archipack/archipack_rendering.py @@ -99,9 +99,7 @@ class ARCHIPACK_OT_render_thumbs(Operator): not f.startswith('.')]) target_path = path.join("presets", category) - presets_path = bpy.utils.user_resource('SCRIPTS', - target_path, - create=True) + presets_path = bpy.utils.user_resource('SCRIPTS', path=target_path, create=True) # files from factory not found in user doesn't require a recompute skipfiles = [] for f in file_list: @@ -130,7 +128,7 @@ class ARCHIPACK_OT_render_thumbs(Operator): skipfiles = self.copy_to_user_path(category) # load user def presets - preset_paths = bpy.utils.script_paths("presets") + preset_paths = bpy.utils.script_paths(subdir="presets") for preset in preset_paths: presets_path = path.join(preset, category) if path.exists(presets_path): diff --git a/archipack/bmesh_utils.py b/archipack/bmesh_utils.py index 3c196bec..16be7a54 100644 --- a/archipack/bmesh_utils.py +++ b/archipack/bmesh_utils.py @@ -98,7 +98,7 @@ class BmeshEdit(): private, end bmesh editing of active object """ bm.normal_update() - bmesh.update_edit_mesh(o.data, True) + bmesh.update_edit_mesh(o.data, loop_triangles=True) bpy.ops.object.mode_set(mode='OBJECT') bm.free() diff --git a/blender_id/profiles.py b/blender_id/profiles.py index 2e872a50..7a4b3495 100644 --- a/blender_id/profiles.py +++ b/blender_id/profiles.py @@ -94,7 +94,7 @@ class BlenderIdProfile(metaclass=_BIPMeta): def register(): global profiles_path, profiles_file - profiles_path = bpy.utils.user_resource('CONFIG', 'blender_id', create=True) + profiles_path = bpy.utils.user_resource('CONFIG', path='blender_id', create=True) profiles_file = os.path.join(profiles_path, 'profiles.json') diff --git a/io_export_paper_model.py b/io_export_paper_model.py index 5f8e70f5..8ea8cf9f 100644 --- a/io_export_paper_model.py +++ b/io_export_paper_model.py @@ -177,7 +177,7 @@ class UnfoldError(ValueError): elem.select = False for elem in chain(*elems.values()): elem.select_set(True) - bmesh.update_edit_mesh(bpy.context.object.data, False, False) + bmesh.update_edit_mesh(bpy.context.object.data, loop_triangles=False, destructive=False) class Unfolder: @@ -2269,7 +2269,7 @@ class SelectIsland(bpy.types.Operator): edge.select = any(face.select for face in edge.link_faces) for vert in verts: vert.select = any(edge.select for edge in vert.link_edges) - bmesh.update_edit_mesh(me, False, False) + bmesh.update_edit_mesh(me, loop_triangles=False, destructive=False) return {'FINISHED'} diff --git a/materials_library_vx/__init__.py b/materials_library_vx/__init__.py index e8bc808e..8df8e2b9 100644 --- a/materials_library_vx/__init__.py +++ b/materials_library_vx/__init__.py @@ -1072,7 +1072,7 @@ def list_materials(): return sorted(list) def get_material(name, link=False): - with bpy.data.libraries.load("{0}", link, False) as (data_from, data_to): + with bpy.data.libraries.load("{0}", link=link, relative=False) as (data_from, data_to): data_to.materials = [name] if link: print(name + " linked.") diff --git a/mesh_looptools.py b/mesh_looptools.py index d13c4213..a2147cb7 100644 --- a/mesh_looptools.py +++ b/mesh_looptools.py @@ -3433,8 +3433,7 @@ class Bridge(Operator): if self.remove_faces and old_selected_faces: bridge_remove_internal_faces(bm, old_selected_faces) # make sure normals are facing outside - bmesh.update_edit_mesh(object.data, loop_triangles=False, - destructive=True) + bmesh.update_edit_mesh(object.data, loop_triangles=False, destructive=True) bpy.ops.mesh.normals_make_consistent() # cleaning up diff --git a/mesh_tiny_cad/CCEN.py b/mesh_tiny_cad/CCEN.py index 24604e8f..f97ca84b 100644 --- a/mesh_tiny_cad/CCEN.py +++ b/mesh_tiny_cad/CCEN.py @@ -65,7 +65,7 @@ def generate_bmesh_repr(p1, v1, axis, num_verts): idx2 = (i + 1) % num_verts bm.edges.new([v_refs[idx1], v_refs[idx2]]) - bmesh.update_edit_mesh(me, True) + bmesh.update_edit_mesh(me, loop_triangles=True) def generate_3PT(pts, obj, nv, mode=1): diff --git a/mesh_tiny_cad/E2F.py b/mesh_tiny_cad/E2F.py index 70b51298..33ac79f3 100644 --- a/mesh_tiny_cad/E2F.py +++ b/mesh_tiny_cad/E2F.py @@ -79,7 +79,7 @@ def extend_vertex(self): vertex_reference = v1_ref if (A_len < B_len) else v2_ref bm.edges.new([vertex_reference, new_vertex]) - bmesh.update_edit_mesh(me, True) + bmesh.update_edit_mesh(me, loop_triangles=True) else: failure_message_on_plane(self) diff --git a/mesh_tiny_cad/VTX.py b/mesh_tiny_cad/VTX.py index f98e85cb..fbd0bc28 100644 --- a/mesh_tiny_cad/VTX.py +++ b/mesh_tiny_cad/VTX.py @@ -170,6 +170,6 @@ class TCAutoVTX(bpy.types.Operator): bm.verts.index_update() bm.edges.index_update() - bmesh.update_edit_mesh(me, True) + bmesh.update_edit_mesh(me, loop_triangles=True) return {'FINISHED'} diff --git a/mesh_tools/mesh_cut_faces.py b/mesh_tools/mesh_cut_faces.py index 23324f1c..99f7c8ac 100644 --- a/mesh_tools/mesh_cut_faces.py +++ b/mesh_tools/mesh_cut_faces.py @@ -23,7 +23,7 @@ def bmesh_release(bm, object): mesh = object.data bm.select_flush_mode() if object.mode == 'EDIT': - bmesh.update_edit_mesh(mesh, True) + bmesh.update_edit_mesh(mesh, loop_triangles=True) else: bm.to_mesh(mesh) bm.free() diff --git a/mesh_tools/mesh_edge_roundifier.py b/mesh_tools/mesh_edge_roundifier.py index 418d97fd..994d2b6f 100644 --- a/mesh_tools/mesh_edge_roundifier.py +++ b/mesh_tools/mesh_edge_roundifier.py @@ -1213,7 +1213,7 @@ class EdgeRoundifier(Operator): verticesForDeletion.append(vi) bmesh.ops.delete(bm, geom=verticesForDeletion, context = 'VERTS') - bmesh.update_edit_mesh(mesh, True) + bmesh.update_edit_mesh(mesh, loop_triangles=True) bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='EDIT') diff --git a/mesh_tools/mesh_edges_floor_plan.py b/mesh_tools/mesh_edges_floor_plan.py index 6a303ffb..a654a4c3 100644 --- a/mesh_tools/mesh_edges_floor_plan.py +++ b/mesh_tools/mesh_edges_floor_plan.py @@ -283,7 +283,7 @@ class MESH_OT_edges_floor_plan(Operator): if edge.is_boundary: edge.select = True - bm = bmesh.update_edit_mesh(ob.data, 1, 1) + bm = bmesh.update_edit_mesh(ob.data, loop_triangles=True, destructive=True) bpy.ops.object.mode_set(mode='OBJECT') self.solidify_mod(context, ob, wid, offset, self.only_rim) @@ -366,7 +366,7 @@ class MESH_OT_edges_floor_plan(Operator): if edge.is_boundary: edge.select = True - bm = bmesh.update_edit_mesh(ob.data, 1, 1) + bm = bmesh.update_edit_mesh(ob.data, loop_triangles=True, destructive=True) context.tool_settings.mesh_select_mode = store_selection_mode diff --git a/mesh_tools/mesh_edges_length.py b/mesh_tools/mesh_edges_length.py index adaee650..ee9ae15b 100644 --- a/mesh_tools/mesh_edges_length.py +++ b/mesh_tools/mesh_edges_length.py @@ -310,7 +310,7 @@ class LengthSet(Operator): '\n edge.verts[1].co' + str(verts[1]) + '\n vector' + str(vector) + '\n v1 > v0:' + str((verts[1] >= verts[0])) ) - bmesh.update_edit_mesh(obj.data, True) + bmesh.update_edit_mesh(obj.data, loop_triangles=True) return {'FINISHED'} diff --git a/mesh_tools/split_solidify.py b/mesh_tools/split_solidify.py index 7158089e..1ac952bc 100644 --- a/mesh_tools/split_solidify.py +++ b/mesh_tools/split_solidify.py @@ -101,7 +101,7 @@ def solidify_split(self, list_0): k.select = False bpy.ops.mesh.normals_make_consistent(inside=False) - bmesh.update_edit_mesh(self.me, True) + bmesh.update_edit_mesh(self.me, loop_triangles=True) class MESH_OT_split_solidify(Operator): diff --git a/object_print3d_utils/mesh_helpers.py b/object_print3d_utils/mesh_helpers.py index cffdf7c5..948a3bc7 100644 --- a/object_print3d_utils/mesh_helpers.py +++ b/object_print3d_utils/mesh_helpers.py @@ -76,7 +76,7 @@ def bmesh_to_object(obj, bm): me = obj.data if obj.mode == 'EDIT': - bmesh.update_edit_mesh(me, True) + bmesh.update_edit_mesh(me, loop_triangles=True) else: bm.to_mesh(me) me.update() diff --git a/precision_drawing_tools/pdt_etof.py b/precision_drawing_tools/pdt_etof.py index edb8ebc5..892bd6b2 100644 --- a/precision_drawing_tools/pdt_etof.py +++ b/precision_drawing_tools/pdt_etof.py @@ -115,7 +115,7 @@ def extend_vertex(context): vertex_reference = v1_ref if (a_len < b_len) else v2_ref bm.edges.new([vertex_reference, new_vertex]) - bmesh.update_edit_mesh(object_data, True) + bmesh.update_edit_mesh(object_data, loop_triangles=True) else: failure_message_on_plane(context) diff --git a/render_povray/render_gui.py b/render_povray/render_gui.py index 018821cb..5b659725 100755 --- a/render_povray/render_gui.py +++ b/render_povray/render_gui.py @@ -421,13 +421,13 @@ def rad_panel_func(self, context): # addon_utils.paths()[0] # addon_utils.modules() # mod.bl_info['name'] == 'Freestyle SVG Exporter': -bpy.utils.script_paths("addons") -# render_freestyle_svg = os.path.join(bpy.utils.script_paths("addons"), "render_freestyle_svg.py") +bpy.utils.script_paths(subdir="addons") +# render_freestyle_svg = os.path.join(bpy.utils.script_paths(subdir="addons"), "render_freestyle_svg.py") render_freestyle_svg = bpy.context.preferences.addons.get('render_freestyle_svg') # mpath=addon_utils.paths()[0].render_freestyle_svg # import mpath -# from mpath import render_freestyle_svg #= addon_utils.modules(['Freestyle SVG Exporter']) +# from mpath import render_freestyle_svg #= addon_utils.modules(module_cache=['Freestyle SVG Exporter']) # from scripts\\addons import render_freestyle_svg if check_render_freestyle_svg(): ''' diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py index 6335514b..bc4e06ea 100644 --- a/rigify/utils/mechanism.py +++ b/rigify/utils/mechanism.py @@ -401,7 +401,7 @@ def deactivate_custom_properties(obj, *, reset=True): for key, value in obj.items(): valtype = type(value) if valtype in {int, float}: - info = rna_idprop_ui_prop_get(obj, key, False) or {} + info = rna_idprop_ui_prop_get(obj, key, create=False) or {} obj[key] = valtype(info.get("default", 0)) @@ -435,7 +435,7 @@ def copy_custom_properties(src, dest, *, prefix='', dest_prefix='', link_driver= dest[new_key] = value if info: - info2 = rna_idprop_ui_prop_get(dest, new_key, True) + info2 = rna_idprop_ui_prop_get(dest, new_key, create=True) for ki, vi in info.items(): info2[ki] = vi diff --git a/space_view3d_pie_menus/pie_sculpt_menu.py b/space_view3d_pie_menus/pie_sculpt_menu.py index e50a47fa..9d343dc1 100644 --- a/space_view3d_pie_menus/pie_sculpt_menu.py +++ b/space_view3d_pie_menus/pie_sculpt_menu.py @@ -136,7 +136,7 @@ brush_icons = {} def create_icons(): global brush_icons - icons_directory = bpy.utils.system_resource('DATAFILES', "icons") + icons_directory = bpy.utils.system_resource('DATAFILES', path="icons") brushes = ["crease", "blob", "smooth", "draw", "clay", "clay_strips", "inflate", "grab", "nudge", "thumb", "snake_hook", "rotate", "flatten", "scrape", "fill", "pinch", "layer", "mask"] diff --git a/ui_translate/edit_translation.py b/ui_translate/edit_translation.py index 1aeee13a..b42560d4 100644 --- a/ui_translate/edit_translation.py +++ b/ui_translate/edit_translation.py @@ -73,14 +73,17 @@ class UI_OT_i18n_edittranslation_update_mo(Operator): def execute(self, context): if self.clean_mo: - root = bpy.utils.user_resource('DATAFILES', settings.settings.MO_PATH_ROOT_RELATIVE) + root = bpy.utils.user_resource('DATAFILES', path=settings.settings.MO_PATH_ROOT_RELATIVE) if root: shutil.rmtree(root) elif not (self.lang and self.po_file): return {'CANCELLED'} else: - mo_dir = bpy.utils.user_resource('DATAFILES', settings.settings.MO_PATH_TEMPLATE_RELATIVE.format(self.lang), - create=True) + mo_dir = bpy.utils.user_resource( + 'DATAFILES', + path=settings.settings.MO_PATH_TEMPLATE_RELATIVE.format(self.lang), + create=True, + ) mo_file = os.path.join(mo_dir, settings.settings.MO_FILE_NAME) _get_messages(self.lang, self.po_file).write(kind='MO', dest=mo_file) diff --git a/ui_translate/update_addon.py b/ui_translate/update_addon.py index 38b0ac8a..2eedc897 100644 --- a/ui_translate/update_addon.py +++ b/ui_translate/update_addon.py @@ -71,7 +71,7 @@ def enum_addons(self, context): global _cached_enum_addons setts = getattr(self, "settings", settings.settings) if not _cached_enum_addons: - for mod in addon_utils.modules(addon_utils.addons_fake_modules): + for mod in addon_utils.modules(module_cache=addon_utils.addons_fake_modules): mod_info = addon_utils.module_bl_info(mod) # Skip OFFICIAL addons, they are already translated in main i18n system (together with Blender itself). if mod_info["support"] in {'OFFICIAL'}: -- cgit v1.2.3