mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 11:18:18 +00:00
IfcGit fixes suggested by ruff
This commit is contained in:
@@ -88,7 +88,7 @@ class IfcGitData:
|
|||||||
try:
|
try:
|
||||||
if tool.IfcGitRepo.repo.branches:
|
if tool.IfcGitRepo.repo.branches:
|
||||||
return tool.IfcGit.branches_by_hexsha(tool.IfcGitRepo.repo)
|
return tool.IfcGit.branches_by_hexsha(tool.IfcGitRepo.repo)
|
||||||
except:
|
except AttributeError:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
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 bpy
|
||||||
import logging
|
import logging
|
||||||
from blenderbim.bim import import_ifc
|
from blenderbim.bim import import_ifc
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
import blenderbim.tool as tool
|
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:
|
class IfcGit:
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -54,17 +53,19 @@ class IfcGit:
|
|||||||
else:
|
else:
|
||||||
return None
|
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
|
return IfcGitRepo.repo
|
||||||
|
|
||||||
try:
|
try:
|
||||||
repo = git.Repo(path_dir)
|
repo = git.Repo(path_dir)
|
||||||
except:
|
except git.exc.InvalidGitRepositoryError:
|
||||||
parentdir_path = os.path.abspath(os.path.join(path_dir, os.pardir))
|
parentdir_path = os.path.abspath(os.path.join(path_dir, os.pardir))
|
||||||
if parentdir_path == path_dir:
|
if parentdir_path == path_dir:
|
||||||
# root folder
|
# root folder
|
||||||
return None
|
return None
|
||||||
return cls.repo_from_path(parentdir_path)
|
return cls.repo_from_path(parentdir_path)
|
||||||
|
except git.exc.NoSuchPathError:
|
||||||
|
return None
|
||||||
if repo:
|
if repo:
|
||||||
IfcGitRepo.repo = repo
|
IfcGitRepo.repo = repo
|
||||||
return repo
|
return repo
|
||||||
@@ -181,9 +182,9 @@ class IfcGit:
|
|||||||
|
|
||||||
for commit in commits:
|
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
|
continue
|
||||||
elif props.ifcgit_filter == "relevant" and not commit in commits_relevant:
|
elif props.ifcgit_filter == "relevant" and commit not in commits_relevant:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
props.ifcgit_commits.add()
|
props.ifcgit_commits.add()
|
||||||
@@ -485,8 +486,7 @@ class IfcGit:
|
|||||||
cls.dos2unix(path_ifc)
|
cls.dos2unix(path_ifc)
|
||||||
repo.index.add(path_ifc)
|
repo.index.add(path_ifc)
|
||||||
repo.git.commit("--no-edit")
|
repo.git.commit("--no-edit")
|
||||||
except:
|
except git.exc.GitError:
|
||||||
|
|
||||||
operator.report({"ERROR"}, "Unknown IFC Merge failure")
|
operator.report({"ERROR"}, "Unknown IFC Merge failure")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ class IfcGit:
|
|||||||
query = "/^#" + str(step_id) + "[ =]/,/;/:" + relpath_ifc
|
query = "/^#" + str(step_id) + "[ =]/,/;/:" + relpath_ifc
|
||||||
try:
|
try:
|
||||||
logtext = repo.git.log("-L", query, "-s")
|
logtext = repo.git.log("-L", query, "-s")
|
||||||
except:
|
except git.exc.CommandError:
|
||||||
logtext = "No Git history found :("
|
logtext = "No Git history found :("
|
||||||
return logtext
|
return logtext
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user