From 8ac1bc69004b34362319f95f49d8d429d1d93b52 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 9 Jun 2023 19:38:16 +0500 Subject: [PATCH] IfcGitData update to ifcgit operators poll() methods Added loading IfcGitData to ifcgit operator's poll() methods because it was getting a bit spammy in console if you don't use git. Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 255, in poll if IfcGitData.data["ifcmerge_exe"]: KeyError: 'ifcmerge_exe' Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 147, in poll repo = IfcGitData.data["repo"] KeyError: 'repo' Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 18, in poll path_ifc = IfcGitData.data["path_ifc"] KeyError: 'path_ifc' Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 45, in poll path_ifc = IfcGitData.data["path_ifc"] KeyError: 'path_ifc' Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 190, in poll repo = IfcGitData.data["repo"] KeyError: 'repo' Traceback (most recent call last): File "\scripts\addons\blenderbim\bim\module\ifcgit\operator.py", line 111, in poll repo = IfcGitData.data["repo"] KeyError: 'repo' --- src/blenderbim/blenderbim/bim/module/ifcgit/data.py | 5 +++++ src/blenderbim/blenderbim/bim/module/ifcgit/operator.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/blenderbim/blenderbim/bim/module/ifcgit/data.py b/src/blenderbim/blenderbim/bim/module/ifcgit/data.py index 4373aa8df5..611b879c64 100644 --- a/src/blenderbim/blenderbim/bim/module/ifcgit/data.py +++ b/src/blenderbim/blenderbim/bim/module/ifcgit/data.py @@ -15,6 +15,11 @@ class IfcGitData: data = {} is_loaded = False + @classmethod + def make_sure_is_loaded(cls): + if not cls.is_loaded: + cls.load() + @classmethod def load(cls): cls.data = { diff --git a/src/blenderbim/blenderbim/bim/module/ifcgit/operator.py b/src/blenderbim/blenderbim/bim/module/ifcgit/operator.py index b60bbd163f..f866772350 100644 --- a/src/blenderbim/blenderbim/bim/module/ifcgit/operator.py +++ b/src/blenderbim/blenderbim/bim/module/ifcgit/operator.py @@ -15,6 +15,7 @@ class CreateRepo(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() path_ifc = IfcGitData.data["path_ifc"] if not os.path.isfile(path_ifc): return False @@ -42,6 +43,7 @@ class AddFileToRepo(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() path_ifc = IfcGitData.data["path_ifc"] if not os.path.isfile(path_ifc): return False @@ -107,6 +109,7 @@ class CommitChanges(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() props = context.scene.IfcGitProperties repo = IfcGitData.data["repo"] if props.commit_message == "": @@ -143,6 +146,7 @@ class AddTag(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() props = context.scene.IfcGitProperties repo = IfcGitData.data["repo"] if repo and ( @@ -187,6 +191,7 @@ class RefreshGit(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() repo = IfcGitData.data["repo"] if repo != None and repo.heads: return True @@ -252,6 +257,7 @@ class Merge(bpy.types.Operator): @classmethod def poll(cls, context): + IfcGitData.make_sure_is_loaded() if IfcGitData.data["ifcmerge_exe"]: return True return False