From 18a2996a934894774abd7af355388718c151f866 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 23 Jul 2020 13:42:41 +1000 Subject: [PATCH] Fix bug where COBie convert fails on empty names of related objects for assemblies --- src/ifcbimtester/bimtester.py | 75 ++++++++++++++++++----------------- src/ifccobie/cobie.py | 2 +- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/ifcbimtester/bimtester.py b/src/ifcbimtester/bimtester.py index 4170187f56..a9aacf309b 100644 --- a/src/ifcbimtester/bimtester.py +++ b/src/ifcbimtester/bimtester.py @@ -168,41 +168,42 @@ class TestPurger: return False -parser = argparse.ArgumentParser( - description='Runs unit tests for BIM data') -parser.add_argument( - '-p', - '--purge', - action='store_true', - help='Purge tests of deleted elements') -parser.add_argument( - '-r', - '--report', - action='store_true', - help='Generate a HTML report') -parser.add_argument( - '-c', - '--console', - action='store_true', - help='Show results in the console') -parser.add_argument( - '-f', - '--feature', - type=str, - help='Specify a feature file to test', - default='') -parser.add_argument( - '-a', - '--advanced-arguments', - type=str, - help='Specify your own arguments to Python\'s Behave', - default='') -args = vars(parser.parse_args()) +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description='Runs unit tests for BIM data') + parser.add_argument( + '-p', + '--purge', + action='store_true', + help='Purge tests of deleted elements') + parser.add_argument( + '-r', + '--report', + action='store_true', + help='Generate a HTML report') + parser.add_argument( + '-c', + '--console', + action='store_true', + help='Show results in the console') + parser.add_argument( + '-f', + '--feature', + type=str, + help='Specify a feature file to test', + default='') + parser.add_argument( + '-a', + '--advanced-arguments', + type=str, + help='Specify your own arguments to Python\'s Behave', + default='') + args = vars(parser.parse_args()) -if args['purge']: - TestPurger().purge() -elif args['report']: - generate_report() -else: - run_tests(args) -print('# All tasks are complete :-)') + if args['purge']: + TestPurger().purge() + elif args['report']: + generate_report() + else: + run_tests(args) + print('# All tasks are complete :-)') diff --git a/src/ifccobie/cobie.py b/src/ifccobie/cobie.py index 482483c426..20833dad18 100644 --- a/src/ifccobie/cobie.py +++ b/src/ifccobie/cobie.py @@ -357,7 +357,7 @@ class IfcCobieParser(): 'CreatedOn': self.get_created_on_from_history(assembly.OwnerHistory), 'SheetName': 'Assembly', 'ParentName': self.get_object_name(assembly.RelatingObject), - 'ChildNames': ','.join([o.Name for o in assembly.RelatedObjects]), + 'ChildNames': ','.join([o.Name if o.Name else '' for o in assembly.RelatedObjects]), 'AssemblyType': 'n/a', # I don't understand this field 'ExtSystem': self.get_ext_system_from_history(assembly.OwnerHistory), 'ExtObject': self.get_ext_object(assembly),