meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7010__py2.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.
Files changed (445) hide show
  1. meerk40t/__init__.py +1 -1
  2. meerk40t/balormk/balor_params.py +167 -167
  3. meerk40t/balormk/clone_loader.py +457 -457
  4. meerk40t/balormk/controller.py +1566 -1512
  5. meerk40t/balormk/cylindermod.py +64 -0
  6. meerk40t/balormk/device.py +966 -1959
  7. meerk40t/balormk/driver.py +778 -591
  8. meerk40t/balormk/galvo_commands.py +1195 -0
  9. meerk40t/balormk/gui/balorconfig.py +237 -111
  10. meerk40t/balormk/gui/balorcontroller.py +191 -184
  11. meerk40t/balormk/gui/baloroperationproperties.py +116 -115
  12. meerk40t/balormk/gui/corscene.py +845 -0
  13. meerk40t/balormk/gui/gui.py +179 -147
  14. meerk40t/balormk/livelightjob.py +466 -382
  15. meerk40t/balormk/mock_connection.py +131 -109
  16. meerk40t/balormk/plugin.py +133 -135
  17. meerk40t/balormk/usb_connection.py +306 -301
  18. meerk40t/camera/__init__.py +1 -1
  19. meerk40t/camera/camera.py +514 -397
  20. meerk40t/camera/gui/camerapanel.py +1241 -1095
  21. meerk40t/camera/gui/gui.py +58 -58
  22. meerk40t/camera/plugin.py +441 -399
  23. meerk40t/ch341/__init__.py +27 -27
  24. meerk40t/ch341/ch341device.py +628 -628
  25. meerk40t/ch341/libusb.py +595 -589
  26. meerk40t/ch341/mock.py +171 -171
  27. meerk40t/ch341/windriver.py +157 -157
  28. meerk40t/constants.py +13 -0
  29. meerk40t/core/__init__.py +1 -1
  30. meerk40t/core/bindalias.py +550 -539
  31. meerk40t/core/core.py +47 -47
  32. meerk40t/core/cutcode/cubiccut.py +73 -73
  33. meerk40t/core/cutcode/cutcode.py +315 -312
  34. meerk40t/core/cutcode/cutgroup.py +141 -137
  35. meerk40t/core/cutcode/cutobject.py +192 -185
  36. meerk40t/core/cutcode/dwellcut.py +37 -37
  37. meerk40t/core/cutcode/gotocut.py +29 -29
  38. meerk40t/core/cutcode/homecut.py +29 -29
  39. meerk40t/core/cutcode/inputcut.py +34 -34
  40. meerk40t/core/cutcode/linecut.py +33 -33
  41. meerk40t/core/cutcode/outputcut.py +34 -34
  42. meerk40t/core/cutcode/plotcut.py +335 -335
  43. meerk40t/core/cutcode/quadcut.py +61 -61
  44. meerk40t/core/cutcode/rastercut.py +168 -148
  45. meerk40t/core/cutcode/waitcut.py +34 -34
  46. meerk40t/core/cutplan.py +1843 -1316
  47. meerk40t/core/drivers.py +330 -329
  48. meerk40t/core/elements/align.py +801 -669
  49. meerk40t/core/elements/branches.py +1844 -1507
  50. meerk40t/core/elements/clipboard.py +229 -219
  51. meerk40t/core/elements/element_treeops.py +4561 -2837
  52. meerk40t/core/elements/element_types.py +125 -105
  53. meerk40t/core/elements/elements.py +4329 -3617
  54. meerk40t/core/elements/files.py +117 -64
  55. meerk40t/core/elements/geometry.py +473 -224
  56. meerk40t/core/elements/grid.py +467 -316
  57. meerk40t/core/elements/materials.py +158 -94
  58. meerk40t/core/elements/notes.py +50 -38
  59. meerk40t/core/elements/offset_clpr.py +933 -912
  60. meerk40t/core/elements/offset_mk.py +963 -955
  61. meerk40t/core/elements/penbox.py +339 -267
  62. meerk40t/core/elements/placements.py +300 -83
  63. meerk40t/core/elements/render.py +785 -687
  64. meerk40t/core/elements/shapes.py +2618 -2092
  65. meerk40t/core/elements/trace.py +651 -563
  66. meerk40t/core/elements/tree_commands.py +415 -409
  67. meerk40t/core/elements/undo_redo.py +116 -58
  68. meerk40t/core/elements/wordlist.py +319 -200
  69. meerk40t/core/exceptions.py +9 -9
  70. meerk40t/core/laserjob.py +220 -220
  71. meerk40t/core/logging.py +63 -63
  72. meerk40t/core/node/blobnode.py +83 -86
  73. meerk40t/core/node/bootstrap.py +105 -103
  74. meerk40t/core/node/branch_elems.py +40 -31
  75. meerk40t/core/node/branch_ops.py +45 -38
  76. meerk40t/core/node/branch_regmark.py +48 -41
  77. meerk40t/core/node/cutnode.py +29 -32
  78. meerk40t/core/node/effect_hatch.py +375 -257
  79. meerk40t/core/node/effect_warp.py +398 -0
  80. meerk40t/core/node/effect_wobble.py +441 -309
  81. meerk40t/core/node/elem_ellipse.py +404 -309
  82. meerk40t/core/node/elem_image.py +1082 -801
  83. meerk40t/core/node/elem_line.py +358 -292
  84. meerk40t/core/node/elem_path.py +259 -201
  85. meerk40t/core/node/elem_point.py +129 -102
  86. meerk40t/core/node/elem_polyline.py +310 -246
  87. meerk40t/core/node/elem_rect.py +376 -286
  88. meerk40t/core/node/elem_text.py +445 -418
  89. meerk40t/core/node/filenode.py +59 -40
  90. meerk40t/core/node/groupnode.py +138 -74
  91. meerk40t/core/node/image_processed.py +777 -766
  92. meerk40t/core/node/image_raster.py +156 -113
  93. meerk40t/core/node/layernode.py +31 -31
  94. meerk40t/core/node/mixins.py +135 -107
  95. meerk40t/core/node/node.py +1427 -1304
  96. meerk40t/core/node/nutils.py +117 -114
  97. meerk40t/core/node/op_cut.py +462 -335
  98. meerk40t/core/node/op_dots.py +296 -251
  99. meerk40t/core/node/op_engrave.py +414 -311
  100. meerk40t/core/node/op_image.py +755 -369
  101. meerk40t/core/node/op_raster.py +787 -522
  102. meerk40t/core/node/place_current.py +37 -40
  103. meerk40t/core/node/place_point.py +329 -126
  104. meerk40t/core/node/refnode.py +58 -47
  105. meerk40t/core/node/rootnode.py +225 -219
  106. meerk40t/core/node/util_console.py +48 -48
  107. meerk40t/core/node/util_goto.py +84 -65
  108. meerk40t/core/node/util_home.py +61 -61
  109. meerk40t/core/node/util_input.py +102 -102
  110. meerk40t/core/node/util_output.py +102 -102
  111. meerk40t/core/node/util_wait.py +65 -65
  112. meerk40t/core/parameters.py +709 -707
  113. meerk40t/core/planner.py +875 -785
  114. meerk40t/core/plotplanner.py +656 -652
  115. meerk40t/core/space.py +120 -113
  116. meerk40t/core/spoolers.py +706 -705
  117. meerk40t/core/svg_io.py +1836 -1549
  118. meerk40t/core/treeop.py +534 -445
  119. meerk40t/core/undos.py +278 -124
  120. meerk40t/core/units.py +784 -680
  121. meerk40t/core/view.py +393 -322
  122. meerk40t/core/webhelp.py +62 -62
  123. meerk40t/core/wordlist.py +513 -504
  124. meerk40t/cylinder/cylinder.py +247 -0
  125. meerk40t/cylinder/gui/cylindersettings.py +41 -0
  126. meerk40t/cylinder/gui/gui.py +24 -0
  127. meerk40t/device/__init__.py +1 -1
  128. meerk40t/device/basedevice.py +322 -123
  129. meerk40t/device/devicechoices.py +50 -0
  130. meerk40t/device/dummydevice.py +163 -128
  131. meerk40t/device/gui/defaultactions.py +618 -602
  132. meerk40t/device/gui/effectspanel.py +114 -0
  133. meerk40t/device/gui/formatterpanel.py +253 -290
  134. meerk40t/device/gui/warningpanel.py +337 -260
  135. meerk40t/device/mixins.py +13 -13
  136. meerk40t/dxf/__init__.py +1 -1
  137. meerk40t/dxf/dxf_io.py +766 -554
  138. meerk40t/dxf/plugin.py +47 -35
  139. meerk40t/external_plugins.py +79 -79
  140. meerk40t/external_plugins_build.py +28 -28
  141. meerk40t/extra/cag.py +112 -116
  142. meerk40t/extra/coolant.py +403 -0
  143. meerk40t/extra/encode_detect.py +198 -0
  144. meerk40t/extra/ezd.py +1165 -1165
  145. meerk40t/extra/hershey.py +835 -340
  146. meerk40t/extra/imageactions.py +322 -316
  147. meerk40t/extra/inkscape.py +630 -622
  148. meerk40t/extra/lbrn.py +424 -424
  149. meerk40t/extra/outerworld.py +284 -0
  150. meerk40t/extra/param_functions.py +1542 -1556
  151. meerk40t/extra/potrace.py +257 -253
  152. meerk40t/extra/serial_exchange.py +118 -0
  153. meerk40t/extra/updater.py +602 -453
  154. meerk40t/extra/vectrace.py +147 -146
  155. meerk40t/extra/winsleep.py +83 -83
  156. meerk40t/extra/xcs_reader.py +597 -0
  157. meerk40t/fill/fills.py +781 -335
  158. meerk40t/fill/patternfill.py +1061 -1061
  159. meerk40t/fill/patterns.py +614 -567
  160. meerk40t/grbl/control.py +87 -87
  161. meerk40t/grbl/controller.py +990 -903
  162. meerk40t/grbl/device.py +1081 -768
  163. meerk40t/grbl/driver.py +989 -771
  164. meerk40t/grbl/emulator.py +532 -497
  165. meerk40t/grbl/gcodejob.py +783 -767
  166. meerk40t/grbl/gui/grblconfiguration.py +373 -298
  167. meerk40t/grbl/gui/grblcontroller.py +485 -271
  168. meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
  169. meerk40t/grbl/gui/grbloperationconfig.py +105 -0
  170. meerk40t/grbl/gui/gui.py +147 -116
  171. meerk40t/grbl/interpreter.py +44 -44
  172. meerk40t/grbl/loader.py +22 -22
  173. meerk40t/grbl/mock_connection.py +56 -56
  174. meerk40t/grbl/plugin.py +294 -264
  175. meerk40t/grbl/serial_connection.py +93 -88
  176. meerk40t/grbl/tcp_connection.py +81 -79
  177. meerk40t/grbl/ws_connection.py +112 -0
  178. meerk40t/gui/__init__.py +1 -1
  179. meerk40t/gui/about.py +2042 -296
  180. meerk40t/gui/alignment.py +1644 -1608
  181. meerk40t/gui/autoexec.py +199 -0
  182. meerk40t/gui/basicops.py +791 -670
  183. meerk40t/gui/bufferview.py +77 -71
  184. meerk40t/gui/busy.py +170 -133
  185. meerk40t/gui/choicepropertypanel.py +1673 -1469
  186. meerk40t/gui/consolepanel.py +706 -542
  187. meerk40t/gui/devicepanel.py +687 -581
  188. meerk40t/gui/dialogoptions.py +110 -107
  189. meerk40t/gui/executejob.py +316 -306
  190. meerk40t/gui/fonts.py +90 -90
  191. meerk40t/gui/functionwrapper.py +252 -0
  192. meerk40t/gui/gui_mixins.py +729 -0
  193. meerk40t/gui/guicolors.py +205 -182
  194. meerk40t/gui/help_assets/help_assets.py +218 -201
  195. meerk40t/gui/helper.py +154 -0
  196. meerk40t/gui/hersheymanager.py +1430 -846
  197. meerk40t/gui/icons.py +3422 -2747
  198. meerk40t/gui/imagesplitter.py +555 -508
  199. meerk40t/gui/keymap.py +354 -344
  200. meerk40t/gui/laserpanel.py +892 -806
  201. meerk40t/gui/laserrender.py +1470 -1232
  202. meerk40t/gui/lasertoolpanel.py +805 -793
  203. meerk40t/gui/magnetoptions.py +436 -0
  204. meerk40t/gui/materialmanager.py +2917 -0
  205. meerk40t/gui/materialtest.py +1722 -1694
  206. meerk40t/gui/mkdebug.py +646 -359
  207. meerk40t/gui/mwindow.py +163 -140
  208. meerk40t/gui/navigationpanels.py +2605 -2467
  209. meerk40t/gui/notes.py +143 -142
  210. meerk40t/gui/opassignment.py +414 -410
  211. meerk40t/gui/operation_info.py +310 -299
  212. meerk40t/gui/plugin.py +494 -328
  213. meerk40t/gui/position.py +714 -669
  214. meerk40t/gui/preferences.py +901 -650
  215. meerk40t/gui/propertypanels/attributes.py +1461 -1131
  216. meerk40t/gui/propertypanels/blobproperty.py +117 -114
  217. meerk40t/gui/propertypanels/consoleproperty.py +83 -80
  218. meerk40t/gui/propertypanels/gotoproperty.py +77 -0
  219. meerk40t/gui/propertypanels/groupproperties.py +223 -217
  220. meerk40t/gui/propertypanels/hatchproperty.py +489 -469
  221. meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
  222. meerk40t/gui/propertypanels/inputproperty.py +59 -58
  223. meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
  224. meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
  225. meerk40t/gui/propertypanels/outputproperty.py +59 -58
  226. meerk40t/gui/propertypanels/pathproperty.py +389 -380
  227. meerk40t/gui/propertypanels/placementproperty.py +1214 -383
  228. meerk40t/gui/propertypanels/pointproperty.py +140 -136
  229. meerk40t/gui/propertypanels/propertywindow.py +313 -181
  230. meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
  231. meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
  232. meerk40t/gui/propertypanels/textproperty.py +770 -755
  233. meerk40t/gui/propertypanels/waitproperty.py +56 -55
  234. meerk40t/gui/propertypanels/warpproperty.py +121 -0
  235. meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
  236. meerk40t/gui/ribbon.py +2468 -2210
  237. meerk40t/gui/scene/scene.py +1100 -1051
  238. meerk40t/gui/scene/sceneconst.py +22 -22
  239. meerk40t/gui/scene/scenepanel.py +439 -349
  240. meerk40t/gui/scene/scenespacewidget.py +365 -365
  241. meerk40t/gui/scene/widget.py +518 -505
  242. meerk40t/gui/scenewidgets/affinemover.py +215 -215
  243. meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
  244. meerk40t/gui/scenewidgets/bedwidget.py +120 -97
  245. meerk40t/gui/scenewidgets/elementswidget.py +137 -107
  246. meerk40t/gui/scenewidgets/gridwidget.py +785 -745
  247. meerk40t/gui/scenewidgets/guidewidget.py +765 -765
  248. meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
  249. meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
  250. meerk40t/gui/scenewidgets/nodeselector.py +28 -28
  251. meerk40t/gui/scenewidgets/rectselectwidget.py +589 -346
  252. meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
  253. meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
  254. meerk40t/gui/scenewidgets/selectionwidget.py +2952 -2756
  255. meerk40t/gui/simpleui.py +357 -333
  256. meerk40t/gui/simulation.py +2431 -2094
  257. meerk40t/gui/snapoptions.py +208 -203
  258. meerk40t/gui/spoolerpanel.py +1227 -1180
  259. meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
  260. meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
  261. meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
  262. meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
  263. meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
  264. meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
  265. meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
  266. meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
  267. meerk40t/gui/themes.py +200 -78
  268. meerk40t/gui/tips.py +591 -0
  269. meerk40t/gui/toolwidgets/circlebrush.py +35 -35
  270. meerk40t/gui/toolwidgets/toolcircle.py +248 -242
  271. meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
  272. meerk40t/gui/toolwidgets/tooldraw.py +97 -90
  273. meerk40t/gui/toolwidgets/toolellipse.py +219 -212
  274. meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
  275. meerk40t/gui/toolwidgets/toolline.py +39 -144
  276. meerk40t/gui/toolwidgets/toollinetext.py +79 -236
  277. meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
  278. meerk40t/gui/toolwidgets/toolmeasure.py +160 -216
  279. meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
  280. meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
  281. meerk40t/gui/toolwidgets/toolparameter.py +754 -668
  282. meerk40t/gui/toolwidgets/toolplacement.py +108 -108
  283. meerk40t/gui/toolwidgets/toolpoint.py +68 -59
  284. meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
  285. meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
  286. meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
  287. meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
  288. meerk40t/gui/toolwidgets/toolrect.py +211 -207
  289. meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
  290. meerk40t/gui/toolwidgets/toolribbon.py +598 -113
  291. meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
  292. meerk40t/gui/toolwidgets/tooltext.py +98 -89
  293. meerk40t/gui/toolwidgets/toolvector.py +213 -204
  294. meerk40t/gui/toolwidgets/toolwidget.py +39 -39
  295. meerk40t/gui/usbconnect.py +98 -91
  296. meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
  297. meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
  298. meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
  299. meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
  300. meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
  301. meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
  302. meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
  303. meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
  304. meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
  305. meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
  306. meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
  307. meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
  308. meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
  309. meerk40t/gui/wordlisteditor.py +985 -931
  310. meerk40t/gui/wxmeerk40t.py +1444 -1169
  311. meerk40t/gui/wxmmain.py +5578 -4112
  312. meerk40t/gui/wxmribbon.py +1591 -1076
  313. meerk40t/gui/wxmscene.py +1635 -1453
  314. meerk40t/gui/wxmtree.py +2410 -2089
  315. meerk40t/gui/wxutils.py +1769 -1099
  316. meerk40t/gui/zmatrix.py +102 -102
  317. meerk40t/image/__init__.py +1 -1
  318. meerk40t/image/dither.py +429 -0
  319. meerk40t/image/imagetools.py +2778 -2269
  320. meerk40t/internal_plugins.py +150 -130
  321. meerk40t/kernel/__init__.py +63 -12
  322. meerk40t/kernel/channel.py +259 -212
  323. meerk40t/kernel/context.py +538 -538
  324. meerk40t/kernel/exceptions.py +41 -41
  325. meerk40t/kernel/functions.py +463 -414
  326. meerk40t/kernel/jobs.py +100 -100
  327. meerk40t/kernel/kernel.py +3809 -3571
  328. meerk40t/kernel/lifecycles.py +71 -71
  329. meerk40t/kernel/module.py +49 -49
  330. meerk40t/kernel/service.py +147 -147
  331. meerk40t/kernel/settings.py +383 -343
  332. meerk40t/lihuiyu/controller.py +883 -876
  333. meerk40t/lihuiyu/device.py +1181 -1069
  334. meerk40t/lihuiyu/driver.py +1466 -1372
  335. meerk40t/lihuiyu/gui/gui.py +127 -106
  336. meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
  337. meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
  338. meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
  339. meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
  340. meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
  341. meerk40t/lihuiyu/interpreter.py +53 -53
  342. meerk40t/lihuiyu/laserspeed.py +450 -450
  343. meerk40t/lihuiyu/loader.py +90 -90
  344. meerk40t/lihuiyu/parser.py +404 -404
  345. meerk40t/lihuiyu/plugin.py +101 -102
  346. meerk40t/lihuiyu/tcp_connection.py +111 -109
  347. meerk40t/main.py +231 -165
  348. meerk40t/moshi/builder.py +788 -781
  349. meerk40t/moshi/controller.py +505 -499
  350. meerk40t/moshi/device.py +495 -442
  351. meerk40t/moshi/driver.py +862 -696
  352. meerk40t/moshi/gui/gui.py +78 -76
  353. meerk40t/moshi/gui/moshicontrollergui.py +538 -522
  354. meerk40t/moshi/gui/moshidrivergui.py +87 -75
  355. meerk40t/moshi/plugin.py +43 -43
  356. meerk40t/network/console_server.py +102 -57
  357. meerk40t/network/kernelserver.py +10 -9
  358. meerk40t/network/tcp_server.py +142 -140
  359. meerk40t/network/udp_server.py +103 -77
  360. meerk40t/network/web_server.py +390 -0
  361. meerk40t/newly/controller.py +1158 -1144
  362. meerk40t/newly/device.py +874 -732
  363. meerk40t/newly/driver.py +540 -412
  364. meerk40t/newly/gui/gui.py +219 -188
  365. meerk40t/newly/gui/newlyconfig.py +116 -101
  366. meerk40t/newly/gui/newlycontroller.py +193 -186
  367. meerk40t/newly/gui/operationproperties.py +51 -51
  368. meerk40t/newly/mock_connection.py +82 -82
  369. meerk40t/newly/newly_params.py +56 -56
  370. meerk40t/newly/plugin.py +1214 -1246
  371. meerk40t/newly/usb_connection.py +322 -322
  372. meerk40t/rotary/gui/gui.py +52 -46
  373. meerk40t/rotary/gui/rotarysettings.py +240 -232
  374. meerk40t/rotary/rotary.py +202 -98
  375. meerk40t/ruida/control.py +291 -91
  376. meerk40t/ruida/controller.py +138 -1088
  377. meerk40t/ruida/device.py +672 -231
  378. meerk40t/ruida/driver.py +534 -472
  379. meerk40t/ruida/emulator.py +1494 -1491
  380. meerk40t/ruida/exceptions.py +4 -4
  381. meerk40t/ruida/gui/gui.py +71 -76
  382. meerk40t/ruida/gui/ruidaconfig.py +239 -72
  383. meerk40t/ruida/gui/ruidacontroller.py +187 -184
  384. meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
  385. meerk40t/ruida/loader.py +54 -52
  386. meerk40t/ruida/mock_connection.py +57 -109
  387. meerk40t/ruida/plugin.py +124 -87
  388. meerk40t/ruida/rdjob.py +2084 -945
  389. meerk40t/ruida/serial_connection.py +116 -0
  390. meerk40t/ruida/tcp_connection.py +146 -0
  391. meerk40t/ruida/udp_connection.py +73 -0
  392. meerk40t/svgelements.py +9671 -9669
  393. meerk40t/tools/driver_to_path.py +584 -579
  394. meerk40t/tools/geomstr.py +5583 -4680
  395. meerk40t/tools/jhfparser.py +357 -292
  396. meerk40t/tools/kerftest.py +904 -890
  397. meerk40t/tools/livinghinges.py +1168 -1033
  398. meerk40t/tools/pathtools.py +987 -949
  399. meerk40t/tools/pmatrix.py +234 -0
  400. meerk40t/tools/pointfinder.py +942 -942
  401. meerk40t/tools/polybool.py +940 -940
  402. meerk40t/tools/rasterplotter.py +1660 -547
  403. meerk40t/tools/shxparser.py +989 -901
  404. meerk40t/tools/ttfparser.py +726 -446
  405. meerk40t/tools/zinglplotter.py +595 -593
  406. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/LICENSE +21 -21
  407. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/METADATA +150 -139
  408. meerk40t-0.9.7010.dist-info/RECORD +445 -0
  409. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/WHEEL +1 -1
  410. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/top_level.txt +0 -1
  411. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/zip-safe +1 -1
  412. meerk40t/balormk/elementlightjob.py +0 -159
  413. meerk40t-0.9.3001.dist-info/RECORD +0 -437
  414. test/bootstrap.py +0 -63
  415. test/test_cli.py +0 -12
  416. test/test_core_cutcode.py +0 -418
  417. test/test_core_elements.py +0 -144
  418. test/test_core_plotplanner.py +0 -397
  419. test/test_core_viewports.py +0 -312
  420. test/test_drivers_grbl.py +0 -108
  421. test/test_drivers_lihuiyu.py +0 -443
  422. test/test_drivers_newly.py +0 -113
  423. test/test_element_degenerate_points.py +0 -43
  424. test/test_elements_classify.py +0 -97
  425. test/test_elements_penbox.py +0 -22
  426. test/test_file_svg.py +0 -176
  427. test/test_fill.py +0 -155
  428. test/test_geomstr.py +0 -1523
  429. test/test_geomstr_nodes.py +0 -18
  430. test/test_imagetools_actualize.py +0 -306
  431. test/test_imagetools_wizard.py +0 -258
  432. test/test_kernel.py +0 -200
  433. test/test_laser_speeds.py +0 -3303
  434. test/test_length.py +0 -57
  435. test/test_lifecycle.py +0 -66
  436. test/test_operations.py +0 -251
  437. test/test_operations_hatch.py +0 -57
  438. test/test_ruida.py +0 -19
  439. test/test_spooler.py +0 -22
  440. test/test_tools_rasterplotter.py +0 -29
  441. test/test_wobble.py +0 -133
  442. test/test_zingl.py +0 -124
  443. {test → meerk40t/cylinder}/__init__.py +0 -0
  444. /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
  445. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/entry_points.txt +0 -0
@@ -1,538 +1,538 @@
1
- from typing import Any, Callable, Dict, Generator, Optional, Tuple, Union
2
-
3
- from .jobs import ConsoleFunction
4
- from .lifecycles import *
5
-
6
-
7
- class Context:
8
- """
9
- Contexts serve as path-relevant snapshots of the kernel. These are the primary interaction between the modules
10
- and the kernel. They permit getting other contexts of the kernel. This should serve as the primary interface
11
- code between the kernel and the modules.
12
-
13
- Contexts store the persistent settings and settings from at their path locations.
14
-
15
- Contexts have attribute settings located at .<setting> and so long as this setting does not begin with _ it will be
16
- reloaded when .setting() is called for the given attribute. This should be called by code that intends access
17
- an attribute even if it was already called.
18
- """
19
-
20
- def __init__(self, kernel: "Kernel", path: str):
21
- self._kernel = kernel
22
- self._path = path
23
- self._state = "unknown"
24
- self.opened = {}
25
-
26
- def __repr__(self):
27
- return f"Context('{self._path}')"
28
-
29
- def __call__(self, data: str, **kwargs):
30
- if len(data) and data[-1] != "\n":
31
- data += "\n"
32
- return self._kernel.console(data)
33
-
34
- # ==========
35
- # PATH INFORMATION
36
- # ==========
37
-
38
- def abs_path(self, subpath: str) -> str:
39
- """
40
- The absolute path function determines the absolute path of the given subpath within the current path of the
41
- context.
42
-
43
- @param subpath: relative path to the path at this context
44
- @return:
45
- """
46
- subpath = str(subpath)
47
- if subpath.startswith("/"):
48
- return subpath[1:]
49
- if self._path is None or self._path == "/":
50
- return subpath
51
- return f"{self._path}/{subpath}"
52
-
53
- def derive(self, path: str) -> "Context":
54
- """
55
- Derive a subpath context.
56
-
57
- @param path:
58
- @return:
59
- """
60
- return self._kernel.get_context(self.abs_path(path))
61
-
62
- @property
63
- def root(self) -> "Context":
64
- return self.get_context("/")
65
-
66
- @property
67
- def path(self) -> str:
68
- return self._path
69
-
70
- @property
71
- def kernel(self) -> "Kernel":
72
- return self._kernel
73
-
74
- @property
75
- def _(self):
76
- return self._kernel.translation
77
-
78
- def get_context(self, path) -> "Context":
79
- """
80
- Get a context at a given path location.
81
-
82
- @param path: path location to get a context.
83
- @return:
84
- """
85
- return self._kernel.get_context(path)
86
-
87
- def subpaths(self) -> Generator["Context", None, None]:
88
- """
89
- Generate all subpaths of the current context with their path name and the relevant context.
90
- """
91
- for e in list(self._kernel.contexts):
92
- if e.startswith(self._path):
93
- yield e, self._kernel.contexts[e]
94
-
95
- def close_subpaths(self) -> None:
96
- """
97
- Find all subpaths of the current context and delete them.
98
-
99
- This is not a maintenance operation. It's needed for rare instances during shutdown. All contexts will be
100
- shutdown, this prevents normal shutdown procedure.
101
- """
102
- for e in list(self._kernel.contexts):
103
- if e.startswith(self._path):
104
- del self._kernel.contexts[e]
105
-
106
- def destroy(self):
107
- self.clear_persistent()
108
- self.close_subpaths()
109
-
110
- # ==========
111
- # PERSISTENT SETTINGS.
112
- # ==========
113
-
114
- def setting(self, setting_type, key, default=None) -> Any:
115
- """
116
- Registers a setting to be used between modules.
117
-
118
- If the setting exists, its value remains unchanged.
119
- If the setting exists in the persistent storage that value is used.
120
- If there is no settings value, the default will be used.
121
-
122
- @param setting_type: int, float, str, bool, list or tuple value
123
- @param key: name of the setting
124
- @param default: default value for the setting to have.
125
- @return: load_value
126
- """
127
- if hasattr(self, key) and getattr(self, key) is not None:
128
- return getattr(self, key)
129
-
130
- # Key is not located in the attr. Load the value.
131
- if not key.startswith("_"):
132
- load_value = self._kernel.read_persistent(
133
- setting_type, self._path, key, default
134
- )
135
- else:
136
- load_value = default
137
- if load_value is not None and not isinstance(load_value, setting_type):
138
- load_value = setting_type(load_value)
139
- setattr(self, key, load_value)
140
- return load_value
141
-
142
- def flush(self) -> None:
143
- """
144
- Commit any and all values currently stored as attr for this object to persistent storage.
145
- """
146
- self._kernel.write_persistent_attributes(self._path, self)
147
-
148
- def write_persistent_attributes(self, obj: Any) -> None:
149
- """
150
- Writes values of the object's attributes at this context
151
- @param obj:
152
- @return:
153
- """
154
- self._kernel.write_persistent_attributes(self._path, obj)
155
-
156
- def read_persistent(self, t: type, key: str) -> Any:
157
- """
158
- Gets a specific value of the persistent attributes.
159
-
160
- The attribute type of the value depends on the provided object value default values.
161
-
162
- @param t: type of value
163
- @param key: relative key
164
- @return: the value associated with the key otherwise None
165
- """
166
- return self._kernel.read_persistent(t, self._path, key)
167
-
168
- def read_persistent_attributes(self, obj: Any) -> None:
169
- """
170
- Loads values of the persistent attributes, at this context and assigns them to the provided object.
171
-
172
- The attribute type of the value depends on the provided object value default values.
173
-
174
- @param obj:
175
- @return:
176
- """
177
- self._kernel.read_persistent_attributes(self._path, obj)
178
-
179
- def read_persistent_string_dict(
180
- self, dictionary: Optional[Dict] = None, suffix: bool = False
181
- ) -> Dict:
182
- """
183
- Delegate to kernel to get a local string of dictionary values.
184
-
185
- @param dictionary: optional dictionary to be updated with values
186
- @param suffix:
187
- @return:
188
- """
189
- return self._kernel.read_persistent_string_dict(
190
- self._path, dictionary=dictionary, suffix=suffix
191
- )
192
-
193
- def clear_persistent(self) -> None:
194
- """
195
- Delegate to Kernel to clear the persistent settings located at this context.
196
- """
197
- self._kernel.clear_persistent(self._path)
198
-
199
- def write_persistent(
200
- self, key: str, value: Union[int, float, str, bool, list, tuple]
201
- ) -> None:
202
- """
203
- Delegate to Kernel to write the given key at this context to persistent settings. This is typically done during
204
- shutdown but there are a variety of reasons to force this call early.
205
-
206
- If the persistence object is not yet established this function cannot succeed.
207
- """
208
- self._kernel.write_persistent(self._path, key, value)
209
-
210
- # ==========
211
- # DELEGATES
212
- # ==========
213
-
214
- def register(self, path: str, obj: Any) -> None:
215
- """
216
- Delegate to Kernel
217
- """
218
- self._kernel.register(path, obj)
219
-
220
- def unregister(self, path: str) -> None:
221
- """
222
- Delegate to Kernel
223
- """
224
- self._kernel.unregister(path)
225
-
226
- def console_argument(self, *args, **kwargs) -> Callable:
227
- """
228
- Delegate to Kernel
229
-
230
- Uses current context to be passed to the console_argument being registered.
231
- """
232
- return self._kernel.console_argument(*args, **kwargs)
233
-
234
- def console_option(self, *args, **kwargs) -> Callable:
235
- """
236
- Delegate to Kernel
237
-
238
- Uses current context to be passed to the console_option being registered.
239
- """
240
- return self._kernel.console_option(*args, **kwargs)
241
-
242
- def console_command(self, *args, **kwargs) -> Callable:
243
- """
244
- Delegate to Kernel
245
-
246
- Uses current context to be passed to the console_command being registered.
247
- """
248
- return self._kernel.console_command(*args, **kwargs)
249
-
250
- def console_command_remove(self, *args, **kwargs) -> Callable:
251
- """
252
- Delegate to Kernel
253
-
254
- Uses current context to be passed to the console_command being removed.
255
- """
256
- return self._kernel.console_command_remove(*args, **kwargs)
257
-
258
- @property
259
- def contexts(self) -> Dict[str, "Context"]:
260
- return self._kernel.contexts
261
-
262
- def has_feature(self, feature: str) -> bool:
263
- """
264
- Return whether this is a registered feature within the kernel.
265
-
266
- @param feature: feature to check if exists in kernel.
267
- @return:
268
- """
269
- return self.lookup(feature) is not None
270
-
271
- def find(self, *args):
272
- """
273
- Delegate of Kernel match.
274
-
275
- @param args: arguments to be delegated
276
- :yield: matched entries.
277
- """
278
- yield from self._kernel.find(*args)
279
-
280
- def match(self, matchtext: str, suffix: bool = False) -> Generator[str, None, None]:
281
- """
282
- Delegate of Kernel match.
283
-
284
- @param matchtext: regex matchtext to locate.
285
- @param suffix: provide the suffix of the match only.
286
- :yield: matched entries.
287
- """
288
- yield from self._kernel.match(matchtext, suffix)
289
-
290
- def lookup(self, *args) -> Any:
291
- """
292
- Lookup a value in the kernel or services.
293
-
294
- @param args: arguments
295
- @return:
296
- """
297
- return self._kernel.lookup(*args)
298
-
299
- def lookup_all(self, *args) -> Any:
300
- """
301
- Lookup all matching values in the kernel or services.
302
-
303
- @param args: arguments
304
- @return:
305
- """
306
- yield from self._kernel.lookup_all(*args)
307
-
308
- def console(self, data: str) -> None:
309
- """
310
- Call the Kernel's Console with the given data.
311
-
312
- Note: '\n' is usually used to execute these functions and this is not added by default.
313
- """
314
- self._kernel.console(data)
315
-
316
- def schedule(self, job: Union["Job", Any]) -> None:
317
- """
318
- Call the Kernel's Scheduler with the given job.
319
- """
320
- self._kernel.schedule(job)
321
-
322
- def unschedule(self, job: Union["Job", Any]) -> None:
323
- """
324
- Unschedule a given job.
325
-
326
- This is often unneeded if the job completes on its own, it will be removed from the scheduler.
327
- """
328
- self._kernel.unschedule(job)
329
-
330
- def threaded(
331
- self,
332
- func: Callable,
333
- *args,
334
- thread_name: str = None,
335
- result: Callable = None,
336
- daemon: bool = False,
337
- ):
338
- """
339
- Calls a thread to be registered in the kernel.
340
-
341
- Registered threads must complete before shutdown can be completed. These will be told to stop and waited on until
342
- completion.
343
-
344
- The result function will be called with any returned result func.
345
- """
346
- return self._kernel.threaded(
347
- func,
348
- *args,
349
- thread_name=thread_name,
350
- result=result,
351
- daemon=daemon,
352
- )
353
-
354
- # ==========
355
- # MODULES
356
- # ==========
357
-
358
- def get_open(self, path: str) -> Union["Module", None]:
359
- """
360
- Finds a loaded instance. Or returns None if not such instance.
361
-
362
- Note: 'name' is not necessarily the type of instance. It could be the named value of the instance.
363
-
364
- @param path: The opened path to find the given instance.
365
- @return: The instance, if found, otherwise None.
366
- """
367
- try:
368
- return self.opened[path]
369
- except KeyError:
370
- return None
371
-
372
- def open(self, registered_path: str, *args, **kwargs) -> "Module":
373
- """
374
- Opens a registered module with the same instance path as the registered path.
375
-
376
- This is fairly standard but should not be used if the goal would be to open the same module several times.
377
- Unless those modules are being opened at different contexts.
378
-
379
- @param registered_path: registered path of the given module.
380
- @param args: args to open the module with.
381
- @param kwargs: kwargs to open the module with.
382
- @return:
383
- """
384
- return self.open_as(registered_path, registered_path, *args, **kwargs)
385
-
386
- def open_as(
387
- self, registered_path: str, instance_path: str, *args, **kwargs
388
- ) -> "Module":
389
- """
390
- Opens a registered module. If that module already exists it returns the already open module.
391
-
392
- Instance_name is the name under which this given module is opened.
393
-
394
- If the module already exists, the restore function is called on that object (if restore() exists), with the same
395
- args and kwargs that were intended for the init() routine.
396
-
397
- @param registered_path: path of object being opened.
398
- @param instance_path: instance_path of object.
399
- @param args: Args to pass to newly opened module.
400
- @param kwargs: Kwargs to pass to newly opened module.
401
- @return: Opened module.
402
- """
403
- try:
404
- find = self.opened[instance_path]
405
- try:
406
- # Module found, attempt restore call.
407
- find.restore(*args, **kwargs)
408
- except AttributeError:
409
- pass
410
- return find
411
- except KeyError:
412
- # Module not found.
413
- pass
414
-
415
- open_object = self._kernel.lookup(registered_path)
416
- if open_object is None:
417
- raise ValueError
418
-
419
- instance = open_object(self, instance_path, *args, **kwargs)
420
- instance.registered_path = registered_path
421
- self._module_delegate(instance)
422
-
423
- # Call module_open lifecycle event.
424
- self.kernel.set_module_lifecycle(instance, LIFECYCLE_MODULE_OPENED)
425
-
426
- return instance
427
-
428
- def _module_delegate(self, module, model=None, add=True):
429
- """
430
- Recursively find any delegates for a module yielded under `.delegate()`
431
- @param module:
432
- @param model:
433
- @param add:
434
- @return:
435
- """
436
- kernel = self.kernel
437
- if model is None:
438
- model = module
439
-
440
- try:
441
- if model is not module:
442
- # We are the model we don't delegate to it.
443
- if add:
444
- kernel.add_delegate(model, module)
445
- else:
446
- kernel.remove_delegate(model, module)
447
- for delegate in model.delegates():
448
- self._module_delegate(module=module, model=delegate, add=add)
449
- except AttributeError:
450
- pass
451
-
452
- def close(self, instance_path: str, *args, **kwargs) -> None:
453
- """
454
- Closes an opened module instance. Located at the instance_path location.
455
-
456
- This calls the close() function on the object (which may not exist). Then calls module_close() on the module,
457
- which should exist.
458
-
459
- @param instance_path: Instance path to close.
460
- @return:
461
- """
462
- try:
463
- instance = self.opened[instance_path]
464
- except KeyError:
465
- return # Nothing to close.
466
- # Call module_close lifecycle event.
467
- self.kernel.set_module_lifecycle(instance, LIFECYCLE_MODULE_CLOSED)
468
-
469
- # ==========
470
- # SIGNALS DELEGATES
471
- # ==========
472
-
473
- def signal(self, code: str, *message) -> None:
474
- """
475
- Send Signal to all registered listeners.
476
-
477
- @param code: Code to delegate at this given context location.
478
- @param message: Message to send.
479
- @return:
480
- """
481
- self._kernel.signal(code, self._path, *message)
482
-
483
- def last_signal(self, signal: str) -> Tuple:
484
- """
485
- Returns the last signal payload at the given code.
486
-
487
- @param signal: Code to delegate at this given context location.
488
- @return: message value of the last signal sent for that code.
489
- """
490
- return self._kernel.last_signal(signal)
491
-
492
- def listen(
493
- self,
494
- signal: str,
495
- process: Callable,
496
- lifecycle_object: Union["Service", "Module", None] = None,
497
- ) -> None:
498
- """
499
- Listen at a particular signal with a given process.
500
-
501
- @param signal: Signal code to listen for
502
- @param process: listener to be attached
503
- @param lifecycle_object: Object to use as a cookie to bind the listener.
504
- @return:
505
- """
506
- self._kernel.listen(signal, process, lifecycle_object)
507
-
508
- def unlisten(self, signal: str, process: Callable):
509
- """
510
- Unlisten to a particular signal with a given process.
511
-
512
- This should be called on the ending of the lifecycle of whatever process listened to the given signal.
513
-
514
- @param signal: Signal to unlisten for.
515
- @param process: listener that is to be detached.
516
- @return:
517
- """
518
- self._kernel.unlisten(signal, process)
519
-
520
- # ==========
521
- # CHANNEL DELEGATES
522
- # ==========
523
-
524
- def channel(self, channel: str, *args, **kwargs) -> "Channel":
525
- """
526
- Return a channel from the kernel location
527
-
528
- @param channel: Channel to be opened.
529
- @return: Channel object that is opened.
530
- """
531
- return self._kernel.channel(channel, *args, **kwargs)
532
-
533
- def console_function(self, data: str) -> "ConsoleFunction":
534
- """
535
- Returns a function that calls a console command. This serves as a Job to be used in Scheduler or simply a
536
- function with the command as the str form.
537
- """
538
- return ConsoleFunction(self, data)
1
+ from typing import Any, Callable, Dict, Generator, Optional, Tuple, Union
2
+
3
+ from .jobs import ConsoleFunction
4
+ from .lifecycles import *
5
+
6
+
7
+ class Context:
8
+ """
9
+ Contexts serve as path-relevant snapshots of the kernel. These are the primary interaction between the modules
10
+ and the kernel. They permit getting other contexts of the kernel. This should serve as the primary interface
11
+ code between the kernel and the modules.
12
+
13
+ Contexts store the persistent settings and settings from at their path locations.
14
+
15
+ Contexts have attribute settings located at .<setting> and so long as this setting does not begin with _ it will be
16
+ reloaded when .setting() is called for the given attribute. This should be called by code that intends access
17
+ an attribute even if it was already called.
18
+ """
19
+
20
+ def __init__(self, kernel: "Kernel", path: str):
21
+ self._kernel = kernel
22
+ self._path = path
23
+ self._state = "unknown"
24
+ self.opened = {}
25
+
26
+ def __repr__(self):
27
+ return f"Context('{self._path}')"
28
+
29
+ def __call__(self, data: str, **kwargs):
30
+ if len(data) and data[-1] != "\n":
31
+ data += "\n"
32
+ return self._kernel.console(data)
33
+
34
+ # ==========
35
+ # PATH INFORMATION
36
+ # ==========
37
+
38
+ def abs_path(self, subpath: str) -> str:
39
+ """
40
+ The absolute path function determines the absolute path of the given subpath within the current path of the
41
+ context.
42
+
43
+ @param subpath: relative path to the path at this context
44
+ @return:
45
+ """
46
+ subpath = str(subpath)
47
+ if subpath.startswith("/"):
48
+ return subpath[1:]
49
+ if self._path is None or self._path == "/":
50
+ return subpath
51
+ return f"{self._path}/{subpath}"
52
+
53
+ def derive(self, path: str) -> "Context":
54
+ """
55
+ Derive a subpath context.
56
+
57
+ @param path:
58
+ @return:
59
+ """
60
+ return self._kernel.get_context(self.abs_path(path))
61
+
62
+ @property
63
+ def root(self) -> "Context":
64
+ return self.get_context("/")
65
+
66
+ @property
67
+ def path(self) -> str:
68
+ return self._path
69
+
70
+ @property
71
+ def kernel(self) -> "Kernel":
72
+ return self._kernel
73
+
74
+ @property
75
+ def _(self):
76
+ return self._kernel.translation
77
+
78
+ def get_context(self, path) -> "Context":
79
+ """
80
+ Get a context at a given path location.
81
+
82
+ @param path: path location to get a context.
83
+ @return:
84
+ """
85
+ return self._kernel.get_context(path)
86
+
87
+ def subpaths(self) -> Generator["Context", None, None]:
88
+ """
89
+ Generate all subpaths of the current context with their path name and the relevant context.
90
+ """
91
+ for e in list(self._kernel.contexts):
92
+ if e.startswith(self._path):
93
+ yield e, self._kernel.contexts[e]
94
+
95
+ def close_subpaths(self) -> None:
96
+ """
97
+ Find all subpaths of the current context and delete them.
98
+
99
+ This is not a maintenance operation. It's needed for rare instances during shutdown. All contexts will be
100
+ shutdown, this prevents normal shutdown procedure.
101
+ """
102
+ for e in list(self._kernel.contexts):
103
+ if e.startswith(self._path):
104
+ del self._kernel.contexts[e]
105
+
106
+ def destroy(self):
107
+ self.clear_persistent()
108
+ self.close_subpaths()
109
+
110
+ # ==========
111
+ # PERSISTENT SETTINGS.
112
+ # ==========
113
+
114
+ def setting(self, setting_type, key, default=None) -> Any:
115
+ """
116
+ Registers a setting to be used between modules.
117
+
118
+ If the setting exists, its value remains unchanged.
119
+ If the setting exists in the persistent storage that value is used.
120
+ If there is no settings value, the default will be used.
121
+
122
+ @param setting_type: int, float, str, bool, list or tuple value
123
+ @param key: name of the setting
124
+ @param default: default value for the setting to have.
125
+ @return: load_value
126
+ """
127
+ if hasattr(self, key) and getattr(self, key) is not None:
128
+ return getattr(self, key)
129
+
130
+ # Key is not located in the attr. Load the value.
131
+ if not key.startswith("_"):
132
+ load_value = self._kernel.read_persistent(
133
+ setting_type, self._path, key, default
134
+ )
135
+ else:
136
+ load_value = default
137
+ if load_value is not None and not isinstance(load_value, setting_type):
138
+ load_value = setting_type(load_value)
139
+ setattr(self, key, load_value)
140
+ return load_value
141
+
142
+ def flush(self) -> None:
143
+ """
144
+ Commit any and all values currently stored as attr for this object to persistent storage.
145
+ """
146
+ self._kernel.write_persistent_attributes(self._path, self)
147
+
148
+ def write_persistent_attributes(self, obj: Any) -> None:
149
+ """
150
+ Writes values of the object's attributes at this context
151
+ @param obj:
152
+ @return:
153
+ """
154
+ self._kernel.write_persistent_attributes(self._path, obj)
155
+
156
+ def read_persistent(self, t: type, key: str) -> Any:
157
+ """
158
+ Gets a specific value of the persistent attributes.
159
+
160
+ The attribute type of the value depends on the provided object value default values.
161
+
162
+ @param t: type of value
163
+ @param key: relative key
164
+ @return: the value associated with the key otherwise None
165
+ """
166
+ return self._kernel.read_persistent(t, self._path, key)
167
+
168
+ def read_persistent_attributes(self, obj: Any) -> None:
169
+ """
170
+ Loads values of the persistent attributes, at this context and assigns them to the provided object.
171
+
172
+ The attribute type of the value depends on the provided object value default values.
173
+
174
+ @param obj:
175
+ @return:
176
+ """
177
+ self._kernel.read_persistent_attributes(self._path, obj)
178
+
179
+ def read_persistent_string_dict(
180
+ self, dictionary: Optional[Dict] = None, suffix: bool = False
181
+ ) -> Dict:
182
+ """
183
+ Delegate to kernel to get a local string of dictionary values.
184
+
185
+ @param dictionary: optional dictionary to be updated with values
186
+ @param suffix:
187
+ @return:
188
+ """
189
+ return self._kernel.read_persistent_string_dict(
190
+ self._path, dictionary=dictionary, suffix=suffix
191
+ )
192
+
193
+ def clear_persistent(self) -> None:
194
+ """
195
+ Delegate to Kernel to clear the persistent settings located at this context.
196
+ """
197
+ self._kernel.clear_persistent(self._path)
198
+
199
+ def write_persistent(
200
+ self, key: str, value: Union[int, float, str, bool, list, tuple]
201
+ ) -> None:
202
+ """
203
+ Delegate to Kernel to write the given key at this context to persistent settings. This is typically done during
204
+ shutdown but there are a variety of reasons to force this call early.
205
+
206
+ If the persistence object is not yet established this function cannot succeed.
207
+ """
208
+ self._kernel.write_persistent(self._path, key, value)
209
+
210
+ # ==========
211
+ # DELEGATES
212
+ # ==========
213
+
214
+ def register(self, path: str, obj: Any) -> None:
215
+ """
216
+ Delegate to Kernel
217
+ """
218
+ self._kernel.register(path, obj)
219
+
220
+ def unregister(self, path: str) -> None:
221
+ """
222
+ Delegate to Kernel
223
+ """
224
+ self._kernel.unregister(path)
225
+
226
+ def console_argument(self, *args, **kwargs) -> Callable:
227
+ """
228
+ Delegate to Kernel
229
+
230
+ Uses current context to be passed to the console_argument being registered.
231
+ """
232
+ return self._kernel.console_argument(*args, **kwargs)
233
+
234
+ def console_option(self, *args, **kwargs) -> Callable:
235
+ """
236
+ Delegate to Kernel
237
+
238
+ Uses current context to be passed to the console_option being registered.
239
+ """
240
+ return self._kernel.console_option(*args, **kwargs)
241
+
242
+ def console_command(self, *args, **kwargs) -> Callable:
243
+ """
244
+ Delegate to Kernel
245
+
246
+ Uses current context to be passed to the console_command being registered.
247
+ """
248
+ return self._kernel.console_command(*args, **kwargs)
249
+
250
+ def console_command_remove(self, *args, **kwargs) -> Callable:
251
+ """
252
+ Delegate to Kernel
253
+
254
+ Uses current context to be passed to the console_command being removed.
255
+ """
256
+ return self._kernel.console_command_remove(*args, **kwargs)
257
+
258
+ @property
259
+ def contexts(self) -> Dict[str, "Context"]:
260
+ return self._kernel.contexts
261
+
262
+ def has_feature(self, feature: str) -> bool:
263
+ """
264
+ Return whether this is a registered feature within the kernel.
265
+
266
+ @param feature: feature to check if exists in kernel.
267
+ @return:
268
+ """
269
+ return self.lookup(feature) is not None
270
+
271
+ def find(self, *args):
272
+ """
273
+ Delegate of Kernel match.
274
+
275
+ @param args: arguments to be delegated
276
+ :yield: matched entries.
277
+ """
278
+ yield from self._kernel.find(*args)
279
+
280
+ def match(self, matchtext: str, suffix: bool = False) -> Generator[str, None, None]:
281
+ """
282
+ Delegate of Kernel match.
283
+
284
+ @param matchtext: regex matchtext to locate.
285
+ @param suffix: provide the suffix of the match only.
286
+ :yield: matched entries.
287
+ """
288
+ yield from self._kernel.match(matchtext, suffix)
289
+
290
+ def lookup(self, *args) -> Any:
291
+ """
292
+ Lookup a value in the kernel or services.
293
+
294
+ @param args: arguments
295
+ @return:
296
+ """
297
+ return self._kernel.lookup(*args)
298
+
299
+ def lookup_all(self, *args) -> Any:
300
+ """
301
+ Lookup all matching values in the kernel or services.
302
+
303
+ @param args: arguments
304
+ @return:
305
+ """
306
+ yield from self._kernel.lookup_all(*args)
307
+
308
+ def console(self, data: str) -> None:
309
+ """
310
+ Call the Kernel's Console with the given data.
311
+
312
+ Note: '\n' is usually used to execute these functions and this is not added by default.
313
+ """
314
+ self._kernel.console(data)
315
+
316
+ def schedule(self, job: Union["Job", Any]) -> None:
317
+ """
318
+ Call the Kernel's Scheduler with the given job.
319
+ """
320
+ self._kernel.schedule(job)
321
+
322
+ def unschedule(self, job: Union["Job", Any]) -> None:
323
+ """
324
+ Unschedule a given job.
325
+
326
+ This is often unneeded if the job completes on its own, it will be removed from the scheduler.
327
+ """
328
+ self._kernel.unschedule(job)
329
+
330
+ def threaded(
331
+ self,
332
+ func: Callable,
333
+ *args,
334
+ thread_name: str = None,
335
+ result: Callable = None,
336
+ daemon: bool = False,
337
+ ):
338
+ """
339
+ Calls a thread to be registered in the kernel.
340
+
341
+ Registered threads must complete before shutdown can be completed. These will be told to stop and waited on until
342
+ completion.
343
+
344
+ The result function will be called with any returned result func.
345
+ """
346
+ return self._kernel.threaded(
347
+ func,
348
+ *args,
349
+ thread_name=thread_name,
350
+ result=result,
351
+ daemon=daemon,
352
+ )
353
+
354
+ # ==========
355
+ # MODULES
356
+ # ==========
357
+
358
+ def get_open(self, path: str) -> Union["Module", None]:
359
+ """
360
+ Finds a loaded instance. Or returns None if not such instance.
361
+
362
+ Note: 'name' is not necessarily the type of instance. It could be the named value of the instance.
363
+
364
+ @param path: The opened path to find the given instance.
365
+ @return: The instance, if found, otherwise None.
366
+ """
367
+ try:
368
+ return self.opened[path]
369
+ except KeyError:
370
+ return None
371
+
372
+ def open(self, registered_path: str, *args, **kwargs) -> "Module":
373
+ """
374
+ Opens a registered module with the same instance path as the registered path.
375
+
376
+ This is fairly standard but should not be used if the goal would be to open the same module several times.
377
+ Unless those modules are being opened at different contexts.
378
+
379
+ @param registered_path: registered path of the given module.
380
+ @param args: args to open the module with.
381
+ @param kwargs: kwargs to open the module with.
382
+ @return:
383
+ """
384
+ return self.open_as(registered_path, registered_path, *args, **kwargs)
385
+
386
+ def open_as(
387
+ self, registered_path: str, instance_path: str, *args, **kwargs
388
+ ) -> "Module":
389
+ """
390
+ Opens a registered module. If that module already exists it returns the already open module.
391
+
392
+ Instance_name is the name under which this given module is opened.
393
+
394
+ If the module already exists, the restore function is called on that object (if restore() exists), with the same
395
+ args and kwargs that were intended for the init() routine.
396
+
397
+ @param registered_path: path of object being opened.
398
+ @param instance_path: instance_path of object.
399
+ @param args: Args to pass to newly opened module.
400
+ @param kwargs: Kwargs to pass to newly opened module.
401
+ @return: Opened module.
402
+ """
403
+ try:
404
+ find = self.opened[instance_path]
405
+ try:
406
+ # Module found, attempt restore call.
407
+ find.restore(*args, **kwargs)
408
+ except AttributeError:
409
+ pass
410
+ return find
411
+ except KeyError:
412
+ # Module not found.
413
+ pass
414
+
415
+ open_object = self._kernel.lookup(registered_path)
416
+ if open_object is None:
417
+ raise ValueError
418
+
419
+ instance = open_object(self, instance_path, *args, **kwargs)
420
+ instance.registered_path = registered_path
421
+ self._module_delegate(instance)
422
+
423
+ # Call module_open lifecycle event.
424
+ self.kernel.set_module_lifecycle(instance, LIFECYCLE_MODULE_OPENED)
425
+
426
+ return instance
427
+
428
+ def _module_delegate(self, module, model=None, add=True):
429
+ """
430
+ Recursively find any delegates for a module yielded under `.delegate()`
431
+ @param module:
432
+ @param model:
433
+ @param add:
434
+ @return:
435
+ """
436
+ kernel = self.kernel
437
+ if model is None:
438
+ model = module
439
+
440
+ try:
441
+ if model is not module:
442
+ # We are the model we don't delegate to it.
443
+ if add:
444
+ kernel.add_delegate(model, module)
445
+ else:
446
+ kernel.remove_delegate(model, module)
447
+ for delegate in model.delegates():
448
+ self._module_delegate(module=module, model=delegate, add=add)
449
+ except AttributeError:
450
+ pass
451
+
452
+ def close(self, instance_path: str, *args, **kwargs) -> None:
453
+ """
454
+ Closes an opened module instance. Located at the instance_path location.
455
+
456
+ This calls the close() function on the object (which may not exist). Then calls module_close() on the module,
457
+ which should exist.
458
+
459
+ @param instance_path: Instance path to close.
460
+ @return:
461
+ """
462
+ try:
463
+ instance = self.opened[instance_path]
464
+ except KeyError:
465
+ return # Nothing to close.
466
+ # Call module_close lifecycle event.
467
+ self.kernel.set_module_lifecycle(instance, LIFECYCLE_MODULE_CLOSED)
468
+
469
+ # ==========
470
+ # SIGNALS DELEGATES
471
+ # ==========
472
+
473
+ def signal(self, code: str, *message) -> None:
474
+ """
475
+ Send Signal to all registered listeners.
476
+
477
+ @param code: Code to delegate at this given context location.
478
+ @param message: Message to send.
479
+ @return:
480
+ """
481
+ self._kernel.signal(code, self._path, *message)
482
+
483
+ def last_signal(self, signal: str) -> Tuple:
484
+ """
485
+ Returns the last signal payload at the given code.
486
+
487
+ @param signal: Code to delegate at this given context location.
488
+ @return: message value of the last signal sent for that code.
489
+ """
490
+ return self._kernel.last_signal(signal)
491
+
492
+ def listen(
493
+ self,
494
+ signal: str,
495
+ process: Callable,
496
+ lifecycle_object: Union["Service", "Module", None] = None,
497
+ ) -> None:
498
+ """
499
+ Listen at a particular signal with a given process.
500
+
501
+ @param signal: Signal code to listen for
502
+ @param process: listener to be attached
503
+ @param lifecycle_object: Object to use as a cookie to bind the listener.
504
+ @return:
505
+ """
506
+ self._kernel.listen(signal, process, lifecycle_object)
507
+
508
+ def unlisten(self, signal: str, process: Callable):
509
+ """
510
+ Unlisten to a particular signal with a given process.
511
+
512
+ This should be called on the ending of the lifecycle of whatever process listened to the given signal.
513
+
514
+ @param signal: Signal to unlisten for.
515
+ @param process: listener that is to be detached.
516
+ @return:
517
+ """
518
+ self._kernel.unlisten(signal, process)
519
+
520
+ # ==========
521
+ # CHANNEL DELEGATES
522
+ # ==========
523
+
524
+ def channel(self, channel: str, *args, **kwargs) -> "Channel":
525
+ """
526
+ Return a channel from the kernel location
527
+
528
+ @param channel: Channel to be opened.
529
+ @return: Channel object that is opened.
530
+ """
531
+ return self._kernel.channel(channel, *args, **kwargs)
532
+
533
+ def console_function(self, data: str) -> "ConsoleFunction":
534
+ """
535
+ Returns a function that calls a console command. This serves as a Job to be used in Scheduler or simply a
536
+ function with the command as the str form.
537
+ """
538
+ return ConsoleFunction(self, data)