pymodaq 4.2.3__py3-none-any.whl → 5.0.0__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.

Potentially problematic release.


This version of pymodaq might be problematic. Click here for more details.

Files changed (399) hide show
  1. pymodaq/__init__.py +30 -23
  2. pymodaq/control_modules/daq_move.py +27 -14
  3. pymodaq/control_modules/daq_move_ui.py +33 -16
  4. pymodaq/control_modules/daq_viewer.py +38 -28
  5. pymodaq/control_modules/daq_viewer_ui.py +6 -6
  6. pymodaq/control_modules/mocks.py +1 -1
  7. pymodaq/control_modules/move_utility_classes.py +19 -10
  8. pymodaq/control_modules/utils.py +18 -12
  9. pymodaq/control_modules/viewer_utility_classes.py +13 -4
  10. pymodaq/dashboard.py +166 -118
  11. pymodaq/examples/custom_app.py +13 -16
  12. pymodaq/examples/custom_viewer.py +7 -7
  13. pymodaq/examples/function_plotter.py +13 -12
  14. pymodaq/examples/parameter_ex.py +50 -25
  15. pymodaq/examples/tcp_client.py +1 -1
  16. pymodaq/extensions/__init__.py +1 -1
  17. pymodaq/extensions/bayesian/bayesian_optimisation.py +15 -12
  18. pymodaq/extensions/bayesian/utils.py +10 -10
  19. pymodaq/extensions/console.py +10 -13
  20. pymodaq/extensions/{daq_logger.py → daq_logger/daq_logger.py} +36 -56
  21. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger.py +16 -15
  22. pymodaq/{utils/db/db_logger → extensions/daq_logger/db}/db_logger_models.py +2 -0
  23. pymodaq/{utils/h5modules → extensions/daq_logger}/h5logging.py +7 -8
  24. pymodaq/extensions/daq_scan.py +153 -247
  25. pymodaq/extensions/daq_scan_ui.py +11 -9
  26. pymodaq/extensions/h5browser.py +8 -8
  27. pymodaq/extensions/pid/__init__.py +6 -3
  28. pymodaq/extensions/pid/daq_move_PID.py +4 -2
  29. pymodaq/extensions/pid/pid_controller.py +15 -12
  30. pymodaq/extensions/pid/utils.py +10 -5
  31. pymodaq/extensions/utils.py +5 -3
  32. pymodaq/post_treatment/load_and_plot.py +10 -7
  33. pymodaq/resources/preset_default.xml +1 -1
  34. pymodaq/utils/array_manipulation.py +4 -384
  35. pymodaq/utils/calibration_camera.py +12 -9
  36. pymodaq/utils/chrono_timer.py +7 -5
  37. pymodaq/utils/config.py +3 -450
  38. pymodaq/utils/daq_utils.py +6 -664
  39. pymodaq/utils/data.py +9 -2774
  40. pymodaq/utils/exceptions.py +0 -4
  41. pymodaq/utils/gui_utils/__init__.py +8 -8
  42. pymodaq/utils/gui_utils/loader_utils.py +38 -0
  43. pymodaq/utils/gui_utils/utils.py +6 -138
  44. pymodaq/utils/h5modules/__init__.py +0 -4
  45. pymodaq/utils/h5modules/module_saving.py +15 -8
  46. pymodaq/utils/leco/__init__.py +2 -2
  47. pymodaq/utils/leco/daq_move_LECODirector.py +2 -2
  48. pymodaq/utils/leco/daq_xDviewer_LECODirector.py +2 -2
  49. pymodaq/utils/leco/director_utils.py +2 -2
  50. pymodaq/utils/leco/leco_director.py +3 -3
  51. pymodaq/utils/leco/pymodaq_listener.py +2 -2
  52. pymodaq/utils/leco/utils.py +1 -1
  53. pymodaq/utils/logger.py +4 -76
  54. pymodaq/utils/managers/batchscan_manager.py +16 -19
  55. pymodaq/utils/managers/modules_manager.py +10 -7
  56. pymodaq/utils/managers/overshoot_manager.py +3 -5
  57. pymodaq/utils/managers/preset_manager.py +37 -15
  58. pymodaq/utils/managers/preset_manager_utils.py +11 -9
  59. pymodaq/utils/managers/remote_manager.py +12 -10
  60. pymodaq/utils/math_utils.py +4 -572
  61. pymodaq/utils/parameter/__init__.py +4 -11
  62. pymodaq/utils/parameter/utils.py +4 -299
  63. pymodaq/utils/scanner/scan_config.py +1 -1
  64. pymodaq/utils/scanner/scan_factory.py +16 -12
  65. pymodaq/utils/{plotting → scanner}/scan_selector.py +19 -20
  66. pymodaq/utils/scanner/scanner.py +10 -8
  67. pymodaq/utils/scanner/scanners/_1d_scanners.py +8 -5
  68. pymodaq/utils/scanner/scanners/_2d_scanners.py +5 -5
  69. pymodaq/utils/scanner/scanners/sequential.py +8 -8
  70. pymodaq/utils/scanner/scanners/tabular.py +9 -9
  71. pymodaq/utils/scanner/utils.py +6 -4
  72. pymodaq/utils/svg/svg_viewer2D.py +3 -4
  73. pymodaq/utils/tcp_ip/serializer.py +64 -16
  74. pymodaq/utils/tcp_ip/tcp_server_client.py +10 -8
  75. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/METADATA +5 -3
  76. pymodaq-5.0.0.dist-info/RECORD +123 -0
  77. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/WHEEL +1 -1
  78. pymodaq/post_treatment/process_to_scalar.py +0 -263
  79. pymodaq/resources/QtDesigner_Ressources/Icon_Library/1d.png +0 -0
  80. pymodaq/resources/QtDesigner_Ressources/Icon_Library/2d.png +0 -0
  81. pymodaq/resources/QtDesigner_Ressources/Icon_Library/3d.png +0 -0
  82. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add2.png +0 -0
  83. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Add_Step.png +0 -0
  84. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve.png +0 -0
  85. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Approve_All.png +0 -0
  86. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Browse_Dir_Path.png +0 -0
  87. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Calculator.png +0 -0
  88. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnGroup.png +0 -0
  89. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnNum.png +0 -0
  90. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnText.png +0 -0
  91. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnTime.png +0 -0
  92. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ChnWave.png +0 -0
  93. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Close3.png +0 -0
  94. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll.png +0 -0
  95. pymodaq/resources/QtDesigner_Ressources/Icon_Library/CollapseAll_32.png +0 -0
  96. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ColorPicker.png +0 -0
  97. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Contract.png +0 -0
  98. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Create.png +0 -0
  99. pymodaq/resources/QtDesigner_Ressources/Icon_Library/DeleteLayer.png +0 -0
  100. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditOpen.png +0 -0
  101. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditRedo.png +0 -0
  102. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EditUndo.png +0 -0
  103. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Ellipse.png +0 -0
  104. pymodaq/resources/QtDesigner_Ressources/Icon_Library/EllipseFilled.png +0 -0
  105. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error.png +0 -0
  106. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ErrorMessage.png +0 -0
  107. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Error_16.png +0 -0
  108. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Exit.png +0 -0
  109. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Expand.png +0 -0
  110. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll.png +0 -0
  111. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ExpandAll_32.png +0 -0
  112. pymodaq/resources/QtDesigner_Ressources/Icon_Library/FFT.png +0 -0
  113. pymodaq/resources/QtDesigner_Ressources/Icon_Library/HLM.ico +0 -0
  114. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help.png +0 -0
  115. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Help_32.png +0 -0
  116. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Histogram.png +0 -0
  117. pymodaq/resources/QtDesigner_Ressources/Icon_Library/LUT_LookUpTable.png +0 -0
  118. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass.png +0 -0
  119. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MagnifyingGlass_24.png +0 -0
  120. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Marker.png +0 -0
  121. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Math.png +0 -0
  122. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MeasurementStudio_32.png +0 -0
  123. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Move.png +0 -0
  124. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveDown.png +0 -0
  125. pymodaq/resources/QtDesigner_Ressources/Icon_Library/MoveUp.png +0 -0
  126. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Multiply.png +0 -0
  127. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewFile.png +0 -0
  128. pymodaq/resources/QtDesigner_Ressources/Icon_Library/NewLayer.png +0 -0
  129. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_File.png +0 -0
  130. pymodaq/resources/QtDesigner_Ressources/Icon_Library/New_Folder.png +0 -0
  131. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open.png +0 -0
  132. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_1D.png +0 -0
  133. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_2D.png +0 -0
  134. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File.png +0 -0
  135. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_File_32.png +0 -0
  136. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Open_sim.png +0 -0
  137. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Options.png +0 -0
  138. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope.png +0 -0
  139. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Oscilloscope_16.png +0 -0
  140. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Pass.png +0 -0
  141. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RGB.png +0 -0
  142. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rectangle.png +0 -0
  143. pymodaq/resources/QtDesigner_Ressources/Icon_Library/RectangleFilled.png +0 -0
  144. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Redo.png +0 -0
  145. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh.png +0 -0
  146. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh2.png +0 -0
  147. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Refresh_32.png +0 -0
  148. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Region.png +0 -0
  149. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Rendezvous.png +0 -0
  150. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SELECT.png +0 -0
  151. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save.png +0 -0
  152. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll.png +0 -0
  153. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAll_32.png +0 -0
  154. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs.png +0 -0
  155. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SaveAs_32.png +0 -0
  156. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_24.png +0 -0
  157. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Save_32.png +0 -0
  158. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Search.png +0 -0
  159. pymodaq/resources/QtDesigner_Ressources/Icon_Library/SelectPolygon.png +0 -0
  160. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Select_24.png +0 -0
  161. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Settings.png +0 -0
  162. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snap&Save.png +0 -0
  163. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot.png +0 -0
  164. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2.png +0 -0
  165. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_16.png +0 -0
  166. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Snapshot2_32.png +0 -0
  167. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Spreadsheet.png +0 -0
  168. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics.png +0 -0
  169. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Statistics2.png +0 -0
  170. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Status.png +0 -0
  171. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Subtract.png +0 -0
  172. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Vision.png +0 -0
  173. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Volts.png +0 -0
  174. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Wait2.png +0 -0
  175. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_1_1.png +0 -0
  176. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_in.png +0 -0
  177. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_out.png +0 -0
  178. pymodaq/resources/QtDesigner_Ressources/Icon_Library/Zoom_to_Selection.png +0 -0
  179. pymodaq/resources/QtDesigner_Ressources/Icon_Library/abort.png +0 -0
  180. pymodaq/resources/QtDesigner_Ressources/Icon_Library/advanced2.png +0 -0
  181. pymodaq/resources/QtDesigner_Ressources/Icon_Library/autoscale.png +0 -0
  182. pymodaq/resources/QtDesigner_Ressources/Icon_Library/b_icon.png +0 -0
  183. pymodaq/resources/QtDesigner_Ressources/Icon_Library/back.png +0 -0
  184. pymodaq/resources/QtDesigner_Ressources/Icon_Library/bg_icon.png +0 -0
  185. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera.png +0 -0
  186. pymodaq/resources/QtDesigner_Ressources/Icon_Library/camera_snap.png +0 -0
  187. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cartesian.png +0 -0
  188. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear2.png +0 -0
  189. pymodaq/resources/QtDesigner_Ressources/Icon_Library/clear_ROI.png +0 -0
  190. pymodaq/resources/QtDesigner_Ressources/Icon_Library/close2.png +0 -0
  191. pymodaq/resources/QtDesigner_Ressources/Icon_Library/cluster2.png +0 -0
  192. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color.png +0 -0
  193. pymodaq/resources/QtDesigner_Ressources/Icon_Library/color2.png +0 -0
  194. pymodaq/resources/QtDesigner_Ressources/Icon_Library/continuous.png +0 -0
  195. pymodaq/resources/QtDesigner_Ressources/Icon_Library/data.png +0 -0
  196. pymodaq/resources/QtDesigner_Ressources/Icon_Library/delay.png +0 -0
  197. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download.png +0 -0
  198. pymodaq/resources/QtDesigner_Ressources/Icon_Library/download2.png +0 -0
  199. pymodaq/resources/QtDesigner_Ressources/Icon_Library/error2.png +0 -0
  200. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ethernet.png +0 -0
  201. pymodaq/resources/QtDesigner_Ressources/Icon_Library/exit2.png +0 -0
  202. pymodaq/resources/QtDesigner_Ressources/Icon_Library/fan.png +0 -0
  203. pymodaq/resources/QtDesigner_Ressources/Icon_Library/filter2.png +0 -0
  204. pymodaq/resources/QtDesigner_Ressources/Icon_Library/g_icon.png +0 -0
  205. pymodaq/resources/QtDesigner_Ressources/Icon_Library/gear2.png +0 -0
  206. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to.png +0 -0
  207. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_1.png +0 -0
  208. pymodaq/resources/QtDesigner_Ressources/Icon_Library/go_to_2.png +0 -0
  209. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grab.png +0 -0
  210. pymodaq/resources/QtDesigner_Ressources/Icon_Library/graph.png +0 -0
  211. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2.png +0 -0
  212. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greenLight2_32.png +0 -0
  213. pymodaq/resources/QtDesigner_Ressources/Icon_Library/green_light.png +0 -0
  214. pymodaq/resources/QtDesigner_Ressources/Icon_Library/grey_icon.png +0 -0
  215. pymodaq/resources/QtDesigner_Ressources/Icon_Library/greyscale.png +0 -0
  216. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1.png +0 -0
  217. pymodaq/resources/QtDesigner_Ressources/Icon_Library/help1_32.png +0 -0
  218. pymodaq/resources/QtDesigner_Ressources/Icon_Library/home2.png +0 -0
  219. pymodaq/resources/QtDesigner_Ressources/Icon_Library/information2.png +0 -0
  220. pymodaq/resources/QtDesigner_Ressources/Icon_Library/ini.png +0 -0
  221. pymodaq/resources/QtDesigner_Ressources/Icon_Library/integrator.png +0 -0
  222. pymodaq/resources/QtDesigner_Ressources/Icon_Library/joystick.png +0 -0
  223. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green.png +0 -0
  224. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_green_16.png +0 -0
  225. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red.png +0 -0
  226. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_red_16.png +0 -0
  227. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow.png +0 -0
  228. pymodaq/resources/QtDesigner_Ressources/Icon_Library/light_yellow_16.png +0 -0
  229. pymodaq/resources/QtDesigner_Ressources/Icon_Library/limiter.png +0 -0
  230. pymodaq/resources/QtDesigner_Ressources/Icon_Library/load_ROI.png +0 -0
  231. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meshPlot.png +0 -0
  232. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter.png +0 -0
  233. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter2.png +0 -0
  234. pymodaq/resources/QtDesigner_Ressources/Icon_Library/meter_32.png +0 -0
  235. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_contour.png +0 -0
  236. pymodaq/resources/QtDesigner_Ressources/Icon_Library/move_straight_line.png +0 -0
  237. pymodaq/resources/QtDesigner_Ressources/Icon_Library/movie.png +0 -0
  238. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multi_point.png +0 -0
  239. pymodaq/resources/QtDesigner_Ressources/Icon_Library/multiplexer.png +0 -0
  240. pymodaq/resources/QtDesigner_Ressources/Icon_Library/new.png +0 -0
  241. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openArrow.png +0 -0
  242. pymodaq/resources/QtDesigner_Ressources/Icon_Library/openTree.png +0 -0
  243. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope2.png +0 -0
  244. pymodaq/resources/QtDesigner_Ressources/Icon_Library/oscilloscope3.png +0 -0
  245. pymodaq/resources/QtDesigner_Ressources/Icon_Library/overlay.png +0 -0
  246. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2.png +0 -0
  247. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass2_16.png +0 -0
  248. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pass_32.png +0 -0
  249. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pause.png +0 -0
  250. pymodaq/resources/QtDesigner_Ressources/Icon_Library/permute.png +0 -0
  251. pymodaq/resources/QtDesigner_Ressources/Icon_Library/phase.png +0 -0
  252. pymodaq/resources/QtDesigner_Ressources/Icon_Library/play.png +0 -0
  253. pymodaq/resources/QtDesigner_Ressources/Icon_Library/polar.png +0 -0
  254. pymodaq/resources/QtDesigner_Ressources/Icon_Library/pole_zero.png +0 -0
  255. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerMeter.png +0 -0
  256. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch.png +0 -0
  257. pymodaq/resources/QtDesigner_Ressources/Icon_Library/powerSwitch_16.png +0 -0
  258. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2.png +0 -0
  259. pymodaq/resources/QtDesigner_Ressources/Icon_Library/print2_32.png +0 -0
  260. pymodaq/resources/QtDesigner_Ressources/Icon_Library/properties.png +0 -0
  261. pymodaq/resources/QtDesigner_Ressources/Icon_Library/r_icon.png +0 -0
  262. pymodaq/resources/QtDesigner_Ressources/Icon_Library/radiocontrolbutton.png +0 -0
  263. pymodaq/resources/QtDesigner_Ressources/Icon_Library/read2.png +0 -0
  264. pymodaq/resources/QtDesigner_Ressources/Icon_Library/red_light.png +0 -0
  265. pymodaq/resources/QtDesigner_Ressources/Icon_Library/remove.png +0 -0
  266. pymodaq/resources/QtDesigner_Ressources/Icon_Library/reset.png +0 -0
  267. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rgb_icon.png +0 -0
  268. pymodaq/resources/QtDesigner_Ressources/Icon_Library/robot.png +0 -0
  269. pymodaq/resources/QtDesigner_Ressources/Icon_Library/rotation2.png +0 -0
  270. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run2.png +0 -0
  271. pymodaq/resources/QtDesigner_Ressources/Icon_Library/run_all.png +0 -0
  272. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saturation.png +0 -0
  273. pymodaq/resources/QtDesigner_Ressources/Icon_Library/saveTree.png +0 -0
  274. pymodaq/resources/QtDesigner_Ressources/Icon_Library/save_ROI.png +0 -0
  275. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_horizontally.png +0 -0
  276. pymodaq/resources/QtDesigner_Ressources/Icon_Library/scale_vertically.png +0 -0
  277. pymodaq/resources/QtDesigner_Ressources/Icon_Library/search2.png +0 -0
  278. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select2.png +0 -0
  279. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all.png +0 -0
  280. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_all2.png +0 -0
  281. pymodaq/resources/QtDesigner_Ressources/Icon_Library/select_none.png +0 -0
  282. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence.png +0 -0
  283. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sequence2.png +0 -0
  284. pymodaq/resources/QtDesigner_Ressources/Icon_Library/snap.png +0 -0
  285. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sort_ascend.png +0 -0
  286. pymodaq/resources/QtDesigner_Ressources/Icon_Library/spectrumAnalyzer.png +0 -0
  287. pymodaq/resources/QtDesigner_Ressources/Icon_Library/start.png +0 -0
  288. pymodaq/resources/QtDesigner_Ressources/Icon_Library/status_cancelled.png +0 -0
  289. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop.png +0 -0
  290. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop2.png +0 -0
  291. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop3.png +0 -0
  292. pymodaq/resources/QtDesigner_Ressources/Icon_Library/stop_all.png +0 -0
  293. pymodaq/resources/QtDesigner_Ressources/Icon_Library/sum.png +0 -0
  294. pymodaq/resources/QtDesigner_Ressources/Icon_Library/surfacePlot.png +0 -0
  295. pymodaq/resources/QtDesigner_Ressources/Icon_Library/tree.png +0 -0
  296. pymodaq/resources/QtDesigner_Ressources/Icon_Library/updateTree.png +0 -0
  297. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility2.png +0 -0
  298. pymodaq/resources/QtDesigner_Ressources/Icon_Library/utility_small.png +0 -0
  299. pymodaq/resources/QtDesigner_Ressources/Icon_Library/vector.png +0 -0
  300. pymodaq/resources/QtDesigner_Ressources/Icon_Library/verify.png +0 -0
  301. pymodaq/resources/QtDesigner_Ressources/Icon_Library/video.png +0 -0
  302. pymodaq/resources/QtDesigner_Ressources/Icon_Library/wait.png +0 -0
  303. pymodaq/resources/QtDesigner_Ressources/Icon_Library/waterfallPlot.png +0 -0
  304. pymodaq/resources/QtDesigner_Ressources/Icon_Library/watershed.png +0 -0
  305. pymodaq/resources/QtDesigner_Ressources/Icon_Library/yellow_light.png +0 -0
  306. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zip_file.png +0 -0
  307. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomAuto.png +0 -0
  308. pymodaq/resources/QtDesigner_Ressources/Icon_Library/zoomReset.png +0 -0
  309. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.bat +0 -2
  310. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources.qrc +0 -234
  311. pymodaq/resources/QtDesigner_Ressources/QtDesigner_ressources_rc.py +0 -127150
  312. pymodaq/resources/QtDesigner_Ressources/icons.svg +0 -142
  313. pymodaq/resources/VERSION +0 -1
  314. pymodaq/resources/config_template.toml +0 -90
  315. pymodaq/resources/triangulation_data.npy +0 -0
  316. pymodaq/utils/abstract/__init__.py +0 -48
  317. pymodaq/utils/db/__init__.py +0 -0
  318. pymodaq/utils/db/db_logger/__init__.py +0 -0
  319. pymodaq/utils/enums.py +0 -76
  320. pymodaq/utils/factory.py +0 -82
  321. pymodaq/utils/gui_utils/custom_app.py +0 -133
  322. pymodaq/utils/gui_utils/dock.py +0 -107
  323. pymodaq/utils/gui_utils/file_io.py +0 -93
  324. pymodaq/utils/gui_utils/layout.py +0 -34
  325. pymodaq/utils/gui_utils/list_picker.py +0 -38
  326. pymodaq/utils/gui_utils/widgets/__init__.py +0 -5
  327. pymodaq/utils/gui_utils/widgets/label.py +0 -24
  328. pymodaq/utils/gui_utils/widgets/lcd.py +0 -111
  329. pymodaq/utils/gui_utils/widgets/push.py +0 -149
  330. pymodaq/utils/gui_utils/widgets/qled.py +0 -62
  331. pymodaq/utils/gui_utils/widgets/spinbox.py +0 -24
  332. pymodaq/utils/gui_utils/widgets/table.py +0 -263
  333. pymodaq/utils/gui_utils/widgets/tree_layout.py +0 -188
  334. pymodaq/utils/gui_utils/widgets/tree_toml.py +0 -102
  335. pymodaq/utils/h5modules/backends.py +0 -1022
  336. pymodaq/utils/h5modules/browsing.py +0 -625
  337. pymodaq/utils/h5modules/data_saving.py +0 -1101
  338. pymodaq/utils/h5modules/exporter.py +0 -119
  339. pymodaq/utils/h5modules/exporters/__init__.py +0 -0
  340. pymodaq/utils/h5modules/exporters/base.py +0 -111
  341. pymodaq/utils/h5modules/exporters/flimj.py +0 -63
  342. pymodaq/utils/h5modules/exporters/hyperspy.py +0 -143
  343. pymodaq/utils/h5modules/saving.py +0 -866
  344. pymodaq/utils/h5modules/utils.py +0 -115
  345. pymodaq/utils/managers/action_manager.py +0 -489
  346. pymodaq/utils/managers/parameter_manager.py +0 -282
  347. pymodaq/utils/managers/roi_manager.py +0 -726
  348. pymodaq/utils/messenger.py +0 -66
  349. pymodaq/utils/parameter/ioxml.py +0 -542
  350. pymodaq/utils/parameter/pymodaq_ptypes/__init__.py +0 -38
  351. pymodaq/utils/parameter/pymodaq_ptypes/bool.py +0 -31
  352. pymodaq/utils/parameter/pymodaq_ptypes/date.py +0 -126
  353. pymodaq/utils/parameter/pymodaq_ptypes/filedir.py +0 -143
  354. pymodaq/utils/parameter/pymodaq_ptypes/itemselect.py +0 -265
  355. pymodaq/utils/parameter/pymodaq_ptypes/led.py +0 -44
  356. pymodaq/utils/parameter/pymodaq_ptypes/list.py +0 -150
  357. pymodaq/utils/parameter/pymodaq_ptypes/numeric.py +0 -18
  358. pymodaq/utils/parameter/pymodaq_ptypes/pixmap.py +0 -175
  359. pymodaq/utils/parameter/pymodaq_ptypes/slide.py +0 -145
  360. pymodaq/utils/parameter/pymodaq_ptypes/table.py +0 -135
  361. pymodaq/utils/parameter/pymodaq_ptypes/tableview.py +0 -149
  362. pymodaq/utils/parameter/pymodaq_ptypes/text.py +0 -142
  363. pymodaq/utils/plotting/__init__.py +0 -0
  364. pymodaq/utils/plotting/data_viewers/__init__.py +0 -10
  365. pymodaq/utils/plotting/data_viewers/base.py +0 -286
  366. pymodaq/utils/plotting/data_viewers/viewer.py +0 -274
  367. pymodaq/utils/plotting/data_viewers/viewer0D.py +0 -298
  368. pymodaq/utils/plotting/data_viewers/viewer1D.py +0 -820
  369. pymodaq/utils/plotting/data_viewers/viewer1Dbasic.py +0 -231
  370. pymodaq/utils/plotting/data_viewers/viewer2D.py +0 -1118
  371. pymodaq/utils/plotting/data_viewers/viewer2D_basic.py +0 -146
  372. pymodaq/utils/plotting/data_viewers/viewerND.py +0 -800
  373. pymodaq/utils/plotting/gant_chart.py +0 -123
  374. pymodaq/utils/plotting/image_viewer.py +0 -97
  375. pymodaq/utils/plotting/items/__init__.py +0 -0
  376. pymodaq/utils/plotting/items/axis_scaled.py +0 -93
  377. pymodaq/utils/plotting/items/crosshair.py +0 -94
  378. pymodaq/utils/plotting/items/image.py +0 -388
  379. pymodaq/utils/plotting/navigator.py +0 -353
  380. pymodaq/utils/plotting/plotter/plotter.py +0 -94
  381. pymodaq/utils/plotting/plotter/plotters/__init__.py +0 -0
  382. pymodaq/utils/plotting/plotter/plotters/matplotlib_plotters.py +0 -134
  383. pymodaq/utils/plotting/plotter/plotters/qt_plotters.py +0 -78
  384. pymodaq/utils/plotting/utils/__init__.py +0 -0
  385. pymodaq/utils/plotting/utils/axes_viewer.py +0 -88
  386. pymodaq/utils/plotting/utils/filter.py +0 -585
  387. pymodaq/utils/plotting/utils/lineout.py +0 -226
  388. pymodaq/utils/plotting/utils/plot_utils.py +0 -579
  389. pymodaq/utils/plotting/utils/signalND.py +0 -1347
  390. pymodaq/utils/plotting/widgets.py +0 -76
  391. pymodaq/utils/qvariant.py +0 -12
  392. pymodaq/utils/slicing.py +0 -63
  393. pymodaq/utils/units.py +0 -216
  394. pymodaq-4.2.3.dist-info/RECORD +0 -438
  395. /pymodaq/{post_treatment/daq_analysis → extensions/daq_logger}/__init__.py +0 -0
  396. /pymodaq/{utils/abstract/logger.py → extensions/daq_logger/abstract.py} +0 -0
  397. /pymodaq/{resources/QtDesigner_Ressources → extensions/daq_logger/db}/__init__.py +0 -0
  398. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/entry_points.txt +0 -0
  399. {pymodaq-4.2.3.dist-info → pymodaq-5.0.0.dist-info}/licenses/LICENSE +0 -0
pymodaq/utils/config.py CHANGED
@@ -1,165 +1,6 @@
1
- from abc import abstractproperty
2
- from collections.abc import Iterable
3
-
4
- from os import environ
5
- import sys
6
- import datetime
7
- from pathlib import Path
8
- from typing import Union, Dict, TypeVar, Any, List, TYPE_CHECKING
9
- from typing import Iterable as IterableType
10
-
11
- import toml
12
-
13
- if TYPE_CHECKING:
14
- from pymodaq.utils.parameter import Parameter
15
-
16
-
17
- try:
18
- USER = environ['USERNAME'] if sys.platform == 'win32' else environ['USER']
19
- except:
20
- USER = 'unknown_user'
21
-
22
- CONFIG_BASE_PATH = Path(environ['PROGRAMDATA']) if sys.platform == 'win32' else \
23
- Path('Library/Application Support') if sys.platform == 'darwin' else Path('/etc')
24
-
25
-
26
- KeyType = TypeVar('KeyType')
27
-
28
-
29
- def deep_update(mapping: Dict[KeyType, Any], *updating_mappings: Dict[KeyType, Any]) -> Dict[KeyType, Any]:
30
- """ Make sure a dictionary is updated using another dict in any nested level
31
- Taken from Pydantic v1
32
- """
33
- updated_mapping = mapping.copy()
34
- for updating_mapping in updating_mappings:
35
- for k, v in updating_mapping.items():
36
- if k in updated_mapping and isinstance(updated_mapping[k], dict) and isinstance(v, dict):
37
- updated_mapping[k] = deep_update(updated_mapping[k], v)
38
- else:
39
- updated_mapping[k] = v
40
- return updated_mapping
41
-
42
-
43
- def replace_file_extension(filename: str, ext: str):
44
- """Replace the extension of a file by the specified one, without the dot"""
45
- file_name = Path(filename).stem # remove eventual extensions
46
- if ext[0] == '.':
47
- ext = ext[1:]
48
- file_name += '.' + ext
49
- return file_name
50
-
51
-
52
- def getitem_recursive(dic, *args, ndepth=0, create_if_missing=False):
53
- """Will scan recursively a dictionary in order to get the item defined by the iterable args
54
-
55
- Parameters
56
- ----------
57
- dic: dict
58
- the dictionary to scan
59
- args: an iterable of str
60
- keys of the dict
61
- ndepth: int
62
- by default (0) get the last element defined by args. 1 would mean it get the parent dict, 2 the parent of the
63
- parent...
64
- create_if_missing: bool
65
- if the entry is not present, create it assigning the 'none' default value (as a lower case string)
66
- Returns
67
- -------
68
- object or dict
69
- """
70
- args = list(args)
71
- while len(args) > ndepth:
72
- try:
73
- arg = args.pop(0)
74
- dic = dic[arg]
75
- except KeyError as e:
76
- if create_if_missing:
77
- if len(args) > 0:
78
- dic[arg] = {}
79
- dic = dic[arg]
80
- else:
81
- dic[arg] = 'none'
82
- dic = 'none'
83
- else:
84
- raise e
85
- return dic
86
-
87
-
88
- def recursive_iterable_flattening(aniterable: IterableType):
89
- flatten_iter = []
90
- for elt in aniterable:
91
- if not isinstance(elt, str) and isinstance(elt, Iterable):
92
- flatten_iter.extend(recursive_iterable_flattening(elt))
93
- else:
94
- flatten_iter.append(elt)
95
- return flatten_iter
96
-
97
-
98
- def get_set_path(a_base_path: Path, dir_name: str) -> Path:
99
- path_to_get = a_base_path.joinpath(dir_name)
100
- if not path_to_get.is_dir():
101
- try:
102
- path_to_get.mkdir()
103
- except PermissionError as e:
104
- print(f"Cannot create local config folder at this location: {path_to_get}"
105
- f", try using admin rights. "
106
- f"Changing the not permitted path to a user one: {Path.home().joinpath(dir_name)}.")
107
- path_to_get = Path.home().joinpath(dir_name)
108
- if not path_to_get.is_dir():
109
- path_to_get.mkdir()
110
- return path_to_get
111
-
112
-
113
- def get_set_local_dir(user=False) -> Path:
114
- """Defines, creates and returns a local folder where configuration files will be saved
115
-
116
- Depending on the os the configurations files will be stored in CONFIG_BASE_PATH, then
117
- each user will have another one created that could override the default and system-wide base folder
118
-
119
- Parameters
120
- ----------
121
- user: bool
122
- if False get the system-wide folder, otherwise the user folder
123
-
124
- Returns
125
- -------
126
- Path: the local path
127
- """
128
- if user:
129
- local_path = get_set_path(Path.home(), '.pymodaq')
130
- else:
131
- local_path = get_set_path(CONFIG_BASE_PATH, '.pymodaq')
132
- return local_path
133
-
134
-
135
- def get_config_file(config_file_name: str, user=False):
136
- return get_set_local_dir(user).joinpath(replace_file_extension(config_file_name, 'toml'))
137
-
138
-
139
- def get_set_config_dir(config_name='config', user=False):
140
- """Creates a folder in the local config directory to store specific configuration files
141
-
142
- Parameters
143
- ----------
144
- config_name: (str) name of the configuration folder
145
- user: bool
146
- if False get the system-wide folder, otherwise the user folder
147
-
148
- Returns
149
- -------
150
- Path
151
-
152
- See Also
153
- --------
154
- get_set_local_dir
155
- """
156
- return get_set_path(get_set_local_dir(user=user), config_name)
157
-
158
-
159
- def get_set_log_path():
160
- """ creates and return the config folder path for log files
161
- """
162
- return get_set_config_dir('log')
1
+ from pymodaq_utils.config import (BaseConfig, Config, ConfigError, get_set_config_dir,
2
+ USER, CONFIG_BASE_PATH, get_set_local_dir)
3
+ from pymodaq_gui.config import get_set_roi_path
163
4
 
164
5
 
165
6
  def get_set_preset_path():
@@ -198,294 +39,6 @@ def get_set_overshoot_path():
198
39
  return get_set_config_dir('overshoot_configs')
199
40
 
200
41
 
201
- def get_set_roi_path():
202
- """ creates and return the config folder path for managers files
203
- """
204
- return get_set_config_dir('roi_configs')
205
-
206
-
207
- def create_toml_from_dict(mydict: dict, dest_path: Path):
208
- """Create a Toml file at a given path from a dictionnary"""
209
- dest_path.write_text(toml.dumps(mydict))
210
-
211
-
212
- def check_config(config_base: dict, config_local: dict):
213
- """Compare two configuration dictionaries. Adding missing keys
214
-
215
- Parameters
216
- ----------
217
- config_base: dict
218
- The base dictionaries with possible new keys
219
- config_local: dict
220
- a dict from a local config file potentially missing keys
221
-
222
- Returns
223
- -------
224
- bool: True if keys where missing else False
225
- """
226
- status = False
227
- for key in config_base:
228
- if key in config_local:
229
- if isinstance(config_base[key], dict):
230
- status = status or check_config(config_base[key], config_local[key])
231
- else:
232
- config_local[key] = config_base[key]
233
- status = True
234
- return status
235
-
236
-
237
- def copy_template_config(config_file_name: str = 'config', source_path: Union[Path, str] = None,
238
- dest_path: Union[Path, str] = None):
239
- """Get a toml file path and copy it
240
-
241
- the destination is made of a given folder path (or the system-wide local path by default) and the config_file_name
242
- appended by the suffix '.toml'
243
-
244
- The source file (or pymodaq config template path by default) is read and dumped in this destination file
245
-
246
- Parameters
247
- ----------
248
- config_file_name: str
249
- the name of the destination config file
250
- source_path: Path or str
251
- the path of the toml source to be copied
252
- dest_path: Path or str
253
- the destination path of the copied config
254
-
255
- Returns
256
- -------
257
- Path: the path of the copied file
258
- """
259
- if dest_path is None:
260
- dest_path = get_set_local_dir()
261
-
262
- file_name = Path(config_file_name).stem # remove eventual extensions
263
- file_name += '.toml'
264
- dest_path_with_filename = dest_path.joinpath(file_name)
265
-
266
- if source_path is None:
267
- config_template_dict = {}
268
- else:
269
- config_template_dict = toml.load(Path(source_path))
270
-
271
- create_toml_from_dict(config_template_dict, dest_path_with_filename)
272
- return dest_path_with_filename
273
-
274
-
275
- def load_system_config_and_update_from_user(config_file_name: str):
276
- """load from a system-wide config file, update it from the user config file
277
-
278
- Parameters
279
- ----------
280
- config_file_name: str
281
- The config file to be loaded
282
- Returns
283
- -------
284
- dict: contains the toml system-wide file update with the user file
285
- """
286
- config_dict = dict([])
287
- toml_base_path = get_config_file(config_file_name, user=False)
288
- if toml_base_path.is_file():
289
- config_dict = toml.load(toml_base_path)
290
- toml_user_path = get_config_file(config_file_name, user=True)
291
- if toml_user_path.is_file():
292
- config_dict = deep_update(config_dict, toml.load(toml_user_path))
293
- return config_dict
294
-
295
-
296
- class ConfigError(Exception):
297
- pass
298
-
299
-
300
- class BaseConfig:
301
- """Base class to manage configuration files
302
-
303
- Should be subclassed with proper class attributes for each configuration file you need with pymodaq
304
-
305
- Attributes
306
- ----------
307
- config_name: str
308
- The name with which the configuration will be saved
309
- config_template_path: Path
310
- The Path of the template from which the config is constructed
311
-
312
- """
313
- config_template_path: Path = abstractproperty()
314
- config_name: str = abstractproperty()
315
-
316
- def __init__(self):
317
- self._config = self.load_config(self.config_name, self.config_template_path)
318
-
319
- def __repr__(self):
320
- return f'{self.config_name} configuration file'
321
-
322
- def __call__(self, *args):
323
- try:
324
- ret = getitem_recursive(self._config, *args)
325
- except KeyError as e:
326
- raise ConfigError(f'the path {args} does not exist in your configuration toml file, check '
327
- f'your pymodaq_local folder')
328
- return ret
329
-
330
- def to_dict(self):
331
- return self._config
332
-
333
- def __getitem__(self, item):
334
- """for backcompatibility when it was a dictionnary"""
335
- if isinstance(item, tuple):
336
- return getitem_recursive(self._config, *item)
337
- else:
338
- return self._config[item]
339
-
340
- # def __setitem__(self, key, value):
341
- # if isinstance(key, tuple):
342
- # dic = getitem_recursive(self._config, *key, ndepth=1, create_if_missing=False)
343
- # dic[key[-1]] = value
344
- # else:
345
- # self._config[key] = value
346
-
347
- def __setitem__(self, key, value):
348
- if isinstance(key, tuple):
349
- dic = getitem_recursive(self._config, *key, ndepth=1, create_if_missing=True)
350
- if value is None: # means the setting is a group
351
- value = {}
352
- dic[key[-1]] = value
353
- else:
354
- self._config[key] = value
355
-
356
- def load_config(self, config_file_name, template_path: Path):
357
- """Load a configuration file from both system-wide and user file
358
-
359
- check also if missing entries in the configuration file compared to the template"""
360
- toml_base_path = get_config_file(config_file_name, user=False)
361
- toml_user_path = get_config_file(config_file_name, user=True)
362
- if toml_base_path.is_file():
363
- config = toml.load(toml_base_path)
364
- if template_path is not None:
365
- config_template = toml.load(template_path)
366
- else:
367
- config_template = {}
368
- if check_config(config_template, config): # check if all fields from template are there
369
- # (could have been modified by some commits)
370
- create_toml_from_dict(config, toml_base_path)
371
-
372
- else:
373
- copy_template_config(config_file_name, template_path, toml_base_path.parent)
374
-
375
- if not toml_user_path.is_file():
376
- # create the author from environment variable
377
- config_dict = self.dict_to_add_to_user()
378
- if config_dict is not None:
379
- create_toml_from_dict(config_dict, toml_user_path)
380
-
381
- config_dict = load_system_config_and_update_from_user(config_file_name)
382
- return config_dict
383
-
384
- def dict_to_add_to_user(self):
385
- """To subclass"""
386
- return dict([])
387
-
388
- @property
389
- def config_path(self):
390
- """Get the user config path"""
391
- return get_config_file(self.config_name, user=True)
392
-
393
- @property
394
- def system_config_path(self):
395
- """Get the system_wide config path"""
396
- return get_config_file(self.config_name, user=False)
397
-
398
- def save(self):
399
- """Save the current Config object into the user toml file"""
400
- self.config_path.write_text(toml.dumps(self.to_dict()))
401
-
402
-
403
- class Config(BaseConfig):
404
- """Main class to deal with configuration values for PyMoDAQ"""
405
- config_template_path = Path(__file__).parent.parent.joinpath('resources/config_template.toml')
406
- config_name = 'config_pymodaq'
407
-
408
- def dict_to_add_to_user(self):
409
- """To subclass"""
410
- return dict(user=dict(name=USER))
411
-
412
-
413
- class ConfigSaverLoader:
414
- """ Allows to set Parameters values from previously saved one in a configuration file
415
-
416
- This plays the role of a cache for these Parameters
417
-
418
- Parameters
419
- ----------
420
- base_param: Parameter
421
- The parent Parameter whose children should be cached in the config file
422
- config: BaseConfig
423
- The Config object that will cache the Parameter values
424
- base_path: Iterable[str]
425
- an iterable of string defining a "category"
426
- """
427
-
428
- def __init__(self, base_param: 'Parameter', config: BaseConfig,
429
- base_path: IterableType[str] = None):
430
- self.config = config
431
- if base_path is None:
432
- base_path = []
433
- self._base_path: List[str] = list(recursive_iterable_flattening(base_path))
434
- self._base_param = base_param
435
-
436
- @property
437
- def base_path(self):
438
- """ Get/Set the iterable of string defining a particular configuration to be loaded/saved"""
439
- return self._base_path
440
-
441
- @base_path.setter
442
- def base_path(self, path: IterableType[str]):
443
- self._base_path = list(recursive_iterable_flattening(path))
444
-
445
- @property
446
- def base_param(self):
447
- """ Get/Set the parent Parameter whose children should be saved in the config file"""
448
- return self._base_param
449
-
450
- @base_param.setter
451
- def base_param(self, param: 'Parameter'):
452
- self._base_param = param
453
-
454
- def load_config(self, param: 'Parameter' = None):
455
- from pymodaq.utils.parameter import utils as putils
456
-
457
- if param is None:
458
- param = self.base_param
459
- base_path = self.base_path[:]
460
- for child in putils.iter_children_params(param, []):
461
- if len(child.children()) == 0: # means it is not a group parameter
462
-
463
- path = base_path + putils.get_param_path(child)[1:]
464
-
465
- try:
466
- child.setValue(self.config(
467
- *path)) # first try to load the config including the actuators name
468
- except ConfigError as e:
469
- pass
470
- else:
471
- self.load_config(child)
472
-
473
- def save_config(self):
474
- from pymodaq.utils.parameter import utils as putils
475
-
476
- for param in putils.iter_children_params(self.base_param, []):
477
- path_param = self.base_path[:]
478
- path_param.extend(putils.get_param_path(param)[1:])
479
- try:
480
- self.config[tuple(path_param)] = param.value()
481
- except Exception as e:
482
- pass
483
- self.config.save()
484
-
485
42
 
486
- if __name__ == '__main__':
487
43
 
488
- config = Config()
489
- config('style', 'darkstyle')
490
- assert config('style', 'darkstyle') == config['style']['darkstyle']
491
44