Skip to content

Commit 449b281

Browse files
add streamline changes do my bimtester 5
1 parent d3fdff2 commit 449b281

File tree

6 files changed

+26
-69
lines changed

6 files changed

+26
-69
lines changed

src/ifcbimtester/bimtester/features/steps/geometric_detail/en.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,5 @@ def is_item_a_representation(item, representation):
217217
message_all_falseelems=_("All {elemcount} {ifc_class} elements are a {parameter} representation."),
218218
message_some_falseelems=_("The following {falsecount} of {elemcount} {ifc_class} elements are a {parameter} representation: {falseelems}"),
219219
message_no_elems=_("There are no {ifc_class} elements in the IFC file."),
220-
parameter=representation_class
220+
parameter=representation_class,
221221
)

src/ifcbimtester/bimtester/guiwidget.py

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def run():
3838

3939
class GuiWidgetBimTester(QtWidgets.QWidget):
4040
def __init__(self, args=None):
41-
super(GuiWidgetBimTester, self).__init__()
41+
super().__init__()
4242

4343
if args is not None and args != {}:
4444
self.args = args
@@ -65,9 +65,7 @@ def __del__(self):
6565

6666
def _setup_ui(self):
6767
package_path = os.path.dirname(os.path.realpath(__file__))
68-
iconpath = os.path.join(
69-
package_path, "resources", "icons", "bimtester.ico"
70-
)
68+
iconpath = os.path.join(package_path, "resources", "icons", "bimtester.ico")
7169

7270
"""
7371
# as svg
@@ -105,14 +103,8 @@ def _setup_ui(self):
105103
_ifcfile_browse_btn.clicked.connect(self.select_ifcfile)
106104

107105
# buttons
108-
self.run_button = QtWidgets.QPushButton(
109-
QtGui.QIcon.fromTheme("document-new"),
110-
"Run"
111-
)
112-
self.close_button = QtWidgets.QPushButton(
113-
QtGui.QIcon.fromTheme("window-close"),
114-
"Close"
115-
)
106+
self.run_button = QtWidgets.QPushButton(QtGui.QIcon.fromTheme("document-new"), "Run")
107+
self.close_button = QtWidgets.QPushButton(QtGui.QIcon.fromTheme("window-close"), "Close")
116108
self.run_button.clicked.connect(self.run_bimtester)
117109
self.close_button.clicked.connect(self.close_widget)
118110
_buttons = QtWidgets.QHBoxLayout()
@@ -139,9 +131,7 @@ def _setup_ui(self):
139131
self.setLayout(layout)
140132

141133
def select_ifcfile(self):
142-
ifcfile = QtWidgets.QFileDialog.getOpenFileName(
143-
self, dir=self.get_ifcfile()
144-
)[0]
134+
ifcfile = QtWidgets.QFileDialog.getOpenFileName(self, dir=self.get_ifcfile())[0]
145135
self.set_ifcfile(ifcfile)
146136

147137
def set_ifcfile(self, a_file):
@@ -153,9 +143,7 @@ def get_ifcfile(self):
153143
return " ".join(self.ifcfile_text.text().split())
154144

155145
def select_featurefile(self):
156-
featurefile = QtWidgets.QFileDialog.getOpenFileName(
157-
self, dir=self.get_ifcfile()
158-
)[0]
146+
featurefile = QtWidgets.QFileDialog.getOpenFileName(self, dir=self.get_ifcfile())[0]
159147
self.set_featurefile(featurefile)
160148

161149
def set_featurefile(self, a_file):
@@ -194,24 +182,15 @@ def run_bimtester(self):
194182
if has_feature_file is True and has_ifc_file is True:
195183
print("Args passed from BIMtester GUI:")
196184
print(json.dumps(self.args, indent=4))
197-
report_json = bimtester.run.TestRunner(
198-
self.args["ifc"],
199-
self.args["schema_file"]
200-
).run(self.args)
185+
report_json = bimtester.run.TestRunner(self.args["ifc"], self.args["schema_file"]).run(self.args)
201186
else:
202187
print("Missing files, BIMTester can not run.")
203188
report_json = ""
204189

205190
# create html report
206191
if os.path.isfile(report_json):
207-
report_html = os.path.join(
208-
os.path.dirname(os.path.realpath(report_json)),
209-
"report.html"
210-
)
211-
bimtester.reports.ReportGenerator().generate(
212-
report_json,
213-
report_html
214-
)
192+
report_html = os.path.join(os.path.dirname(os.path.realpath(report_json)), "report.html")
193+
bimtester.reports.ReportGenerator().generate(report_json, report_html)
215194
print("HTML report generated: {}".format(report_html))
216195
elif report_json == "":
217196
report_html = ""

src/ifcbimtester/bimtester/lang.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@ def switch_locale(locale_dir, locale_id):
3333
# https://docs.python.org/3/library/gettext.html
3434
mo_file = gettext.find(domain, localedir=locale_dir, languages=[locale_id])
3535
if mo_file is not None:
36-
print(
37-
"Locale will be switched to language '{}'. Translation file found {}"
38-
.format(locale_id, mo_file)
39-
)
36+
print("Locale will be switched to language '{}'. Translation file found {}".format(locale_id, mo_file))
4037
newlang = gettext.translation(domain, localedir=locale_dir, languages=[locale_id])
4138
newlang.install()
4239
translation = newlang.gettext
4340
else:
4441
print(
45-
"Locale can not be switched to '{}'. Translation file (*.mo) not found in {}"
46-
.format(locale_id, locale_dir)
42+
"Locale can not be switched to '{}'. Translation file (*.mo) not found in {}".format(locale_id, locale_dir)
4743
)

src/ifcbimtester/bimtester/reports.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ def generate_feature_report(self, feature, output_file):
8383
data["pass_rate"] = 0
8484

8585
# get language and switch locale
86-
the_lang = self.get_feature_lang(feature["keyword"])
86+
the_lang = self.get_feature_lang(feature.get("keyword", None))
8787
from bimtester.lang import switch_locale
88+
8889
switch_locale(os.path.join(self.base_path, "locale"), the_lang)
8990
data["_lang"] = the_lang
9091

@@ -198,6 +199,4 @@ def get_feature_lang(self, feature_key):
198199
return "it"
199200
elif feature_key == "Functionaliteit":
200201
return "nl"
201-
else:
202-
# standard English
203-
return "en"
202+
return "en"

src/ifcbimtester/bimtester/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@
2020
import sys
2121
import json
2222
import shutil
23+
import logging
2324
import time
2425
import tempfile
2526
import ifcopenshell
27+
try:
28+
import ifcopenshell.express
29+
except:
30+
pass # They are using an old version of IfcOpenShell. Gracefully degrade for now.
2631
import behave.formatter.pretty # Needed for pyinstaller to package it
2732
from bimtester.ifc import IfcStore
2833
from distutils.dir_util import copy_tree

src/ifcbimtester/bimtester/util.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def assert_elements(
117117
message_all_falseelems,
118118
message_some_falseelems,
119119
message_no_elems="",
120-
parameter=None
120+
parameter=None,
121121
):
122122
# improve output of falselems
123123
out_falseelems = "\n\n"
@@ -138,42 +138,20 @@ def assert_elements(
138138
# )
139139

140140
if falsecount == 0:
141-
return # test ok for elemcount == 0 and elemcount > 0
141+
return # test ok for elemcount == 0 and elemcount > 0
142142
elif falsecount == elemcount:
143143
if parameter is None:
144-
assert False, (
145-
message_all_falseelems.format(
146-
elemcount=elemcount,
147-
ifc_class=ifc_class
148-
) + "\n"
149-
)
144+
assert False, (message_all_falseelems.format(elemcount=elemcount, ifc_class=ifc_class) + "\n")
150145
else:
151146
assert False, (
152-
message_all_falseelems.format(
153-
elemcount=elemcount,
154-
ifc_class=ifc_class,
155-
parameter=parameter
156-
) + "\n"
157-
)
147+
message_all_falseelems.format(elemcount=elemcount, ifc_class=ifc_class, parameter=parameter) + "\n")
158148
elif falsecount > 0 and falsecount < elemcount:
159149
if parameter is None:
160150
assert False, (
161-
message_some_falseelems.format(
162-
falsecount=falsecount,
163-
elemcount=elemcount,
164-
ifc_class=ifc_class,
165-
falseelems=out_falseelems,
166-
) + "\n"
167-
)
151+
message_some_falseelems.format(falsecount=falsecount, elemcount=elemcount, ifc_class=ifc_class, falseelems=out_falseelems) + "\n")
168152
else:
169153
assert False, (
170-
message_some_falseelems.format(
171-
falsecount=falsecount,
172-
elemcount=elemcount,
173-
ifc_class=ifc_class,
174-
falseelems=out_falseelems,
175-
parameter=parameter
176-
) + "\n"
154+
message_some_falseelems.format(falsecount=falsecount, elemcount=elemcount, ifc_class=ifc_class, falseelems=out_falseelems, parameter=parameter) + "\n"
177155
)
178156
else:
179157
assert False, _("Error in falsecount calculation, something went wrong.") + "\n"

0 commit comments

Comments
 (0)