IfcGit fixes suggested by ruff

This commit is contained in:
Bruno Postle
2024-01-15 22:16:19 +00:00
parent 44c9aee727
commit 616d23d804
2 changed files with 15 additions and 15 deletions
@@ -88,7 +88,7 @@ class IfcGitData:
try:
if tool.IfcGitRepo.repo.branches:
return tool.IfcGit.branches_by_hexsha(tool.IfcGitRepo.repo)
except:
except AttributeError:
return {}
@classmethod
+14 -14
View File
@@ -1,18 +1,17 @@
import os
import re
# allows git import even if git executable isn't found
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
try:
import git
except:
print("Warning: GitPython not available.")
import bpy
import logging
from blenderbim.bim import import_ifc
from blenderbim.bim.ifc import IfcStore
import blenderbim.tool as tool
# allows git import even if git executable isn't found
os.environ["GIT_PYTHON_REFRESH"] = "quiet"
try:
import git
except ImportError:
print("Warning: GitPython not available.")
class IfcGit:
@classmethod
@@ -54,17 +53,19 @@ class IfcGit:
else:
return None
if IfcGitRepo.repo != None and IfcGitRepo.repo.working_dir == path_dir:
if IfcGitRepo.repo is not None and IfcGitRepo.repo.working_dir == path_dir:
return IfcGitRepo.repo
try:
repo = git.Repo(path_dir)
except:
except git.exc.InvalidGitRepositoryError:
parentdir_path = os.path.abspath(os.path.join(path_dir, os.pardir))
if parentdir_path == path_dir:
# root folder
return None
return cls.repo_from_path(parentdir_path)
except git.exc.NoSuchPathError:
return None
if repo:
IfcGitRepo.repo = repo
return repo
@@ -181,9 +182,9 @@ class IfcGit:
for commit in commits:
if props.ifcgit_filter == "tagged" and not commit.hexsha in lookup:
if props.ifcgit_filter == "tagged" and commit.hexsha not in lookup:
continue
elif props.ifcgit_filter == "relevant" and not commit in commits_relevant:
elif props.ifcgit_filter == "relevant" and commit not in commits_relevant:
continue
props.ifcgit_commits.add()
@@ -485,8 +486,7 @@ class IfcGit:
cls.dos2unix(path_ifc)
repo.index.add(path_ifc)
repo.git.commit("--no-edit")
except:
except git.exc.GitError:
operator.report({"ERROR"}, "Unknown IFC Merge failure")
return False
@@ -506,7 +506,7 @@ class IfcGit:
query = "/^#" + str(step_id) + "[ =]/,/;/:" + relpath_ifc
try:
logtext = repo.git.log("-L", query, "-s")
except:
except git.exc.CommandError:
logtext = "No Git history found :("
return logtext