Bugfix for BIMTester purge function to overwrite existing feature files

This commit is contained in:
Dion Moult
2019-11-18 10:48:50 +11:00
parent c46167073b
commit 1e802bd0a3
+16 -13
View File
@@ -54,19 +54,22 @@ class TestPurger:
def purge(self): def purge(self):
for filename in Path('features/').glob('*.feature'): for filename in Path('features/').glob('*.feature'):
with open(filename, 'r') as feature_file: with open(filename, 'r') as feature_file:
with open('{}.purged'.format(filename), 'w') as new_file: old_file = feature_file.readlines()
for line in feature_file: with open(filename, 'w') as new_file:
if 'Given the IFC file ' in line: for line in old_file:
filename = line.split('"')[1] is_purged = False
print('Loading file {} ...'.format(filename)) if 'Given the IFC file ' in line:
self.file = ifcopenshell.open(filename) filename = line.split('"')[1]
if line.strip()[0:4] == 'Then': print('Loading file {} ...'.format(filename))
words = line.strip().split() self.file = ifcopenshell.open(filename)
for word in words: if line.strip()[0:4] == 'Then':
if self.is_a_global_id(word): words = line.strip().split()
if not self.does_global_id_exist(word): for word in words:
print('Test for {} purged ...'.format(word)) if self.is_a_global_id(word):
continue if not self.does_global_id_exist(word):
print('Test for {} purged ...'.format(word))
is_purged = True
if not is_purged:
new_file.write(line) new_file.write(line)
def is_a_global_id(self, word): def is_a_global_id(self, word):