python-eigen-ingenuity-nocli 0.5.32b2__py3-none-any.whl → 0.5.33__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- modelbuilder/src/configmanager.py +2 -1
- modelbuilder/src/filemanager.py +29 -12
- modelbuilder/src/processors/labelmanager.py +1 -1
- modelbuilder/src/processors/nodefileprocessor.py +69 -41
- modelbuilder/src/processors/relationshipfileprocessor.py +58 -45
- modelbuilder/src/property.py +17 -41
- modelbuilder/src/querymanager.py +44 -78
- {python_eigen_ingenuity_nocli-0.5.32b2.dist-info → python_eigen_ingenuity_nocli-0.5.33.dist-info}/METADATA +1 -1
- {python_eigen_ingenuity_nocli-0.5.32b2.dist-info → python_eigen_ingenuity_nocli-0.5.33.dist-info}/RECORD +11 -11
- {python_eigen_ingenuity_nocli-0.5.32b2.dist-info → python_eigen_ingenuity_nocli-0.5.33.dist-info}/WHEEL +1 -1
- {python_eigen_ingenuity_nocli-0.5.32b2.dist-info → python_eigen_ingenuity_nocli-0.5.33.dist-info}/top_level.txt +0 -0
|
@@ -265,6 +265,7 @@ class ConfigManager:
|
|
|
265
265
|
self.no_version = True
|
|
266
266
|
|
|
267
267
|
def read_csv_config(self):
|
|
268
|
+
self.default_encoding = self.get_config_value("DEFAULT", "Encoding", False)
|
|
268
269
|
self.separators = {s: self.get_config_value(s, "Separator", self.separator, allow_comma=True) for s in self.available_sections}
|
|
269
270
|
self.primary_property = {s: self.primary_property_override or self.get_config_value(s, "PrimaryProperty", "node") for s in self.available_sections}
|
|
270
271
|
self.default_data_type = {s: self.get_config_value(s, "DataType", "") for s in self.available_sections}
|
|
@@ -638,7 +639,7 @@ class ConfigManager:
|
|
|
638
639
|
return self.logger
|
|
639
640
|
|
|
640
641
|
def get_force_encoding(self):
|
|
641
|
-
return self.force_encoding
|
|
642
|
+
return self.force_encoding or self.default_encoding
|
|
642
643
|
|
|
643
644
|
def get_detect_encoding(self):
|
|
644
645
|
return self.detect_encoding
|
modelbuilder/src/filemanager.py
CHANGED
|
@@ -40,6 +40,7 @@ class FileManager:
|
|
|
40
40
|
# And a list of lists for the queries in specified priority order
|
|
41
41
|
self.valid_file_list = [[], [], [], [], [], []]
|
|
42
42
|
|
|
43
|
+
self.file_count = 0
|
|
43
44
|
self.invalid_file_count = 0
|
|
44
45
|
|
|
45
46
|
self.config_section = config_manager.get_config_section()
|
|
@@ -87,8 +88,10 @@ class FileManager:
|
|
|
87
88
|
file = a_file
|
|
88
89
|
this_section = section
|
|
89
90
|
self.analyse_csv_file(file, this_section)
|
|
91
|
+
self.file_count += 1
|
|
90
92
|
case 'cypher' | 'qry':
|
|
91
93
|
self.analyse_cypher_file(a_file)
|
|
94
|
+
self.file_count += 1
|
|
92
95
|
case 'lst':
|
|
93
96
|
self.analyse_lst_file(a_file, section)
|
|
94
97
|
case _:
|
|
@@ -106,6 +109,7 @@ class FileManager:
|
|
|
106
109
|
self.valid_file_list[priority] += [{'processor': file_processor, 'type': file_type}]
|
|
107
110
|
else:
|
|
108
111
|
info_message(file_processor.get_filename(), ' not processed as requested')
|
|
112
|
+
self.file_count -= 1
|
|
109
113
|
|
|
110
114
|
def analyse_lst_file(self, filename, def_section=''):
|
|
111
115
|
recurse_dirs = self.config_manager.get_recurse_dirs()
|
|
@@ -162,12 +166,14 @@ class FileManager:
|
|
|
162
166
|
else:
|
|
163
167
|
query_processor = CypherFileProcessor(a_query, self.config_manager, True)
|
|
164
168
|
self.add_file_to_process_list(query_processor, 'pre')
|
|
169
|
+
self.file_count += 1
|
|
165
170
|
|
|
166
171
|
labels_to_delete_list = self.config_manager.get_labels_to_delete_list()
|
|
167
172
|
if labels_to_delete_list == []:
|
|
168
173
|
query = 'MATCH (n) DETACH DELETE n'
|
|
169
174
|
query_processor = CypherFileProcessor(query, self.config_manager, True)
|
|
170
175
|
self.add_file_to_process_list(query_processor, 'pre')
|
|
176
|
+
self.file_count += 1
|
|
171
177
|
else:
|
|
172
178
|
for label_list in labels_to_delete_list:
|
|
173
179
|
match_list = ''
|
|
@@ -183,6 +189,7 @@ class FileManager:
|
|
|
183
189
|
query += 'DETACH DELETE n'
|
|
184
190
|
query_processor = CypherFileProcessor(query, self.config_manager, True)
|
|
185
191
|
self.add_file_to_process_list(query_processor, 'pre')
|
|
192
|
+
self.file_count += 1
|
|
186
193
|
|
|
187
194
|
# Process each file in the list, and determine its content type (ignoring any clues in the filename!)
|
|
188
195
|
# Analyse each of the specified input .csv files to determine if they contain Nodes or Relationships
|
|
@@ -190,13 +197,13 @@ class FileManager:
|
|
|
190
197
|
file_list = self.config_manager.get_input_file_list()
|
|
191
198
|
dir_list = self.config_manager.get_input_dir_list()
|
|
192
199
|
recurse_dirs = self.config_manager.get_recurse_dirs()
|
|
193
|
-
|
|
200
|
+
|
|
194
201
|
for a_file in file_list:
|
|
195
202
|
a_file_split = a_file.split(',')
|
|
196
203
|
for a_split_file in a_file_split:
|
|
197
204
|
if a_split_file != '':
|
|
198
205
|
self.analyse_a_file(a_split_file.strip(), self.config_section)
|
|
199
|
-
|
|
206
|
+
|
|
200
207
|
for a_dir in dir_list:
|
|
201
208
|
a_dir_split = a_dir.split(',')
|
|
202
209
|
for a_split_dir in a_dir_split:
|
|
@@ -238,6 +245,7 @@ class FileManager:
|
|
|
238
245
|
else:
|
|
239
246
|
query_processor = CypherFileProcessor(a_query, self.config_manager, True)
|
|
240
247
|
self.add_file_to_process_list(query_processor, 'post')
|
|
248
|
+
self.file_count += 1
|
|
241
249
|
|
|
242
250
|
def add_file_to_list(self, this_file_processor, this_file_type, file_errors=None):
|
|
243
251
|
|
|
@@ -317,6 +325,7 @@ class FileManager:
|
|
|
317
325
|
def process_not_found_files(self):
|
|
318
326
|
for file in self.file_not_found_list:
|
|
319
327
|
warning_message(f'{file} not found')
|
|
328
|
+
self.file_count -= 1
|
|
320
329
|
|
|
321
330
|
def process_unrecognised_file_type_files(self):
|
|
322
331
|
for file in self.unrecognised_file_type_list:
|
|
@@ -325,43 +334,50 @@ class FileManager:
|
|
|
325
334
|
def process_incorrect_files(self):
|
|
326
335
|
for file in self.incorrect_file_list:
|
|
327
336
|
error_message(f'{file} is not a correctly formatted .csv file - file not processed')
|
|
337
|
+
self.file_count -= 1
|
|
328
338
|
|
|
329
339
|
def process_incorrect_sections(self):
|
|
330
340
|
for file in self.incorrect_section_list:
|
|
331
341
|
error_message(f'{file} has an invalid config section - file not processed')
|
|
342
|
+
self.file_count -= 1
|
|
332
343
|
|
|
333
344
|
def process_incomplete_files(self):
|
|
334
345
|
for file in self.incomplete_file_list:
|
|
335
346
|
error_message(f'{file[0]} has incomplete data in rows {file[1]} - file not processed')
|
|
347
|
+
self.file_count -= 1
|
|
336
348
|
|
|
337
349
|
def process_neither_found_files(self):
|
|
338
350
|
for file in self.neither_file_list:
|
|
339
351
|
error_message(f'Insufficient data in {file} to determine content type - file not processed')
|
|
352
|
+
self.file_count -= 1
|
|
340
353
|
|
|
341
354
|
def process_both_files(self):
|
|
342
355
|
for file in self.both_file_list:
|
|
343
356
|
error_message(f'Ambiguous data in {file} - could be multiple content types - file not processed')
|
|
357
|
+
self.file_count -= 1
|
|
344
358
|
|
|
345
359
|
def process_valid_files(self, db_connector):
|
|
360
|
+
file_count = 0
|
|
346
361
|
num_queries = 0
|
|
347
362
|
for group in self.valid_file_list:
|
|
348
363
|
for file in group:
|
|
364
|
+
file_count += 1
|
|
349
365
|
processor = file['processor']
|
|
350
366
|
match file['type']:
|
|
351
367
|
case 'n':
|
|
352
368
|
if self.batch_rate == 0:
|
|
353
|
-
queries, file_result, version_result = self.process_file(processor, NodeFileProcessor.process_node_file, db_connector)
|
|
369
|
+
queries, file_result, version_result = self.process_file(processor, NodeFileProcessor.process_node_file, db_connector, file_count)
|
|
354
370
|
else:
|
|
355
|
-
queries, file_result, version_result = self.process_file(processor, NodeFileProcessor.process_node_file_batch, db_connector)
|
|
371
|
+
queries, file_result, version_result = self.process_file(processor, NodeFileProcessor.process_node_file_batch, db_connector, file_count)
|
|
356
372
|
case 'r':
|
|
357
373
|
if self.batch_rate == 0:
|
|
358
|
-
queries, file_result, version_result = self.process_file(processor, RelationshipFileProcessor.process_relationship_file, db_connector)
|
|
374
|
+
queries, file_result, version_result = self.process_file(processor, RelationshipFileProcessor.process_relationship_file, db_connector, file_count)
|
|
359
375
|
else:
|
|
360
|
-
queries, file_result, version_result = self.process_file(processor, RelationshipFileProcessor.process_relationship_file_batch, db_connector)
|
|
376
|
+
queries, file_result, version_result = self.process_file(processor, RelationshipFileProcessor.process_relationship_file_batch, db_connector, file_count)
|
|
361
377
|
case 'c' | 'pre-file' | 'post-file':
|
|
362
|
-
queries, file_result, version_result = self.process_file(processor, CypherFileProcessor.process_cypher_file, db_connector)
|
|
378
|
+
queries, file_result, version_result = self.process_file(processor, CypherFileProcessor.process_cypher_file, db_connector, file_count)
|
|
363
379
|
case 'q' | 'pre' | 'post':
|
|
364
|
-
queries, file_result, version_result = self.process_file(processor, CypherFileProcessor.process_query_list, db_connector)
|
|
380
|
+
queries, file_result, version_result = self.process_file(processor, CypherFileProcessor.process_query_list, db_connector, file_count)
|
|
365
381
|
case _:
|
|
366
382
|
# This should never happen!
|
|
367
383
|
queries = 0
|
|
@@ -376,7 +392,7 @@ class FileManager:
|
|
|
376
392
|
|
|
377
393
|
return num_queries
|
|
378
394
|
|
|
379
|
-
def process_file(self, file_to_process, file_processor, db_connector):
|
|
395
|
+
def process_file(self, file_to_process, file_processor, db_connector, file_count):
|
|
380
396
|
node_queries = 0
|
|
381
397
|
num_errors = 0
|
|
382
398
|
error_list = []
|
|
@@ -405,10 +421,11 @@ class FileManager:
|
|
|
405
421
|
else:
|
|
406
422
|
section = ''
|
|
407
423
|
|
|
424
|
+
file_message = f' {file_count} of {self.file_count}, "{file_to_process.get_filename()}"{section} at {amu.get_formatted_time_now()}'
|
|
408
425
|
if file_to_process.is_inline_query():
|
|
409
|
-
report_message(f'Processing query
|
|
426
|
+
report_message(f'Processing query{file_message}')
|
|
410
427
|
else:
|
|
411
|
-
report_message(f'Processing file
|
|
428
|
+
report_message(f'Processing file{file_message}')
|
|
412
429
|
# Build all the queries from the file, depending on the content type of the file
|
|
413
430
|
queries = file_processor(file_to_process)
|
|
414
431
|
message(f'{len(queries)} queries generated from {file_to_process.get_filename()}, processing...')
|
|
@@ -428,7 +445,7 @@ class FileManager:
|
|
|
428
445
|
|
|
429
446
|
try:
|
|
430
447
|
if self.min_display_rate:
|
|
431
|
-
display_rate = max(display_rate,int(ast.literal_eval(self.min_display_rate)))
|
|
448
|
+
display_rate = max(display_rate, int(ast.literal_eval(self.min_display_rate)))
|
|
432
449
|
except:
|
|
433
450
|
pass
|
|
434
451
|
else:
|
|
@@ -124,7 +124,7 @@ def strip_quotes(quote_list):
|
|
|
124
124
|
def merge_node_labels(merge_labels, node_labels):
|
|
125
125
|
wanted, _, remove = sort_labels(merge_labels, node_labels)
|
|
126
126
|
merged_labels = [i for i in merge_labels + wanted if not i in remove]
|
|
127
|
-
return merged_labels
|
|
127
|
+
return list(set(merged_labels))
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
def merge_labels(self, required_labels, unrequired_labels, remove_labels):
|
|
@@ -7,6 +7,7 @@ import processors.labelmanager as lm
|
|
|
7
7
|
import processors.propertymanager as pm
|
|
8
8
|
import property
|
|
9
9
|
from property import Neo4jProperty
|
|
10
|
+
import copy
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class NodeFileProcessor:
|
|
@@ -62,9 +63,9 @@ class NodeFileProcessor:
|
|
|
62
63
|
|
|
63
64
|
queries = []
|
|
64
65
|
|
|
65
|
-
num_rows = num_data_rows - self.start_from + 1
|
|
66
66
|
this_row = self.start_from-1
|
|
67
67
|
last_row = self.get_last_row(num_data_rows)
|
|
68
|
+
num_rows = last_row - self.start_from + 1
|
|
68
69
|
property_ref = 'n'
|
|
69
70
|
property_ref_dot = property_ref + '.'
|
|
70
71
|
|
|
@@ -79,41 +80,68 @@ class NodeFileProcessor:
|
|
|
79
80
|
# Split out those properties that are dependent on others, so that we can add them in the right order
|
|
80
81
|
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
81
82
|
|
|
83
|
+
|
|
84
|
+
# Can put this code here (potentially faster) but with less error checking
|
|
85
|
+
# Or leave it inside the for loop
|
|
86
|
+
|
|
87
|
+
# param_explicit_props = self.query_manager.parameterise_property_dict(explicit_properties, self.section)
|
|
88
|
+
# param_calc_props = self.query_manager.parameterise_property_dict(calculated_properties, self.section)
|
|
89
|
+
# param_properties = []
|
|
90
|
+
# num_param_properties = max(len(param_explicit_props), len(param_calc_props))
|
|
91
|
+
# for count in range(num_param_properties):
|
|
92
|
+
# param_properties += [[param_explicit_props[min(count, len(param_explicit_props) - 1)], param_calc_props[min(count, len(param_calc_props) - 1)]]]
|
|
93
|
+
|
|
82
94
|
for primary_property in self.contents.get_property_values_list(this_row, node_columns, self.primary_property, allow_split=True, override_format='str'):
|
|
95
|
+
primary_property_dict = {primary_property.key: primary_property}
|
|
96
|
+
param_primary_props = self.query_manager.parameterise_property_dict(primary_property_dict, self.section)
|
|
97
|
+
|
|
98
|
+
# The next chunk could be moved outside the primary_property loop to be more performant if (a big if) there are multiple node columns (which is very unusual)
|
|
99
|
+
# The downside is that some parameter error checking is lost
|
|
100
|
+
# If the code is moved, remove the last parameter in the first two calls since we won't know it above
|
|
101
|
+
param_explicit_props = self.query_manager.parameterise_property_dict(explicit_properties, self.section, len(param_primary_props))
|
|
102
|
+
param_calc_props = self.query_manager.parameterise_property_dict(calculated_properties, self.section, len(param_primary_props))
|
|
103
|
+
param_properties = []
|
|
104
|
+
num_param_properties = max(len(param_explicit_props), len(param_calc_props))
|
|
105
|
+
for count in range(num_param_properties):
|
|
106
|
+
param_properties += [[param_explicit_props[min(count, len(param_explicit_props) - 1)], param_calc_props[min(count, len(param_calc_props) - 1)]]]
|
|
107
|
+
|
|
83
108
|
time_now = amu.get_formatted_time_now()
|
|
84
109
|
merge_labels, new_labels, remove_labels = lm.sort_node_labels(self.required_labels, validated_csv_labels)
|
|
85
110
|
node_labels = lm.merge_node_labels(merge_labels, primary_property.labels)
|
|
86
|
-
|
|
111
|
+
# node_labels = lm.merge_node_labels(node_labels, new_labels)
|
|
112
|
+
for prop_counter in range(len(param_primary_props)):
|
|
87
113
|
# Build a simple MERGE query using queries
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# Add in System properties if required
|
|
94
|
-
if self.add_system_properties:
|
|
95
|
-
new_uuid = str(uuid.uuid4())
|
|
96
|
-
create_time = property_ref_dot + self.creation_time_property + '=datetime("' + time_now + '")'
|
|
97
|
-
id_property = property_ref_dot + self.unique_id_property
|
|
98
|
-
update_id = id_property + '= CASE WHEN ' + id_property + ' IS null THEN "' + new_uuid + '" ELSE ' + id_property + ' END,' +\
|
|
99
|
-
property_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
100
|
-
query_text = query_text.on_create().set_literal(create_time).set_literal(update_id)
|
|
101
|
-
|
|
102
|
-
if len(new_labels) > 0:
|
|
103
|
-
query_text = query_text.set_labels(ref_name=property_ref, labels=new_labels)
|
|
104
|
-
if len(remove_labels) > 0:
|
|
105
|
-
query_text = query_text.remove_literal(f'{property_ref}:{":".join(remove_labels)}')
|
|
106
|
-
if len(explicit_properties) > 0:
|
|
107
|
-
query_text = query_text.set(properties=explicit_properties, property_ref=property_ref_dot)
|
|
108
|
-
if len(calculated_properties) > 0:
|
|
109
|
-
query_text = query_text.set(properties=calculated_properties, property_ref=property_ref_dot)
|
|
114
|
+
query_text = (QueryBuilder()
|
|
115
|
+
.merge()
|
|
116
|
+
.node(labels=node_labels, ref_name=property_ref, properties=param_primary_props[prop_counter])
|
|
117
|
+
)
|
|
110
118
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
# Add in System properties if required
|
|
120
|
+
if self.add_system_properties:
|
|
121
|
+
new_uuid = str(uuid.uuid4())
|
|
122
|
+
create_time = property_ref_dot + self.creation_time_property + '=datetime("' + time_now + '")'
|
|
123
|
+
id_property = property_ref_dot + self.unique_id_property
|
|
124
|
+
update_id = id_property + '= CASE WHEN ' + id_property + ' IS null THEN "' + new_uuid + '" ELSE ' + id_property + ' END,' +\
|
|
125
|
+
property_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
126
|
+
query_text = query_text.on_create().set_literal(create_time).set_literal(update_id)
|
|
127
|
+
|
|
128
|
+
if len(remove_labels) > 0:
|
|
129
|
+
query_text = query_text.remove_literal(f'{property_ref}:{":".join(remove_labels)}')
|
|
130
|
+
|
|
131
|
+
query_text_param = query_text
|
|
132
|
+
param_explicit = param_properties[min(prop_counter, num_param_properties-1)][0]
|
|
133
|
+
if len(new_labels) > 0:
|
|
134
|
+
query_text_param = query_text.set_labels(ref_name=property_ref, labels=new_labels)
|
|
135
|
+
if len(param_explicit) > 0:
|
|
136
|
+
query_text_param = query_text_param.set(properties=param_explicit, property_ref=property_ref_dot)
|
|
137
|
+
param_calc = param_properties[min(prop_counter, num_param_properties-1)][1]
|
|
138
|
+
if len(param_calc) > 0:
|
|
139
|
+
query_text_param = query_text_param.set(properties=param_calc, property_ref=property_ref_dot)
|
|
140
|
+
|
|
141
|
+
query_str = query_text_param.toStr()
|
|
142
|
+
query = Neo4jQuery('node', query_str, time_now, merge_labels, new_labels, primary_property, properties, self.section)
|
|
115
143
|
if self.validate_only and not self.summarise:
|
|
116
|
-
print(
|
|
144
|
+
print(query_str)
|
|
117
145
|
queries.append(query)
|
|
118
146
|
|
|
119
147
|
this_row += 1
|
|
@@ -134,9 +162,9 @@ class NodeFileProcessor:
|
|
|
134
162
|
|
|
135
163
|
queries = []
|
|
136
164
|
|
|
137
|
-
num_rows = num_data_rows - self.start_from + 1
|
|
138
165
|
this_row = self.start_from-1
|
|
139
166
|
last_row = self.get_last_row(num_data_rows)
|
|
167
|
+
num_rows = last_row - self.start_from + 1
|
|
140
168
|
dict_size = 0
|
|
141
169
|
property_ref = 'n'
|
|
142
170
|
property_ref_dot = property_ref + '.'
|
|
@@ -168,17 +196,15 @@ class NodeFileProcessor:
|
|
|
168
196
|
temp = properties.pop(unwanted, None)
|
|
169
197
|
|
|
170
198
|
primary_property_dict = {primary_property.key: primary_property}
|
|
171
|
-
all_properties = pm.combine_properties(properties, primary_property_dict)
|
|
172
199
|
|
|
173
|
-
explicit_properties, calculated_properties = pm.split_out_functional_properties(
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
201
|
+
param_primary_props = self.query_manager.parameterise_property_dict(primary_property_dict, self.section)
|
|
202
|
+
param_explicit_props = self.query_manager.parameterise_property_dict(explicit_properties, self.section, len(param_primary_props))
|
|
203
|
+
param_calc_props = self.query_manager.parameterise_property_dict(calculated_properties, self.section, len(param_primary_props))
|
|
176
204
|
|
|
177
205
|
query_data_list = []
|
|
178
|
-
for
|
|
179
|
-
query_data_list += [[param_explicit_props[min(
|
|
180
|
-
|
|
181
|
-
# prop_data = [explicit_properties, calculated_properties, time_now]
|
|
206
|
+
for node_count in range(len(param_primary_props)):
|
|
207
|
+
query_data_list += [[pm.combine_properties(param_explicit_props[min(node_count, len(param_explicit_props)-1)], param_primary_props[node_count]), param_calc_props[min(node_count, len(param_calc_props)-1)], time_now]]
|
|
182
208
|
|
|
183
209
|
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
184
210
|
# We'll group these by unique combinations of labels and primary key type
|
|
@@ -217,8 +243,8 @@ class NodeFileProcessor:
|
|
|
217
243
|
while this_size < batch_size:
|
|
218
244
|
# Combine all the update data...
|
|
219
245
|
update = updates[(batch_num-1)*self.batch_rate + this_size]
|
|
220
|
-
update_properties = update[0] or {}
|
|
221
|
-
func_properties = update[1] or {}
|
|
246
|
+
update_properties = copy.copy(update[0]) or {}
|
|
247
|
+
func_properties = copy.copy(update[1]) or {}
|
|
222
248
|
if self.add_system_properties:
|
|
223
249
|
update_properties[self.update_time_property] = Neo4jProperty(self.update_time_property, update[2])
|
|
224
250
|
payload.append(update_properties)
|
|
@@ -234,12 +260,14 @@ class NodeFileProcessor:
|
|
|
234
260
|
|
|
235
261
|
# Build a MERGE query using queries
|
|
236
262
|
merge_labels = batch_keys[new_labels][1]
|
|
263
|
+
# merge_labels = lm.merge_node_labels(batch_keys[new_labels][1], batch_keys[new_labels][0])
|
|
237
264
|
remove_labels = batch_keys[new_labels][2]
|
|
238
265
|
primary_property = batch_keys[new_labels][3][0]
|
|
239
266
|
query_text = (QueryBuilder()
|
|
240
267
|
.unwind_list_as(formatted_payload, payload_ref)
|
|
241
268
|
.merge()
|
|
242
|
-
.node_batch(labels=
|
|
269
|
+
# .node_batch(labels=merge_labels, ref_name=property_ref, properties=primary_property+':'+payload_ref_dot+primary_property)
|
|
270
|
+
.node_batch(labels=list(set(merge_labels)), ref_name=property_ref, properties=primary_property + ':' + payload_ref_dot + primary_property)
|
|
243
271
|
.set_literal(property_ref + ' += ' + payload_ref)
|
|
244
272
|
)
|
|
245
273
|
|
|
@@ -7,6 +7,7 @@ import processors.relationshipmanager as rm
|
|
|
7
7
|
import processors.propertymanager as pm
|
|
8
8
|
import property
|
|
9
9
|
from property import Neo4jProperty
|
|
10
|
+
import copy
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class RelationshipFileProcessor:
|
|
@@ -78,9 +79,9 @@ class RelationshipFileProcessor:
|
|
|
78
79
|
to_ref = 'to'
|
|
79
80
|
relation_ref_dot = relation_ref + '.'
|
|
80
81
|
|
|
81
|
-
num_rows = num_data_rows - self.start_from + 1
|
|
82
82
|
this_row = self.start_from-1
|
|
83
83
|
last_row = self.get_last_row(num_data_rows)
|
|
84
|
+
num_rows = last_row - self.start_from + 1
|
|
84
85
|
while this_row < last_row:
|
|
85
86
|
|
|
86
87
|
combined_relationships = {**self.required_relationships, **self.contents.get_column_values_dict(this_row, relation_columns)}
|
|
@@ -93,13 +94,17 @@ class RelationshipFileProcessor:
|
|
|
93
94
|
|
|
94
95
|
# Split out those properties that are dependent on others, so that we can add them in the right order
|
|
95
96
|
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
97
|
+
param_explicit_props = self.query_manager.parameterise_property_dict(explicit_properties, self.section)
|
|
98
|
+
param_calc_props = self.query_manager.parameterise_property_dict(calculated_properties, self.section)
|
|
96
99
|
|
|
97
100
|
# If there are multiple From or To nodes, create a relationship query for each combination
|
|
98
101
|
for from_node in self.contents.get_property_values_list(this_row, from_columns, self.primary_property, self.from_property, override_format='str'):
|
|
102
|
+
param_from_nodes = self.query_manager.parameterise_property_dict({'from_node': from_node}, self.section)
|
|
99
103
|
validated_csv_from_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, from_label_columns))
|
|
100
104
|
from_labels = lm.sort_relationship_labels(self.required_labels + self.from_required_labels, validated_csv_from_labels)
|
|
101
105
|
from_node_labels = lm.merge_node_labels(from_labels, from_node.labels)
|
|
102
106
|
for to_node in self.contents.get_property_values_list(this_row, to_columns, self.primary_property, self.to_property, override_format='str'):
|
|
107
|
+
param_to_nodes = self.query_manager.parameterise_property_dict({'to_node': to_node}, self.section)
|
|
103
108
|
validated_csv_to_labels = lm.validate_labels(self.contents.get_column_values_list(this_row, to_label_columns))
|
|
104
109
|
to_labels = lm.sort_relationship_labels(self.required_labels + self.to_required_labels, validated_csv_to_labels)
|
|
105
110
|
to_node_labels = lm.merge_node_labels(to_labels, to_node.labels)
|
|
@@ -109,36 +114,41 @@ class RelationshipFileProcessor:
|
|
|
109
114
|
for relation in relationship.split(':'):
|
|
110
115
|
if relation:
|
|
111
116
|
|
|
117
|
+
param_properties = []
|
|
118
|
+
for from_count in range(len(param_from_nodes)):
|
|
119
|
+
for to_count in range(len(param_to_nodes)):
|
|
120
|
+
for explicit_count in range(len(param_explicit_props)):
|
|
121
|
+
for calc_count in range(len(param_calc_props)):
|
|
122
|
+
param_properties += [[param_from_nodes[from_count], param_to_nodes[to_count], param_explicit_props[explicit_count], param_calc_props[calc_count]]]
|
|
123
|
+
|
|
112
124
|
time_now = amu.get_formatted_time_now()
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
for a_query in query_list:
|
|
139
|
-
query = Neo4jQuery('relationship', a_query, time_now)
|
|
125
|
+
for props in param_properties:
|
|
126
|
+
query_text = (QueryBuilder()
|
|
127
|
+
.match()
|
|
128
|
+
.node(labels=from_node_labels, ref_name=from_ref, properties=props[0])
|
|
129
|
+
.match()
|
|
130
|
+
.node(labels=to_node_labels, ref_name=to_ref, properties=props[1])
|
|
131
|
+
.merge()
|
|
132
|
+
.node(ref_name=from_ref)
|
|
133
|
+
.related_to(label=relation, ref_name=relation_ref)
|
|
134
|
+
.node(ref_name=to_ref)
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
# Add in System properties
|
|
138
|
+
if self.add_system_properties:
|
|
139
|
+
create_time = relation_ref_dot + self.creation_time_property + '=datetime("' + time_now + '")'
|
|
140
|
+
update_time = relation_ref_dot + self.update_time_property + '=datetime("' + time_now + '")'
|
|
141
|
+
query_text = query_text.on_create().set_literal(create_time).set_literal(update_time)
|
|
142
|
+
|
|
143
|
+
if len(explicit_properties) > 0:
|
|
144
|
+
query_text = query_text.set(properties=props[2], property_ref=relation_ref_dot)
|
|
145
|
+
if len(calculated_properties) > 0:
|
|
146
|
+
query_text = query_text.set(properties=props[3], property_ref=relation_ref_dot)
|
|
147
|
+
|
|
148
|
+
query_text = query_text.toStr()
|
|
149
|
+
query = Neo4jQuery('relationship', query_text, time_now)
|
|
140
150
|
if self.validate_only and not self.summarise:
|
|
141
|
-
print(
|
|
151
|
+
print(query_text)
|
|
142
152
|
queries.append(query)
|
|
143
153
|
|
|
144
154
|
this_row += 1
|
|
@@ -176,14 +186,13 @@ class RelationshipFileProcessor:
|
|
|
176
186
|
# Since the dictionary key can't be a list, we will create a list (of lists) and use the index in that list as the key
|
|
177
187
|
# When we have worked through all the input and grouped the queries by label and relationship combinations, we will create the queries
|
|
178
188
|
|
|
179
|
-
new_labels_list = []
|
|
180
189
|
batch_keys = []
|
|
181
190
|
query_dictionary = {}
|
|
182
191
|
dict_size = 0
|
|
183
192
|
|
|
184
|
-
num_rows = num_data_rows - self.start_from + 1
|
|
185
193
|
this_row = self.start_from-1
|
|
186
194
|
last_row = self.get_last_row(num_data_rows)
|
|
195
|
+
num_rows = last_row - self.start_from + 1
|
|
187
196
|
while this_row < last_row:
|
|
188
197
|
|
|
189
198
|
combined_relationships = {**self.required_relationships, **self.contents.get_column_values_dict(this_row, relation_columns)}
|
|
@@ -211,15 +220,19 @@ class RelationshipFileProcessor:
|
|
|
211
220
|
|
|
212
221
|
explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
|
|
213
222
|
|
|
214
|
-
param_from_nodes = self.query_manager.
|
|
215
|
-
param_to_nodes = self.query_manager.
|
|
216
|
-
param_explicit_props = self.query_manager.
|
|
217
|
-
param_calc_props = self.query_manager.
|
|
223
|
+
param_from_nodes = self.query_manager.parameterise_property_dict({'from_node': from_node}, self.section)
|
|
224
|
+
param_to_nodes = self.query_manager.parameterise_property_dict({'to_node': to_node}, self.section)
|
|
225
|
+
param_explicit_props = self.query_manager.parameterise_property_dict(explicit_properties, self.section)
|
|
226
|
+
param_calc_props = self.query_manager.parameterise_property_dict(calculated_properties, self.section)
|
|
218
227
|
|
|
228
|
+
new_labels_list = []
|
|
219
229
|
query_data_list = []
|
|
220
|
-
for
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
for from_count in range(len(param_from_nodes)):
|
|
231
|
+
for to_count in range(len(param_to_nodes)):
|
|
232
|
+
for explicit_count in range(len(param_explicit_props)):
|
|
233
|
+
for calc_count in range(len(param_calc_props)):
|
|
234
|
+
new_labels_list += [[from_node_labels, to_node_labels, relation, from_node.key, to_node.key, param_calc_props[calc_count]]]
|
|
235
|
+
query_data_list += [[param_from_nodes[from_count]['from_node'].value.replace('\\\\n', '\n'), param_to_nodes[to_count]['to_node'].value.replace('\\\\n', '\n'), param_explicit_props[explicit_count], param_calc_props[calc_count], time_now]]
|
|
223
236
|
|
|
224
237
|
# So now we know all about this particular update. Let's put it in the query dictionary
|
|
225
238
|
q_count = 0
|
|
@@ -227,12 +240,12 @@ class RelationshipFileProcessor:
|
|
|
227
240
|
q_count += 1
|
|
228
241
|
try:
|
|
229
242
|
dictionary_index = batch_keys.index(new_labels_list[count])
|
|
230
|
-
query_dictionary[dictionary_index] += query_data_list
|
|
243
|
+
query_dictionary[dictionary_index] += [query_data_list[count]]
|
|
231
244
|
except:
|
|
232
245
|
dictionary_index = len(batch_keys)
|
|
233
|
-
query_dictionary[dictionary_index] = query_data_list
|
|
246
|
+
query_dictionary[dictionary_index] = [query_data_list[count]]
|
|
234
247
|
batch_keys.append(new_labels_list[count])
|
|
235
|
-
dict_size += len(query_data_list)
|
|
248
|
+
dict_size += len([query_data_list[count]])
|
|
236
249
|
|
|
237
250
|
this_row += 1
|
|
238
251
|
messages.message_no_cr(f'Analysing file... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
|
|
@@ -262,19 +275,19 @@ class RelationshipFileProcessor:
|
|
|
262
275
|
while this_size < batch_size:
|
|
263
276
|
# Combine all the update data...
|
|
264
277
|
update = updates[(batch_num - 1) * self.batch_rate + this_size]
|
|
265
|
-
update_properties = update[2] or {} # In case update_properties[2] is {}
|
|
266
|
-
func_properties = update[3] or {} # In case update_properties[3] is {}
|
|
278
|
+
update_properties = copy.copy(update[2]) or {} # In case update_properties[2] is {}
|
|
279
|
+
func_properties = copy.copy(update[3]) or {} # In case update_properties[3] is {}
|
|
267
280
|
update_properties[from_ref] = Neo4jProperty(from_ref, update[0], 'str')
|
|
268
281
|
update_properties[to_ref] = Neo4jProperty(to_ref, update[1], 'str')
|
|
269
282
|
if self.add_system_properties:
|
|
270
283
|
update_properties[self.update_time_property] = Neo4jProperty(self.update_time_property, update[4])
|
|
271
|
-
payload.append(update_properties)
|
|
284
|
+
payload.append([update_properties])
|
|
272
285
|
this_size += 1
|
|
273
286
|
query_count += 1
|
|
274
287
|
|
|
275
288
|
formatted_payload = []
|
|
276
289
|
for a_payload in payload:
|
|
277
|
-
formatted_pload = property.format(a_payload, '', self.query_manager, self.section)
|
|
290
|
+
formatted_pload = property.format(a_payload[0], '', self.query_manager, self.section)
|
|
278
291
|
formatted_payload += formatted_pload
|
|
279
292
|
|
|
280
293
|
# Build a MERGE query using queries
|
modelbuilder/src/property.py
CHANGED
|
@@ -4,13 +4,10 @@ import datetime
|
|
|
4
4
|
import messages
|
|
5
5
|
import processors.labelmanager as lm
|
|
6
6
|
import processors.propertymanager as pm
|
|
7
|
-
from querymanager import QueryManager
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
class Neo4jProperty:
|
|
11
|
-
def __init__(
|
|
12
|
-
self, key, value=None, format=None, type=None, blank_override=False, labels=[]
|
|
13
|
-
):
|
|
10
|
+
def __init__(self, key, value=None, format=None, type=None, blank_override=False, labels=[]):
|
|
14
11
|
|
|
15
12
|
self.key = pm.validate_property(key)
|
|
16
13
|
# Sanitise the value
|
|
@@ -36,13 +33,11 @@ class Neo4jProperty:
|
|
|
36
33
|
|
|
37
34
|
# Now check to see if the value might be a formula
|
|
38
35
|
if "{" in self.value or "}" in self.value:
|
|
39
|
-
self.formula, self.is_formula, self.
|
|
40
|
-
value, "n."
|
|
41
|
-
)
|
|
36
|
+
self.formula, self.is_formula, self.parameter_names = parse_value(value, "n.")
|
|
42
37
|
else:
|
|
43
38
|
self.formula = None
|
|
44
39
|
self.is_formula = False
|
|
45
|
-
self.
|
|
40
|
+
self.parameter_names = []
|
|
46
41
|
|
|
47
42
|
def set_format(self, new_format):
|
|
48
43
|
# If the format has changed, update it (otherwise, no need to do anything)
|
|
@@ -58,13 +53,11 @@ class Neo4jProperty:
|
|
|
58
53
|
# And say the value hasn't been formatted using the new format
|
|
59
54
|
self.formatted_values = {}
|
|
60
55
|
if "{" in self.value or "}" in self.value:
|
|
61
|
-
self.formula, self.is_formula, self.
|
|
62
|
-
new_value, "n."
|
|
63
|
-
)
|
|
56
|
+
self.formula, self.is_formula, self.parameter_names = parse_value(new_value, "n.")
|
|
64
57
|
else:
|
|
65
58
|
self.formula = None
|
|
66
59
|
self.is_formula = False
|
|
67
|
-
self.
|
|
60
|
+
self.parameter_names = []
|
|
68
61
|
|
|
69
62
|
def get_value(self, ref):
|
|
70
63
|
# Check to see if we have a formatted value, and if not do it now
|
|
@@ -127,7 +120,7 @@ def format_value(self, ref):
|
|
|
127
120
|
|
|
128
121
|
# Handle formulas
|
|
129
122
|
if self.is_formula and ref != "n.":
|
|
130
|
-
self.formula, self.is_formula, self.
|
|
123
|
+
self.formula, self.is_formula, self.parameter_names = parse_value(value, ref)
|
|
131
124
|
formula = self.formula
|
|
132
125
|
|
|
133
126
|
if self.is_formula and formula != "":
|
|
@@ -242,13 +235,11 @@ def parse_value(formula, ref):
|
|
|
242
235
|
parsed = ""
|
|
243
236
|
index = 0
|
|
244
237
|
open = False
|
|
245
|
-
|
|
238
|
+
param_name = []
|
|
246
239
|
property_name = ""
|
|
247
240
|
while index < len(formula):
|
|
248
241
|
this_char = formula[index]
|
|
249
|
-
next_char = (formula + " ")[
|
|
250
|
-
index + 1
|
|
251
|
-
] # Added a space to formula, so we don't run off the end
|
|
242
|
+
next_char = (formula + " ")[index + 1] # Added a space to formula, so we don't run off the end
|
|
252
243
|
if this_char == "{":
|
|
253
244
|
if next_char == "{":
|
|
254
245
|
if open:
|
|
@@ -261,10 +252,10 @@ def parse_value(formula, ref):
|
|
|
261
252
|
property_name = ""
|
|
262
253
|
num_open += 1
|
|
263
254
|
elif this_char == "$" and next_char == "{":
|
|
264
|
-
end_parm = formula[index + 1
|
|
255
|
+
end_parm = formula[index + 1:].find("}")
|
|
265
256
|
if end_parm >= 0:
|
|
266
|
-
parsed += formula[index
|
|
267
|
-
|
|
257
|
+
parsed += formula[index: index + end_parm + 2]
|
|
258
|
+
param_name += [formula[index + 2: index + end_parm + 1]]
|
|
268
259
|
index += end_parm + 1
|
|
269
260
|
else:
|
|
270
261
|
parsed += this_char
|
|
@@ -294,14 +285,12 @@ def parse_value(formula, ref):
|
|
|
294
285
|
|
|
295
286
|
is_formula = (num_open == num_close) and (num_open > 0)
|
|
296
287
|
|
|
297
|
-
return parsed.strip(), is_formula,
|
|
288
|
+
return parsed.strip(), is_formula, param_name
|
|
298
289
|
|
|
299
290
|
|
|
300
291
|
def try_date_format(date, date_format):
|
|
301
292
|
try:
|
|
302
|
-
tested_date = datetime.datetime.strptime(
|
|
303
|
-
date.replace("/", "-"), date_format
|
|
304
|
-
).date()
|
|
293
|
+
tested_date = datetime.datetime.strptime(date.replace("/", "-"), date_format).date()
|
|
305
294
|
except:
|
|
306
295
|
tested_date = None
|
|
307
296
|
return tested_date
|
|
@@ -352,10 +341,7 @@ def format_property_list(
|
|
|
352
341
|
prop_list = {properties.key: properties}
|
|
353
342
|
else:
|
|
354
343
|
prop_list = properties
|
|
355
|
-
pairs = [
|
|
356
|
-
f"{key_ref}{prop_list[property].key}{comparison_operator}{prop_list[property].get_value(property_ref)}"
|
|
357
|
-
for property in prop_list.keys()
|
|
358
|
-
]
|
|
344
|
+
pairs = [f"{key_ref}{prop_list[property].key}{comparison_operator}{prop_list[property].get_value(property_ref)}" for property in prop_list.keys()]
|
|
359
345
|
res = boolean_operator.join(pairs)
|
|
360
346
|
return res
|
|
361
347
|
|
|
@@ -366,19 +352,9 @@ def format(properties, property_ref="", query_manager=None, section="DEFAULT"):
|
|
|
366
352
|
for p in properties.keys():
|
|
367
353
|
pairs.append(f"{properties[p].key}:{properties[p].get_value(property_ref)}")
|
|
368
354
|
pair_data = "{" + ",".join(pairs) + "}"
|
|
369
|
-
return
|
|
355
|
+
return [pair_data]
|
|
370
356
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
properties,
|
|
374
|
-
comparison_operator: str = ":",
|
|
375
|
-
boolean_operator: str = ",",
|
|
376
|
-
property_ref="",
|
|
377
|
-
key_ref="",
|
|
378
|
-
) -> str:
|
|
379
|
-
pairs = [
|
|
380
|
-
f"{key_ref}{key.split(':')[0]}{comparison_operator}{Neo4jProperty(key, str(value)).get_value(property_ref)}"
|
|
381
|
-
for key, value in properties.items()
|
|
382
|
-
]
|
|
357
|
+
def to_str(properties, comparison_operator: str = ":", boolean_operator: str = ",", property_ref="", key_ref="", ) -> str:
|
|
358
|
+
pairs = [f"{key_ref}{key.split(':')[0]}{comparison_operator}{Neo4jProperty(key, str(value)).get_value(property_ref)}" for key, value in properties.items()]
|
|
383
359
|
res = boolean_operator.join(pairs)
|
|
384
360
|
return res
|
modelbuilder/src/querymanager.py
CHANGED
|
@@ -1,98 +1,64 @@
|
|
|
1
1
|
import copy
|
|
2
|
+
import messages
|
|
2
3
|
|
|
3
4
|
class QueryManager():
|
|
4
5
|
|
|
5
6
|
def __init__(self, parameters):
|
|
6
7
|
self.parameters = parameters
|
|
7
8
|
|
|
8
|
-
def
|
|
9
|
-
if self.parameters:
|
|
10
|
-
query_list = []
|
|
11
|
-
|
|
12
|
-
for parm, values in self.parameters[section].items():
|
|
13
|
-
parm_name = '${'+str(parm)+'}'
|
|
14
|
-
if parm_name in query_text:
|
|
15
|
-
for v in values:
|
|
16
|
-
new_query = query_text.replace(parm_name, v)
|
|
17
|
-
query_list.append(new_query)
|
|
18
|
-
|
|
19
|
-
if query_list == []:
|
|
20
|
-
query_list = [query_text]
|
|
21
|
-
|
|
22
|
-
else:
|
|
23
|
-
query_list = [query_text]
|
|
9
|
+
def parameterise_property_dict(self, properties, section, num_nodes=0):
|
|
24
10
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def parameterise_dict(self, data, section):
|
|
11
|
+
paramed_data = [properties]
|
|
28
12
|
if self.parameters:
|
|
29
13
|
|
|
30
14
|
params = self.parameters[section]
|
|
31
15
|
params_found = []
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
param_names = {}
|
|
17
|
+
param_count = []
|
|
18
|
+
max_params = 0
|
|
19
|
+
|
|
20
|
+
for property in properties:
|
|
21
|
+
for param_name in properties[property].parameter_names:
|
|
22
|
+
if param_name not in params_found:
|
|
23
|
+
params_found += [param_name]
|
|
24
|
+
num_values = len(params[param_name])
|
|
25
|
+
param_count += [num_values]
|
|
26
|
+
if num_nodes > 0 and num_values != 1:
|
|
27
|
+
if num_values != num_nodes:
|
|
28
|
+
messages.warning_message(f'{num_values} values found for ${{{param_name}}}, should have {num_nodes}')
|
|
29
|
+
max_params = max(max_params, len(params[param_name]))
|
|
30
|
+
if param_name in param_names:
|
|
31
|
+
param_names[param_name] += [property]
|
|
32
|
+
else:
|
|
33
|
+
param_names[param_name] = [property]
|
|
34
|
+
|
|
35
|
+
param_count_check = list(set(param_count + [1]))
|
|
36
|
+
if len(param_count_check) > 2:
|
|
37
|
+
messages.warning_message('Inconsistent parameter counts found')
|
|
43
38
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
new_prop = copy.deepcopy(data[k])
|
|
51
|
-
new_prop.set_value(new_value)
|
|
52
|
-
this_one[k] = new_prop
|
|
53
|
-
else:
|
|
54
|
-
this_one[k] = copy.deepcopy(data[k])
|
|
55
|
-
new_data += [this_one]
|
|
56
|
-
else:
|
|
57
|
-
new_data = [data]
|
|
58
|
-
else:
|
|
59
|
-
new_data = [data]
|
|
60
|
-
|
|
61
|
-
return new_data
|
|
39
|
+
if params_found:
|
|
40
|
+
next_list = []
|
|
41
|
+
for param_num in range(max_params):
|
|
42
|
+
this_list = [copy.deepcopy(properties)]
|
|
43
|
+
for param in param_names:
|
|
44
|
+
param_id = '${' + param + '}'
|
|
62
45
|
|
|
46
|
+
# If parameters aren't configured correctly, this can error so use nothing instead
|
|
47
|
+
try:
|
|
48
|
+
new_val = params[param][min(param_num, len(params[param])-1)]
|
|
49
|
+
except:
|
|
50
|
+
new_val = ""
|
|
63
51
|
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
for prop_list in this_list:
|
|
53
|
+
updated_data = prop_list
|
|
66
54
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
for prop in updated_data:
|
|
56
|
+
new_value = updated_data[prop].value.replace(param_id, new_val)
|
|
57
|
+
updated_data[prop].set_value(new_value)
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
if prop.parameter_number != -1:
|
|
73
|
-
params_found.append(prop.key)
|
|
74
|
-
param_num = prop.parameter_number
|
|
59
|
+
next_list += [updated_data]
|
|
75
60
|
|
|
76
|
-
|
|
77
|
-
params_to_use = params[param_num]
|
|
78
|
-
num_params = len(params_to_use)
|
|
79
|
-
param_id = '{$' + param_num + '}'
|
|
61
|
+
paramed_data = next_list
|
|
80
62
|
|
|
81
|
-
|
|
82
|
-
for count in range(num_params):
|
|
83
|
-
this_one = []
|
|
84
|
-
for prop in prop_data:
|
|
85
|
-
if prop.key in params_found:
|
|
86
|
-
new_value = prop.value.replace(param_id, params_to_use[count])
|
|
87
|
-
new_prop = copy.deepcopy(prop)
|
|
88
|
-
new_prop.set_value(new_value)
|
|
89
|
-
this_one.append(new_prop)
|
|
90
|
-
else:
|
|
91
|
-
this_one.append(copy.deepcopy(prop))
|
|
92
|
-
new_data.append(this_one[0])
|
|
93
|
-
else:
|
|
94
|
-
new_data = prop_data
|
|
95
|
-
else:
|
|
96
|
-
new_data = prop_data
|
|
63
|
+
return paramed_data
|
|
97
64
|
|
|
98
|
-
return new_data
|
|
@@ -40,14 +40,14 @@ modelbuilder/src/__init__.py,sha256=bMvb-E_plw2dz9_TYIPevQuvDNmKtW0dmBgnQE9ylwc,
|
|
|
40
40
|
modelbuilder/src/assetmodelbuilder.py,sha256=92Yu9CvmObPYDdqCpn8eBCaZ_KGBhm307YsFt6cg2Eg,8886
|
|
41
41
|
modelbuilder/src/assetmodelcsvwriter.py,sha256=GKNi_fw7AlY-UG2XhwFIS34Ff3XiVRss-o5MUzyJSV0,1071
|
|
42
42
|
modelbuilder/src/assetmodelutilities.py,sha256=1j-S2CKaxcde-Pj6AfgYMGOKu13kwA-sIJSIyLqMW94,6700
|
|
43
|
-
modelbuilder/src/configmanager.py,sha256=
|
|
43
|
+
modelbuilder/src/configmanager.py,sha256=RlfiKAlRtQnl50SrKQqBmybdRw8N3FzFZ0abxiE-fsQ,32046
|
|
44
44
|
modelbuilder/src/csvcontentsmanager.py,sha256=601JuaT5rxlTlj58uK50c6vSUk4NKh4pGOrVq9ECX8o,8247
|
|
45
45
|
modelbuilder/src/csvwriter.py,sha256=2Xc6kdV6cYwCjrVF6WaZfS6tVp8-oc0ksIHSOx6iqj8,14132
|
|
46
46
|
modelbuilder/src/fileanalyser.py,sha256=hNwEZLlIRRLroJCxiWXwJTQHIsHbZDWbBK4BCFIMcLw,7633
|
|
47
|
-
modelbuilder/src/filemanager.py,sha256=
|
|
47
|
+
modelbuilder/src/filemanager.py,sha256=UulYx4FDGsIVRG8oQqKCMIWBi9qlr5UVe0iIJpOL4A4,27055
|
|
48
48
|
modelbuilder/src/messages.py,sha256=6JnW-ke6nHGUA4hTEBvo_kVlNJTXoV4LWw8mNwMpBCQ,1325
|
|
49
|
-
modelbuilder/src/property.py,sha256=
|
|
50
|
-
modelbuilder/src/querymanager.py,sha256=
|
|
49
|
+
modelbuilder/src/property.py,sha256=q9iAi_zWYaZh9SfPpiOOnLMbCxp6FE4Q0E9xeYaR6ko,11897
|
|
50
|
+
modelbuilder/src/querymanager.py,sha256=U9SB9VMvm9IFPe9PO77IgkFVkcghmHVHuCcxRkDQ4Ns,2500
|
|
51
51
|
modelbuilder/src/versionmanager.py,sha256=B8mrYY5Der0sWi1GQjduyVGZ6BuAb6rTNVAZzQlP4k4,19148
|
|
52
52
|
modelbuilder/src/connectors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
modelbuilder/src/connectors/boltconnector.py,sha256=9mFpYUqYzf--o_8gLw00BjPOmOqo1X1KsdxjFkzYRaQ,4885
|
|
@@ -56,10 +56,10 @@ modelbuilder/src/connectors/genericconnector.py,sha256=bMfnbrOWq97BC9oM7RIA58bNd
|
|
|
56
56
|
modelbuilder/src/connectors/httpsconnector.py,sha256=DOZyxRW3JQcaiaYtnx0_Jq2dBEhgSUIubnx5jj7OY_g,6078
|
|
57
57
|
modelbuilder/src/processors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
modelbuilder/src/processors/cypherfileprocessor.py,sha256=EmaLsBhC6gWQwvhyY7Ks2HEbGEzDoGAZfu2nBkh2hOs,2941
|
|
59
|
-
modelbuilder/src/processors/labelmanager.py,sha256=
|
|
60
|
-
modelbuilder/src/processors/nodefileprocessor.py,sha256=
|
|
59
|
+
modelbuilder/src/processors/labelmanager.py,sha256=bDWZB7DDARtffgFsh1cgo8w738cA8ZW8b9GKCazB2dk,6844
|
|
60
|
+
modelbuilder/src/processors/nodefileprocessor.py,sha256=yF11gQcMn_5z9i4msRWSaPKNiF4mhycQktaKMwnRPdY,17388
|
|
61
61
|
modelbuilder/src/processors/propertymanager.py,sha256=zLr8S0HPZMXeUp1RUzVXWyNa64MxLufXrOqh5uL1mwU,6978
|
|
62
|
-
modelbuilder/src/processors/relationshipfileprocessor.py,sha256
|
|
62
|
+
modelbuilder/src/processors/relationshipfileprocessor.py,sha256=-d5utaJPVOBHwrYf4KNQoawD9y6k7yZUwyVgdGRebfQ,20796
|
|
63
63
|
modelbuilder/src/processors/relationshipmanager.py,sha256=lDtE_5AdKzL3boq7VD8Gmpai8Uscq79vRxkzYQL8A9A,1105
|
|
64
64
|
modelbuilder/src/queries/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
65
|
modelbuilder/src/queries/cypherbuilder.py,sha256=VpUGuPo-Ba3skjCVBFjmxm4ORQBGgF5cDiQYnK67hLA,10418
|
|
@@ -88,7 +88,7 @@ regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py,sha256=f
|
|
|
88
88
|
regressiontests/eigeningenuity/historian-multi/test_listDataTags.py,sha256=TcceNSjCKoiK5SJcgTH2JXfKLYxIHdQdwZWlkpGnEVM,2006
|
|
89
89
|
regressiontests/eigeningenuity/historian-multi/test_tagManagement.py,sha256=ylInBt453d1RaSih1eTTxGPZmb60UK4vMwI3UW-U1JY,4830
|
|
90
90
|
regressiontests/eigeningenuity/historian-multi/test_writePoints.py,sha256=51tfUSLUqLKcCKJ1EyhjfzoC_4OP6n1oL3zgTSkXu4s,2696
|
|
91
|
-
python_eigen_ingenuity_nocli-0.5.
|
|
92
|
-
python_eigen_ingenuity_nocli-0.5.
|
|
93
|
-
python_eigen_ingenuity_nocli-0.5.
|
|
94
|
-
python_eigen_ingenuity_nocli-0.5.
|
|
91
|
+
python_eigen_ingenuity_nocli-0.5.33.dist-info/METADATA,sha256=LK0IDrVEWmqZ3qVFmjQNmuLautuxc7gRq0cFRBlmQTk,1434
|
|
92
|
+
python_eigen_ingenuity_nocli-0.5.33.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
93
|
+
python_eigen_ingenuity_nocli-0.5.33.dist-info/top_level.txt,sha256=oDWOSmlNPKNBlIEKP8_JaV01O60jTcUIt2tDkq3OD18,56
|
|
94
|
+
python_eigen_ingenuity_nocli-0.5.33.dist-info/RECORD,,
|
|
File without changes
|