mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Format ifcgit code with black
This commit is contained in:
@@ -15,44 +15,29 @@
|
|||||||
# 2023 Bruno Postle <bruno@postle.net>, Bruno Perdigão <brunoperdigao@tutanota.com>,
|
# 2023 Bruno Postle <bruno@postle.net>, Bruno Perdigão <brunoperdigao@tutanota.com>,
|
||||||
# Massimo Fabbro <maxfb87@yahoo.it>
|
# Massimo Fabbro <maxfb87@yahoo.it>
|
||||||
|
|
||||||
# import os
|
|
||||||
# import sys
|
|
||||||
import bpy
|
import bpy
|
||||||
from . import ui, prop, operator
|
from . import ui, prop, operator
|
||||||
|
|
||||||
# sys.path.insert(0, "/home/bruno/src/ifc-git")
|
|
||||||
# sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
||||||
|
|
||||||
# bl_info = {
|
|
||||||
# "name": "IFC Git",
|
|
||||||
# "author": "Bruno Postle",
|
|
||||||
# "location": "Scene > IFC Git",
|
|
||||||
# "description": "Manage IFC files in Git repositories",
|
|
||||||
# "blender": (2, 80, 0),
|
|
||||||
# "category": "Import-Export",
|
|
||||||
# }
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
operator.AddFileToRepo,
|
operator.AddFileToRepo,
|
||||||
operator.CommitChanges,
|
operator.CommitChanges,
|
||||||
operator.CreateRepo,
|
operator.CreateRepo,
|
||||||
operator.DiscardUncommitted,
|
operator.DiscardUncommitted,
|
||||||
operator.DisplayRevision,
|
operator.DisplayRevision,
|
||||||
operator.DisplayUncommitted,
|
operator.DisplayUncommitted,
|
||||||
operator.Merge,
|
operator.Merge,
|
||||||
operator.RefreshGit,
|
operator.RefreshGit,
|
||||||
operator.SwitchRevision,
|
operator.SwitchRevision,
|
||||||
prop.IfcGitListItem,
|
prop.IfcGitListItem,
|
||||||
prop.IfcGitProperties,
|
prop.IfcGitProperties,
|
||||||
ui.IFCGIT_PT_panel,
|
ui.IFCGIT_PT_panel,
|
||||||
ui.COMMIT_UL_List,
|
ui.COMMIT_UL_List,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.types.Scene.IfcGitProperties = bpy.props.PointerProperty(type=prop.IfcGitProperties)
|
bpy.types.Scene.IfcGitProperties = bpy.props.PointerProperty(type=prop.IfcGitProperties)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import bpy
|
import bpy
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
# import tool
|
# import tool
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ def git_branches(self, context):
|
|||||||
|
|
||||||
# NOTE "Python must keep a reference to the strings returned by
|
# NOTE "Python must keep a reference to the strings returned by
|
||||||
# the callback or Blender will misbehave or even crash"
|
# the callback or Blender will misbehave or even crash"
|
||||||
IfcGitData.data["branch_names"] = sorted(
|
IfcGitData.data["branch_names"] = sorted([branch.name for branch in IfcGitData.data["repo"].heads])
|
||||||
[branch.name for branch in IfcGitData.data["repo"].heads]
|
|
||||||
)
|
|
||||||
|
|
||||||
if "main" in IfcGitData.data["branch_names"]:
|
if "main" in IfcGitData.data["branch_names"]:
|
||||||
IfcGitData.data["branch_names"].remove("main")
|
IfcGitData.data["branch_names"].remove("main")
|
||||||
|
|||||||
@@ -71,9 +71,7 @@ class IFCGIT_PT_panel(bpy.types.Panel):
|
|||||||
|
|
||||||
if IfcGitData.data["repo"].head.is_detached:
|
if IfcGitData.data["repo"].head.is_detached:
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.label(
|
row.label(text="HEAD is detached, commit will create a branch", icon="ERROR")
|
||||||
text="HEAD is detached, commit will create a branch", icon="ERROR"
|
|
||||||
)
|
|
||||||
row.prop(props, "new_branch_name")
|
row.prop(props, "new_branch_name")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
@@ -83,9 +81,7 @@ class IFCGIT_PT_panel(bpy.types.Panel):
|
|||||||
if IfcGitData.data["repo"].head.is_detached:
|
if IfcGitData.data["repo"].head.is_detached:
|
||||||
row.label(text="Working branch: Detached HEAD")
|
row.label(text="Working branch: Detached HEAD")
|
||||||
else:
|
else:
|
||||||
row.label(
|
row.label(text="Working branch: " + IfcGitData.data["repo"].active_branch.name)
|
||||||
text="Working branch: " + IfcGitData.data["repo"].active_branch.name
|
|
||||||
)
|
|
||||||
|
|
||||||
grouped = layout.row()
|
grouped = layout.row()
|
||||||
column = grouped.column()
|
column = grouped.column()
|
||||||
@@ -141,9 +137,7 @@ class IFCGIT_PT_panel(bpy.types.Panel):
|
|||||||
class COMMIT_UL_List(bpy.types.UIList):
|
class COMMIT_UL_List(bpy.types.UIList):
|
||||||
"""List of Git commits"""
|
"""List of Git commits"""
|
||||||
|
|
||||||
def draw_item(
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
|
||||||
self, context, layout, data, item, icon, active_data, active_propname, index
|
|
||||||
):
|
|
||||||
|
|
||||||
props = context.scene.IfcGitProperties
|
props = context.scene.IfcGitProperties
|
||||||
|
|
||||||
@@ -166,9 +160,7 @@ class COMMIT_UL_List(bpy.types.UIList):
|
|||||||
refs += "{" + tag.name + "} "
|
refs += "{" + tag.name + "} "
|
||||||
|
|
||||||
if commit == current_revision:
|
if commit == current_revision:
|
||||||
layout.label(
|
layout.label(text="[HEAD] " + refs + commit.message, icon="DECORATE_KEYFRAME")
|
||||||
text="[HEAD] " + refs + commit.message, icon="DECORATE_KEYFRAME"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
layout.label(text=refs + commit.message, icon="DECORATE_ANIMATE")
|
layout.label(text=refs + commit.message, icon="DECORATE_ANIMATE")
|
||||||
layout.label(text=time.strftime("%c", time.localtime(commit.committed_date)))
|
layout.label(text=time.strftime("%c", time.localtime(commit.committed_date)))
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ class IfcGit:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def add_file_to_repo(cls, repo, path_file):
|
def add_file_to_repo(cls, repo, path_file):
|
||||||
repo.index.add(path_file)
|
repo.index.add(path_file)
|
||||||
repo.index.commit(
|
repo.index.commit(message="Added " + os.path.relpath(path_file, repo.working_dir))
|
||||||
message="Added " + os.path.relpath(path_file, repo.working_dir)
|
|
||||||
)
|
|
||||||
bpy.ops.ifcgit.refresh()
|
bpy.ops.ifcgit.refresh()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -63,7 +61,6 @@ class IfcGit:
|
|||||||
repo.index.add(path_file)
|
repo.index.add(path_file)
|
||||||
repo.index.commit(message=props.commit_message)
|
repo.index.commit(message=props.commit_message)
|
||||||
props.commit_message = ""
|
props.commit_message = ""
|
||||||
return repo
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_new_branch(cls):
|
def create_new_branch(cls):
|
||||||
@@ -209,9 +206,7 @@ class IfcGit:
|
|||||||
current_revision = repo.commit()
|
current_revision = repo.commit()
|
||||||
|
|
||||||
if selected_revision == current_revision:
|
if selected_revision == current_revision:
|
||||||
area = next(
|
area = next(area for area in bpy.context.screen.areas if area.type == "VIEW_3D")
|
||||||
area for area in bpy.context.screen.areas if area.type == "VIEW_3D"
|
|
||||||
)
|
|
||||||
area.spaces[0].shading.color_type = "MATERIAL"
|
area.spaces[0].shading.color_type = "MATERIAL"
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -249,9 +244,7 @@ class IfcGit:
|
|||||||
final_step_ids = {}
|
final_step_ids = {}
|
||||||
final_step_ids["added"] = step_ids["added"]
|
final_step_ids["added"] = step_ids["added"]
|
||||||
final_step_ids["removed"] = step_ids["removed"]
|
final_step_ids["removed"] = step_ids["removed"]
|
||||||
final_step_ids["modified"] = step_ids["modified"].union(
|
final_step_ids["modified"] = step_ids["modified"].union(modified_shape_object_step_ids["modified"])
|
||||||
modified_shape_object_step_ids["modified"]
|
|
||||||
)
|
|
||||||
return final_step_ids
|
return final_step_ids
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -311,9 +304,7 @@ class IfcGit:
|
|||||||
section = 'mergetool "ifcmerge"'
|
section = 'mergetool "ifcmerge"'
|
||||||
if not config_reader.has_section(section):
|
if not config_reader.has_section(section):
|
||||||
config_writer = IfcGitRepo.repo.config_writer()
|
config_writer = IfcGitRepo.repo.config_writer()
|
||||||
config_writer.set_value(
|
config_writer.set_value(section, "cmd", "ifcmerge $BASE $LOCAL $REMOTE $MERGED")
|
||||||
section, "cmd", "ifcmerge $BASE $LOCAL $REMOTE $MERGED"
|
|
||||||
)
|
|
||||||
config_writer.set_value(section, "trustExitCode", True)
|
config_writer.set_value(section, "trustExitCode", True)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user