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'
This commit is contained in:
Andrej730
2023-06-09 19:38:16 +05:00
parent dfe7421dab
commit 8ac1bc6900
2 changed files with 11 additions and 0 deletions
@@ -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 = {
@@ -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