| 1 |
# BIMTester - OpenBIM Auditing Tool |
| 2 |
# Copyright (C) 2021 Dion Moult <[email protected]> |
| 3 |
# |
| 4 |
# This file is part of BIMTester. |
| 5 |
# |
| 6 |
# BIMTester is free software: you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU Lesser General Public License as published by |
| 8 |
# the Free Software Foundation, either version 3 of the License, or |
| 9 |
# (at your option) any later version. |
| 10 |
# |
| 11 |
# BIMTester is distributed in the hope that it will be useful, |
| 12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
# GNU Lesser General Public License for more details. |
| 15 |
# |
| 16 |
# You should have received a copy of the GNU Lesser General Public License |
| 17 |
# along with BIMTester. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
import json |
| 20 |
|
| 21 |
|
| 22 |
def create_logfile(thelogfile, ifcbasename): |
| 23 |
|
| 24 |
logfile = open(thelogfile, "w") |
| 25 |
logfile.write("BIMTester log file\n") |
| 26 |
logfile.write("------------------\n\n") |
| 27 |
logfile.write("ifc base file name: {}\n".format(ifcbasename)) |
| 28 |
logfile.close() |
| 29 |
|
| 30 |
|
| 31 |
def append_logfile(thecontext, step): |
| 32 |
|
| 33 |
# step attributes (also these set by user) scope is the scenario |
| 34 |
# https://behave.readthedocs.io/en/latest/thecontext_attributes.html |
| 35 |
print("Step '{}' failed".format(step.name)) |
| 36 |
|
| 37 |
# log file |
| 38 |
logfile = open(thecontext.thelogfile, "a") |
| 39 |
logfile.write("\n\nStep '{}' failed\n".format(step.name)) |
| 40 |
if hasattr(thecontext, "falseelems"): |
| 41 |
logfile.write("{}\n".format(json.dumps(thecontext.falseelems, indent=4))) |
| 42 |
if hasattr(thecontext, "falseprops"): |
| 43 |
logfile.write("{}\n".format(json.dumps(thecontext.falseprops, indent=4))) |
| 44 |
logfile.close() |