python-eigen-ingenuity-nocli 0.5.27b1__tar.gz → 0.5.29b1__tar.gz

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.
Files changed (104) hide show
  1. {python_eigen_ingenuity_nocli-0.5.27b1/python_eigen_ingenuity_nocli.egg-info → python_eigen_ingenuity_nocli-0.5.29b1}/PKG-INFO +1 -1
  2. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/assetmodelbuilder.py +5 -1
  3. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/configmanager.py +33 -1
  4. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/csvcontentsmanager.py +0 -1
  5. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/filemanager.py +75 -25
  6. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/cypherfileprocessor.py +1 -1
  7. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/nodefileprocessor.py +22 -16
  8. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/relationshipfileprocessor.py +33 -17
  9. python_eigen_ingenuity_nocli-0.5.29b1/modelbuilder/src/property.py +343 -0
  10. python_eigen_ingenuity_nocli-0.5.29b1/modelbuilder/src/querymanager.py +98 -0
  11. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1/python_eigen_ingenuity_nocli.egg-info}/PKG-INFO +1 -1
  12. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/python_eigen_ingenuity_nocli.egg-info/SOURCES.txt +1 -0
  13. python_eigen_ingenuity_nocli-0.5.27b1/modelbuilder/src/property.py +0 -306
  14. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/MANIFEST.in +0 -0
  15. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/README-nocli.md +0 -0
  16. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/README.md +0 -0
  17. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/__init__.py +0 -0
  18. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/assetmodel.py +0 -0
  19. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/auth.py +0 -0
  20. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/commonmenu.py +0 -0
  21. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/core/__init__.py +0 -0
  22. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/elastic.py +0 -0
  23. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/events.py +0 -0
  24. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/historian.py +0 -0
  25. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/historianmulti.py +0 -0
  26. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/logformatter.py +0 -0
  27. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/settings.py +0 -0
  28. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/sql.py +0 -0
  29. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/eigeningenuity/util.py +0 -0
  30. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/__init__.py +0 -0
  31. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/common.py +0 -0
  32. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/config.py +0 -0
  33. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/demo.py +0 -0
  34. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/__init__.py +0 -0
  35. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_getCurrentDataPoints.py +0 -0
  36. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_getInterpolatedPoints.py +0 -0
  37. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_getInterpolatedRange.py +0 -0
  38. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_getMetaData.py +0 -0
  39. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_getRawDataPoints.py +0 -0
  40. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_listDataTags.py +0 -0
  41. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historian/test_writePoints.py +0 -0
  42. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/__init__.py +0 -0
  43. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/common_multi.py +0 -0
  44. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getClosestRawPoint.py +0 -0
  45. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getCurrentDataPoints.py +0 -0
  46. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getInterpolatedPoints.py +0 -0
  47. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getInterpolatedRange.py +0 -0
  48. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getMetaData.py +0 -0
  49. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_getRawDatapoints.py +0 -0
  50. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_listDataTags.py +0 -0
  51. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_tagManagement.py +0 -0
  52. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/historianmulti/test_writePoints.py +0 -0
  53. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/local-tests/run_tests.py +0 -0
  54. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/__init__.py +0 -0
  55. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/__init__.py +0 -0
  56. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/assetmodelcsvwriter.py +0 -0
  57. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/assetmodelutilities.py +0 -0
  58. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/connectors/__init__.py +0 -0
  59. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/connectors/boltconnector.py +0 -0
  60. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/connectors/dbconnectors.py +0 -0
  61. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/connectors/genericconnector.py +0 -0
  62. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/connectors/httpsconnector.py +0 -0
  63. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/csvwriter.py +0 -0
  64. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/fileanalyser.py +0 -0
  65. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/messages.py +0 -0
  66. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/__init__.py +0 -0
  67. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/labelmanager.py +0 -0
  68. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/propertymanager.py +0 -0
  69. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/processors/relationshipmanager.py +0 -0
  70. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/queries/__init__.py +0 -0
  71. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/queries/cypherbuilder.py +0 -0
  72. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/queries/query.py +0 -0
  73. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/modelbuilder/src/versionmanager.py +0 -0
  74. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/pyproject.toml +0 -0
  75. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/python_eigen_ingenuity_nocli.egg-info/dependency_links.txt +0 -0
  76. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/python_eigen_ingenuity_nocli.egg-info/requires.txt +0 -0
  77. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/python_eigen_ingenuity_nocli.egg-info/top_level.txt +0 -0
  78. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/__init__.py +0 -0
  79. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/__init__.py +0 -0
  80. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/common.py +0 -0
  81. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/common_multi.py +0 -0
  82. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/__init__.py +0 -0
  83. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/common.py +0 -0
  84. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_getCurrentDataPoints.py +0 -0
  85. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_getInterpolatedPoints.py +0 -0
  86. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_getInterpolatedRange.py +0 -0
  87. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_getMetaData.py +0 -0
  88. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_getRawDataPoints.py +0 -0
  89. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_listDataTags.py +0 -0
  90. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian/test_writePoints.py +0 -0
  91. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/__init__.py +0 -0
  92. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/common_multi.py +0 -0
  93. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getClosestRawPoint.py +0 -0
  94. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getCurrentDataPoints.py +0 -0
  95. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedPoints.py +0 -0
  96. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getInterpolatedRange.py +0 -0
  97. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getMetaData.py +0 -0
  98. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_getRawDatapoints.py +0 -0
  99. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_listDataTags.py +0 -0
  100. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_tagManagement.py +0 -0
  101. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/regressiontests/eigeningenuity/historian-multi/test_writePoints.py +0 -0
  102. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/requirements.txt +0 -0
  103. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/setup.cfg +0 -0
  104. {python_eigen_ingenuity_nocli-0.5.27b1 → python_eigen_ingenuity_nocli-0.5.29b1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-eigen-ingenuity-nocli
3
- Version: 0.5.27b1
3
+ Version: 0.5.29b1
4
4
  Summary: A python library used to query data from the Eigen Ingenuity system
5
5
  Home-page: https://www.eigen.co/
6
6
  Author: Murray Callander
@@ -7,6 +7,7 @@ sys.path.append(current_dir)
7
7
  from configmanager import ConfigManager
8
8
  from connectors.dbconnectors import ConnectionManager
9
9
  from filemanager import FileManager
10
+ from querymanager import QueryManager
10
11
 
11
12
  import sys
12
13
  import inspect
@@ -146,8 +147,11 @@ def _asset_model_builder_():
146
147
  if config_manager.get_error_count() > 0:
147
148
  sys.exit()
148
149
 
150
+ # Create a Query Manager
151
+ query_manager = QueryManager(config_manager.get_parameters())
152
+
149
153
  # Create a csv file Manager to process all the input files
150
- file_manager = FileManager(config_manager)
154
+ file_manager = FileManager(config_manager, query_manager)
151
155
  file_manager.analyse_files()
152
156
 
153
157
  # Create a connection to the database
@@ -24,6 +24,8 @@ class ConfigManager:
24
24
  parser.add_argument('-cs', '--configsection', default='', help='Section of the config file to use, if not DEFAULT')
25
25
  parser.add_argument('-d', '--database', default='0', help='Database ID (as set in config file). Defaults to first entry')
26
26
  parser.add_argument('-f', '--file', nargs='+', default='', help='List of input files (space separated, quoted with " where necessary)')
27
+ parser.add_argument('-dir', '--directory', nargs='+', default='', help='List of input directories (space separated, quoted with " where necessary)')
28
+ parser.add_argument('-rec', '--recurse_directories', default=False, help='Recurse into subdirectories when processing input directories, or dir references in lst files. Default is False', action='store_true')
27
29
  parser.add_argument('-q', '--query', nargs='+', default='', help='List of queries to run (space separated, quoted with " where necessary)')
28
30
  parser.add_argument('-pre', '--preprocess', nargs='+', default='', help='Command(s) to execute before processing input files')
29
31
  parser.add_argument('-post', '--postprocess', nargs='+', default='', help='Command(s) to execute after processing input files')
@@ -79,6 +81,8 @@ class ConfigManager:
79
81
  self.config_file = args.config
80
82
  self.config_section = args.configsection
81
83
  self.input_file_list = args.file
84
+ self.input_dir_list = args.directory
85
+ self.recurse_dirs = args.recurse_directories
82
86
  self.inline_query_list = args.query
83
87
  self.preprocess_query_list = args.preprocess
84
88
  self.postprocess_query_list = args.postprocess
@@ -211,7 +215,7 @@ class ConfigManager:
211
215
  except:
212
216
  database_num = None
213
217
 
214
- if not (database_num is None):
218
+ if database_num is not None:
215
219
  # Database number provided, so check if it's valid
216
220
  if database_num < len(database_name_list):
217
221
  database_index = database_num
@@ -312,6 +316,25 @@ class ConfigManager:
312
316
  except:
313
317
  self.alias_header_mappings_dict[s] = {}
314
318
 
319
+ # Read lists of parameters
320
+ params = {s: self.get_config_value_list(s, "Parameters", "") for s in self.available_sections}
321
+ self.parameters = {}
322
+ this_parm = ''
323
+ parm_list = []
324
+ for s in self.available_sections:
325
+ self.parameters[s] = {}
326
+ for parm in params[s]:
327
+ parm = parm.strip()
328
+ if parm[0] == '$':
329
+ if this_parm != '':
330
+ self.parameters[s][this_parm] = parm_list
331
+ this_parm = parm.split(':')[0][1:]
332
+ parm_list = [parm.split(':')[1]]
333
+ else:
334
+ parm_list.append(parm)
335
+ if this_parm != '':
336
+ self.parameters[s][this_parm] = parm_list
337
+
315
338
  def get_error_list(self):
316
339
  return self.error_list
317
340
 
@@ -384,6 +407,12 @@ class ConfigManager:
384
407
 
385
408
  def get_input_file_list(self):
386
409
  return self.input_file_list
410
+
411
+ def get_input_dir_list(self):
412
+ return self.input_dir_list
413
+
414
+ def get_recurse_dirs(self):
415
+ return self.recurse_dirs
387
416
 
388
417
  def get_inline_query_list(self):
389
418
  return self.inline_query_list
@@ -593,3 +622,6 @@ class ConfigManager:
593
622
  for error in self.error_list:
594
623
  error_message(error)
595
624
  return len(self.error_list)
625
+
626
+ def get_parameters(self):
627
+ return self.parameters
@@ -1,5 +1,4 @@
1
1
  import assetmodelutilities as amu
2
- import processors.propertymanager as pm
3
2
  from property import Neo4jProperty
4
3
 
5
4
  class CSVContentsManager:
@@ -11,8 +11,9 @@ import os
11
11
 
12
12
  class FileManager:
13
13
 
14
- def __init__(self, config_manager):
14
+ def __init__(self, config_manager, query_manager):
15
15
  self.config_manager = config_manager
16
+ self.query_manager = query_manager
16
17
  self.validation_mode = config_manager.in_validation_mode()
17
18
  self.report_queries = config_manager.get_show_query()
18
19
  self.show_progress = config_manager.get_display_rate()
@@ -47,6 +48,8 @@ class FileManager:
47
48
  self.file_analysers = {s: FileAnalyser(config_manager, s) for s in config_manager.get_available_sections()}
48
49
  self.version_managers = {s: VersionManager(config_manager, s) for s in config_manager.get_available_sections()}
49
50
 
51
+ self.batch_debug = False
52
+
50
53
  def check_section(self, in_file, empty_section_response):
51
54
  file = in_file.split('#')[0].strip()
52
55
  if file.startswith('#') or file == '':
@@ -105,7 +108,7 @@ class FileManager:
105
108
  info_message(file_processor.get_filename(), ' not processed as requested')
106
109
 
107
110
  def analyse_lst_file(self, filename, def_section=''):
108
-
111
+ recurse_dirs = self.config_manager.get_recurse_dirs()
109
112
  f_name = amu.find_file(self.config_manager.get_default_path(), filename)
110
113
  current_section = self.section
111
114
  self.section = def_section
@@ -113,9 +116,29 @@ class FileManager:
113
116
  lst_file = open(f_name, 'r')
114
117
  for a_file in lst_file:
115
118
  if not a_file.startswith('#') and a_file != '\n':
116
- file, section = self.check_section(a_file, self.config_section)
117
- if file != '':
118
- self.analyse_a_file(file, section)
119
+ if os.path.isdir(a_file.strip()):
120
+ # Directory specified - add all .csv files in the directory, recursively
121
+ dir_name = a_file.strip()
122
+ if recurse_dirs:
123
+ for root, dirs, files in os.walk(dir_name):
124
+ for dir in dirs:
125
+ dir, section = self.check_section(os.path.join(root, dir), self.config_section)
126
+ if dir != '':
127
+ self.analyse_lst_file(dir, section)
128
+ for file in files:
129
+ file, section = self.check_section(os.path.join(root, file), self.config_section)
130
+ if file != '':
131
+ self.analyse_a_file(file, section)
132
+
133
+ else:
134
+ for file in os.listdir(dir_name):
135
+ file, section = self.check_section(os.path.join(dir_name, file), self.config_section)
136
+ if file != '' and file.endswith('.csv'):
137
+ self.analyse_a_file(file, section)
138
+ else:
139
+ file, section = self.check_section(a_file, self.config_section)
140
+ if file != '':
141
+ self.analyse_a_file(file, section)
119
142
  lst_file.close()
120
143
  else:
121
144
  warning_message(f'{filename} not found')
@@ -142,7 +165,7 @@ class FileManager:
142
165
 
143
166
  labels_to_delete_list = self.config_manager.get_labels_to_delete_list()
144
167
  if labels_to_delete_list == []:
145
- query = f'MATCH (n) DETACH DELETE n'
168
+ query = 'MATCH (n) DETACH DELETE n'
146
169
  query_processor = CypherFileProcessor(query, self.config_manager, True)
147
170
  self.add_file_to_process_list(query_processor, 'pre')
148
171
  else:
@@ -165,12 +188,36 @@ class FileManager:
165
188
  # Analyse each of the specified input .csv files to determine if they contain Nodes or Relationships
166
189
  # If the file doesn't have a valid combination of columns (or is missing) they are placed in the appropriate list
167
190
  file_list = self.config_manager.get_input_file_list()
191
+ dir_list = self.config_manager.get_input_dir_list()
192
+ recurse_dirs = self.config_manager.get_recurse_dirs()
193
+
168
194
  for a_file in file_list:
169
195
  a_file_split = a_file.split(',')
170
196
  for a_split_file in a_file_split:
171
197
  if a_split_file != '':
172
198
  self.analyse_a_file(a_split_file.strip(), self.config_section)
173
-
199
+
200
+ for a_dir in dir_list:
201
+ a_dir_split = a_dir.split(',')
202
+ for a_split_dir in a_dir_split:
203
+ if a_split_dir != '':
204
+ if recurse_dirs:
205
+ for root, dirs, files in os.walk(a_split_dir.strip()):
206
+ for dir in dirs:
207
+ dir, section = self.check_section(os.path.join(root, dir), self.config_section)
208
+ if dir != '':
209
+ self.analyse_lst_file(dir, section)
210
+ for file in files:
211
+ file, section = self.check_section(os.path.join(root, file), self.config_section)
212
+ if file != '':
213
+ self.analyse_a_file(file, section)
214
+
215
+ else:
216
+ for file in os.listdir(a_split_dir.strip()):
217
+ file, section = self.check_section(os.path.join(a_split_dir.strip(), file), self.config_section)
218
+ if file != '' and file.endswith('.csv'):
219
+ self.analyse_a_file(file, section)
220
+
174
221
  query_list = self.config_manager.get_inline_query_list()
175
222
  for a_query in query_list:
176
223
  if a_query is not None:
@@ -225,19 +272,19 @@ class FileManager:
225
272
  config_section = 'DEFAULT'
226
273
  if config_section not in self.config_manager.get_available_sections():
227
274
  # Use NodeFileProcessor as placeholder. It won't be used, other than to process the errors
228
- this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, None, 'DEFAULT')
275
+ this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, None, 'DEFAULT', self.query_manager)
229
276
  self.add_file_to_list(this_csv_file_processor, 'invalid config section', [])
230
277
  else:
231
278
  # Analyse each of the specified input .csv files to determine if they contain Nodes or Relationships
232
279
  # If the file doesn't have a valid combination of columns (or is missing) they are placed in the appropriate list
233
280
  this_csv_file_type, csv_contents, file_errors = self.file_analysers[config_section].determine_file_type(csv_file, 'csv')
234
281
  if this_csv_file_type == 'nodes':
235
- this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, csv_contents, config_section)
282
+ this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, csv_contents, config_section, self.query_manager)
236
283
  elif this_csv_file_type == 'relationships':
237
- this_csv_file_processor = RelationshipFileProcessor(csv_file, self.config_manager, csv_contents, config_section)
284
+ this_csv_file_processor = RelationshipFileProcessor(csv_file, self.config_manager, csv_contents, config_section, self.query_manager)
238
285
  else:
239
286
  # Use NodeFileProcessor as placeholder. It won't be used, other than to process the errors
240
- this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, csv_contents, config_section)
287
+ this_csv_file_processor = NodeFileProcessor(csv_file, self.config_manager, csv_contents, config_section, self.query_manager)
241
288
  self.add_file_to_list(this_csv_file_processor, this_csv_file_type, file_errors)
242
289
 
243
290
  def analyse_cypher_file(self, query_file):
@@ -390,8 +437,9 @@ class FileManager:
390
437
  except:
391
438
  display_rate = 0
392
439
 
393
- ## total_new_nodes = 0
394
- ## total_new_relationships = 0
440
+ if self.batch_debug:
441
+ total_new_nodes = 0
442
+ total_new_relationships = 0
395
443
 
396
444
  if display_rate > 0:
397
445
  message(f'0 of {num_queries} queries processed at {amu.get_formatted_time_now()}', False)
@@ -413,14 +461,15 @@ class FileManager:
413
461
  if result.get_status() == 200:
414
462
 
415
463
  # Display info on how many of each batch were created
416
- ## new_nodes = result.get_updates()['nodes created']
417
- ## total_new_nodes += new_nodes
418
- ## new_relationships = result.get_updates()['relationships created']
419
- ## total_new_relationships += new_relationships
420
- ## if new_nodes > 0 or new_relationships > 0:
421
- ## if (query.type == 'batch node' and new_nodes != query.batch_size) or (query.type == 'batch relationship' and new_relationships != query.batch_size):
422
- ## info_message(f'Batch {query_count} contained {query.batch_size} updates: only {new_nodes+new_relationships} created')
423
- ## print(query.text)
464
+ if self.batch_debug:
465
+ new_nodes = result.get_updates()['nodes created']
466
+ total_new_nodes += new_nodes
467
+ new_relationships = result.get_updates()['relationships created']
468
+ total_new_relationships += new_relationships
469
+ if new_nodes > 0 or new_relationships > 0:
470
+ if (query.type == 'batch node' and new_nodes != query.batch_size) or (query.type == 'batch relationship' and new_relationships != query.batch_size):
471
+ info_message(f'Batch {query_count} contained {query.batch_size} updates: only {new_nodes+new_relationships} created')
472
+ print(query.text)
424
473
 
425
474
  if self.report_queries:
426
475
  result.print_results('Updates made: ')
@@ -446,7 +495,7 @@ class FileManager:
446
495
  file_results.set_status(result.get_status())
447
496
  break
448
497
  else:
449
- info_message(f'No changes made by ', query.text)
498
+ info_message('No changes made by ', query.text)
450
499
 
451
500
  if query.type == 'batch node':
452
501
  batch_info = f'{query.batch_size} nodes, {query.property_count} properties, '
@@ -456,9 +505,10 @@ class FileManager:
456
505
  if display_rate > 0 and not self.report_queries:
457
506
  if query_count % display_rate == 0 or query_count == num_queries:
458
507
  message(f'{query_count} of {num_queries} queries processed at {amu.get_formatted_time_now()} ({query_count / num_queries * 100:.2f}%)', False)
459
- ## message(f'{query_count} of {num_queries} queries processed at {amu.get_formatted_time_now()} ({query_count / num_queries * 100:.2f}%) Nodes: {total_new_nodes}, Relationships: {total_new_relationships}', False)
460
- ## total_new_nodes = 0
461
- ## total_new_relationships = 0
508
+ if self.batch_debug:
509
+ message(f'{query_count} of {num_queries} queries processed at {amu.get_formatted_time_now()} ({query_count / num_queries * 100:.2f}%) Nodes: {total_new_nodes}, Relationships: {total_new_relationships}', False)
510
+ total_new_nodes = 0
511
+ total_new_relationships = 0
462
512
  else:
463
513
  message_no_cr(f'{query_count} of {num_queries} queries processed ({batch_info}{query_count / num_queries * 100:.2f}%) {chr(13)}')
464
514
 
@@ -26,7 +26,7 @@ class CypherFileProcessor:
26
26
  entry_count = 0
27
27
  while entry_count < cypher_file_size:
28
28
  this_entry = cypher_list[entry_count].strip()
29
- if not this_entry.startswith('#') and not this_entry == '\n':
29
+ if not this_entry.startswith('#') and not this_entry == '\n' and not this_entry == '':
30
30
  next_query += this_entry + '\n'
31
31
  if not this_entry.endswith(',') and not this_entry.endswith('\\'):
32
32
  while next_query.endswith('\n'):
@@ -11,9 +11,11 @@ from property import Neo4jProperty
11
11
 
12
12
  class NodeFileProcessor:
13
13
 
14
- def __init__(self, filename, config, contents, section):
14
+ def __init__(self, filename, config, contents, section, query_manager):
15
15
  self.filename = filename
16
16
  self.contents = contents
17
+ self.section = section
18
+ self.query_manager = query_manager
17
19
 
18
20
  self.primary_property = config.get_primary_property()[section]
19
21
  self.add_system_properties = not config.get_no_system_properties()
@@ -41,8 +43,6 @@ class NodeFileProcessor:
41
43
  self.label_types = amu.label_types
42
44
  self.all_types = amu.all_types
43
45
 
44
- self.section = section
45
-
46
46
  def get_last_row(self, num_rows):
47
47
  if self.last_row < 0:
48
48
  last_row = num_rows
@@ -108,13 +108,12 @@ class NodeFileProcessor:
108
108
  query_text = query_text.set(properties=calculated_properties, property_ref=property_ref_dot)
109
109
 
110
110
  query_text = query_text.toStr()
111
-
112
- query = Neo4jQuery('node', query_text, time_now, merge_labels, new_labels, primary_property, properties, self.section)
113
-
114
- if self.validate_only and not self.summarise:
115
- print(query.text)
116
-
117
- queries.append(query)
111
+ query_list = self.query_manager.parameterise(query_text, self.section)
112
+ for a_query in query_list:
113
+ query = Neo4jQuery('node', a_query, time_now, merge_labels, new_labels, primary_property, properties, self.section)
114
+ if self.validate_only and not self.summarise:
115
+ print(a_query)
116
+ queries.append(query)
118
117
 
119
118
  this_row += 1
120
119
  messages.message_no_cr(f'Generating queries... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
@@ -170,8 +169,14 @@ class NodeFileProcessor:
170
169
  all_properties = pm.combine_properties(properties, primary_property_dict)
171
170
 
172
171
  explicit_properties, calculated_properties = pm.split_out_functional_properties(all_properties)
172
+ param_explicit_props = self.query_manager.parameterise_dict(explicit_properties, self.section)
173
+ param_calc_props = self.query_manager.parameterise_dict(calculated_properties, self.section)
174
+
175
+ query_data_list = []
176
+ for count in range(max(len(param_explicit_props), len(param_calc_props))):
177
+ query_data_list += [[param_explicit_props[min(count, len(param_explicit_props)-1)], param_calc_props[min(count, len(param_calc_props)-1)], time_now]]
173
178
 
174
- query_data = [explicit_properties, calculated_properties, time_now]
179
+ # prop_data = [explicit_properties, calculated_properties, time_now]
175
180
 
176
181
  # So now we know all about this particular update. Let's put it in the query dictionary
177
182
  # We'll group these by unique combinations of labels and primary key type
@@ -179,12 +184,12 @@ class NodeFileProcessor:
179
184
  dictionary_key = [new_labels, merge_labels, remove_labels, [primary_property.key], calculated_properties.keys()]
180
185
  try:
181
186
  dictionary_index = batch_keys.index(dictionary_key)
182
- query_dictionary[dictionary_index].append(query_data)
187
+ query_dictionary[dictionary_index] += query_data_list
183
188
  except:
184
189
  dictionary_index = len(batch_keys)
185
- query_dictionary[dictionary_index] = [query_data]
190
+ query_dictionary[dictionary_index] = query_data_list
186
191
  batch_keys.append(dictionary_key)
187
- dict_size += 1
192
+ dict_size += len(query_data_list)
188
193
 
189
194
  this_row += 1
190
195
  messages.message_no_cr(f'Analysing file... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
@@ -221,8 +226,9 @@ class NodeFileProcessor:
221
226
  formatted_payload = []
222
227
  property_count = 0
223
228
  for a_payload in payload:
224
- formatted_payload.append(property.format(a_payload, property_ref_dot))
225
- property_count += len(a_payload)
229
+ formatted_pload = property.format(a_payload, property_ref_dot, self.query_manager, self.section)
230
+ formatted_payload += formatted_pload
231
+ property_count += len(a_payload)*len(formatted_pload)
226
232
 
227
233
  # Build a MERGE query using queries
228
234
  merge_labels = batch_keys[new_labels][1]
@@ -11,10 +11,11 @@ from property import Neo4jProperty
11
11
 
12
12
  class RelationshipFileProcessor:
13
13
 
14
- def __init__(self, filename, config, contents, section):
14
+ def __init__(self, filename, config, contents, section, query_manager):
15
15
  self.filename = filename
16
16
  self.contents = contents
17
17
  self.section = section
18
+ self.query_manager = query_manager
18
19
 
19
20
  self.primary_property = config.get_primary_property()[section]
20
21
  self.add_system_properties = not config.get_no_system_properties()
@@ -130,12 +131,13 @@ class RelationshipFileProcessor:
130
131
  query_text = query_text.set(properties=calculated_properties, property_ref=relation_ref_dot)
131
132
 
132
133
  query_text = query_text.toStr()
133
- query = Neo4jQuery('relationship', query_text, time_now)
134
+ query_list = self.query_manager.parameterise(query_text, self.section)
134
135
 
135
- if self.validate_only and not self.summarise:
136
- print(query.text)
137
-
138
- queries.append(query)
136
+ for a_query in query_list:
137
+ query = Neo4jQuery('node', a_query, time_now)
138
+ if self.validate_only and not self.summarise:
139
+ print(a_query)
140
+ queries.append(query)
139
141
 
140
142
  this_row += 1
141
143
  messages.message_no_cr(f'Generating queries... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
@@ -172,6 +174,7 @@ class RelationshipFileProcessor:
172
174
  # 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
173
175
  # When we have worked through all the input and grouped the queries by label and relationship combinations, we will create the queries
174
176
 
177
+ new_labels_list = []
175
178
  batch_keys = []
176
179
  query_dictionary = {}
177
180
  dict_size = 0
@@ -203,18 +206,29 @@ class RelationshipFileProcessor:
203
206
  if relation:
204
207
 
205
208
  explicit_properties, calculated_properties = pm.split_out_functional_properties(properties)
206
- new_labels = [from_labels, to_labels, relation, from_node.key, to_node.key, calculated_properties]
207
- query_data = [from_node.value.replace('\\\\n', '\n'), to_node.value.replace('\\\\n', '\n'), explicit_properties, calculated_properties, time_now]
209
+
210
+ param_from_nodes = self.query_manager.parameterise_list([from_node], self.section)
211
+ param_to_nodes = self.query_manager.parameterise_list([to_node], self.section)
212
+ param_explicit_props = self.query_manager.parameterise_dict(explicit_properties, self.section)
213
+ param_calc_props = self.query_manager.parameterise_dict(calculated_properties, self.section)
214
+
215
+ query_data_list = []
216
+ for count in range(max(len(param_from_nodes), len(param_to_nodes), len(param_explicit_props), len(param_calc_props))):
217
+ new_labels_list = [[from_labels, to_labels, relation, from_node.key, to_node.key, param_calc_props[min(count, len(param_calc_props) - 1)]]]
218
+ query_data_list += [[param_from_nodes[min(count, len(param_from_nodes) - 1)].value.replace('\\\\n', '\n'), param_to_nodes[min(count, len(param_to_nodes) - 1)].value.replace('\\\\n', '\n'), param_explicit_props[min(count, len(param_explicit_props) - 1)], param_calc_props[min(count, len(param_calc_props) - 1)], time_now]]
208
219
 
209
220
  # So now we know all about this particular update. Let's put it in the query dictionary
210
- try:
211
- dictionary_index = batch_keys.index(new_labels)
212
- query_dictionary[dictionary_index].append(query_data)
213
- except:
214
- dictionary_index = len(batch_keys)
215
- query_dictionary[dictionary_index] = [query_data]
216
- batch_keys.append(new_labels)
217
- dict_size += 1
221
+ q_count = 0
222
+ for count in range(len(new_labels_list)):
223
+ q_count += 1
224
+ try:
225
+ dictionary_index = batch_keys.index(new_labels_list[count])
226
+ query_dictionary[dictionary_index] += query_data_list
227
+ except:
228
+ dictionary_index = len(batch_keys)
229
+ query_dictionary[dictionary_index] = query_data_list
230
+ batch_keys.append(new_labels_list[count])
231
+ dict_size += len(query_data_list)
218
232
 
219
233
  this_row += 1
220
234
  messages.message_no_cr(f'Analysing file... {100 * (this_row - self.start_from + 1) / num_rows:.0f}%{chr(13)}')
@@ -256,7 +270,9 @@ class RelationshipFileProcessor:
256
270
 
257
271
  formatted_payload = []
258
272
  for a_payload in payload:
259
- formatted_payload.append(property.format(a_payload))
273
+ formatted_pload = property.format(a_payload, '', self.query_manager, self.section)
274
+ formatted_payload += formatted_pload
275
+
260
276
  # Build a MERGE query using queries
261
277
  from_keys = " {" + from_node + ":" + payload_ref_dot + from_ref + "}"
262
278
  to_keys = " {" + to_node + ":" + payload_ref_dot + to_ref + "}"