From 7b4e65cbb7fc463307019faa1ee835a717eb0777 Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Sat, 24 May 2025 15:22:01 +0200 Subject: [PATCH] check for None --- butils.py | 10 +++++----- common/Font.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/butils.py b/butils.py index 9b696d1..6663a1a 100644 --- a/butils.py +++ b/butils.py @@ -358,7 +358,7 @@ def turn_collection_hierarchy_into_path(obj): def find_font_object(fontcollection, font_name): fonts = find_objects_by_custom_property(fontcollection.objects, "is_font", True) for font in fonts: - if font["font_name"] == font_name and font.parent == None: + if font["font_name"] == font_name and font.parent is None: return font return None @@ -375,7 +375,7 @@ def move_in_fontcollection(obj, fontcollection, allow_duplicates=False): # parent nesting structure # the font object font_obj = find_font_object(fontcollection, obj["font_name"]) - if font_obj == None: + if font_obj is None: font_obj = bpy.data.objects.new(obj["font_name"], None) font_obj.empty_display_type = "PLAIN_AXES" fontcollection.objects.link(font_obj) @@ -386,7 +386,7 @@ def move_in_fontcollection(obj, fontcollection, allow_duplicates=False): # the face object as a child of font object face_obj = find_font_face_object(font_obj, obj["face_name"]) - if face_obj == None: + if face_obj is None: face_obj = bpy.data.objects.new(obj["face_name"], None) face_obj.empty_display_type = "PLAIN_AXES" face_obj["is_face"] = True @@ -678,8 +678,8 @@ def is_metrics_object(o): if f"{utils.prefix()}_type" in o: return o[f"{utils.prefix()}_type"] == "metrics" return ( - re.match(".*_metrics$", o.name) != None - or re.match(".*_metrics.[\d]{3}$", o.name) != None + re.match(".*_metrics$", o.name) is not None + or re.match(".*_metrics.[\d]{3}$", o.name) is not None ) and is_mesh(o) diff --git a/common/Font.py b/common/Font.py index bcb7949..e7a7ac0 100644 --- a/common/Font.py +++ b/common/Font.py @@ -163,7 +163,7 @@ class Font: def register_font(font_name, face_name, glyphs_in_fontfile, filepath): if not fonts.keys().__contains__(font_name): fonts[font_name] = Font({}) - if fonts[font_name].faces.get(face_name) == None: + if fonts[font_name].faces.get(face_name) is None: fonts[font_name].faces[face_name] = FontFace({}) fonts[font_name].faces[face_name].glyphs_in_fontfile = glyphs_in_fontfile else: @@ -193,9 +193,9 @@ def add_glyph(font_name, face_name, glyph_id, glyph_object): if not fonts.keys().__contains__(font_name): fonts[font_name] = Font({}) - if fonts[font_name].faces.get(face_name) == None: + if fonts[font_name].faces.get(face_name) is None: fonts[font_name].faces[face_name] = FontFace({}) - if fonts[font_name].faces[face_name].glyphs.get(glyph_id) == None: + if fonts[font_name].faces[face_name].glyphs.get(glyph_id) is None: fonts[font_name].faces[face_name].glyphs[glyph_id] = [] fonts[font_name].faces[face_name].glyphs.get(glyph_id).append(glyph_object) @@ -224,13 +224,13 @@ def get_glyph(font_name, face_name, glyph_id, alternate=0): return None face = fonts[font_name].faces.get(face_name) - if face == None: + if face is None: # print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) not found") # print(fonts[font_name].faces.keys()) return None glyphs_for_id = face.glyphs.get(glyph_id) - if glyphs_for_id == None or len(glyphs_for_id) <= alternate: + if glyphs_for_id is None or len(glyphs_for_id) <= alternate: # print(f"ABC3D::get_glyph: font({font_name}) face({face_name}) glyph({glyph_id})[{alternate}] not found") if glyph_id not in fonts[font_name].faces[face_name].missing_glyphs: fonts[font_name].faces[face_name].missing_glyphs.append(glyph_id) @@ -243,7 +243,7 @@ def test_glyphs_availability(font_name, face_name, text): # maybe there is NOTHING yet if ( not fonts.keys().__contains__(font_name) - or fonts[font_name].faces.get(face_name) == None + or fonts[font_name].faces.get(face_name) is None ): return "", "", text # , , @@ -286,7 +286,7 @@ MISSING_FACE = 1 def test_availability(font_name, face_name, text): if not fonts.keys().__contains__(font_name): return MISSING_FONT - if fonts[font_name].faces.get(face_name) == None: + if fonts[font_name].faces.get(face_name) is None: return MISSING_FACE loaded, missing, maybe, filepaths = test_glyphs_availability( font_name, face_name, text