arctrl 3.0.0a3__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 (456) hide show
  1. arctrl/__init__.py +18 -0
  2. arctrl/py/CWL/__init__.py +0 -0
  3. arctrl/py/CWL/cwltypes.py +150 -0
  4. arctrl/py/CWL/decode.py +973 -0
  5. arctrl/py/CWL/encode.py +1 -0
  6. arctrl/py/CWL/inputs.py +88 -0
  7. arctrl/py/CWL/outputs.py +85 -0
  8. arctrl/py/CWL/requirements.py +77 -0
  9. arctrl/py/CWL/tool_description.py +103 -0
  10. arctrl/py/CWL/workflow_description.py +104 -0
  11. arctrl/py/CWL/workflow_steps.py +113 -0
  12. arctrl/py/Contract/__init__.py +0 -0
  13. arctrl/py/Contract/arc.py +60 -0
  14. arctrl/py/Contract/arc_assay.py +125 -0
  15. arctrl/py/Contract/arc_investigation.py +88 -0
  16. arctrl/py/Contract/arc_run.py +125 -0
  17. arctrl/py/Contract/arc_study.py +126 -0
  18. arctrl/py/Contract/arc_workflow.py +125 -0
  19. arctrl/py/Contract/contract.py +153 -0
  20. arctrl/py/Contract/datamap.py +372 -0
  21. arctrl/py/Contract/git.py +118 -0
  22. arctrl/py/Contract/validation_packages_config.py +107 -0
  23. arctrl/py/ContractIO/__init__.py +0 -0
  24. arctrl/py/ContractIO/contract_io.py +344 -0
  25. arctrl/py/ContractIO/file_system_helper.py +264 -0
  26. arctrl/py/Core/Helper/__init__.py +0 -0
  27. arctrl/py/Core/Helper/collections_.py +438 -0
  28. arctrl/py/Core/Helper/date_time.py +26 -0
  29. arctrl/py/Core/Helper/hash_codes.py +60 -0
  30. arctrl/py/Core/Helper/identifier.py +248 -0
  31. arctrl/py/Core/Helper/orcid.py +42 -0
  32. arctrl/py/Core/Helper/printer.py +13 -0
  33. arctrl/py/Core/Helper/regex.py +554 -0
  34. arctrl/py/Core/Helper/sem_ver.py +71 -0
  35. arctrl/py/Core/Helper/url.py +148 -0
  36. arctrl/py/Core/Process/__init__.py +0 -0
  37. arctrl/py/Core/Process/column_index.py +280 -0
  38. arctrl/py/Core/Process/component.py +200 -0
  39. arctrl/py/Core/Process/factor.py +151 -0
  40. arctrl/py/Core/Process/factor_value.py +182 -0
  41. arctrl/py/Core/Process/material.py +74 -0
  42. arctrl/py/Core/Process/material_attribute.py +95 -0
  43. arctrl/py/Core/Process/material_attribute_value.py +184 -0
  44. arctrl/py/Core/Process/material_type.py +45 -0
  45. arctrl/py/Core/Process/process.py +477 -0
  46. arctrl/py/Core/Process/process_input.py +265 -0
  47. arctrl/py/Core/Process/process_output.py +235 -0
  48. arctrl/py/Core/Process/process_parameter_value.py +200 -0
  49. arctrl/py/Core/Process/process_sequence.py +435 -0
  50. arctrl/py/Core/Process/protocol.py +175 -0
  51. arctrl/py/Core/Process/protocol_parameter.py +98 -0
  52. arctrl/py/Core/Process/sample.py +82 -0
  53. arctrl/py/Core/Process/source.py +62 -0
  54. arctrl/py/Core/Table/__init__.py +0 -0
  55. arctrl/py/Core/Table/arc_table.py +1264 -0
  56. arctrl/py/Core/Table/arc_table_aux.py +575 -0
  57. arctrl/py/Core/Table/arc_tables.py +591 -0
  58. arctrl/py/Core/Table/composite_cell.py +319 -0
  59. arctrl/py/Core/Table/composite_column.py +73 -0
  60. arctrl/py/Core/Table/composite_header.py +739 -0
  61. arctrl/py/Core/__init__.py +0 -0
  62. arctrl/py/Core/arc_types.py +5064 -0
  63. arctrl/py/Core/comment.py +128 -0
  64. arctrl/py/Core/comment_list.py +127 -0
  65. arctrl/py/Core/conversion.py +1313 -0
  66. arctrl/py/Core/data.py +245 -0
  67. arctrl/py/Core/data_context.py +157 -0
  68. arctrl/py/Core/data_file.py +112 -0
  69. arctrl/py/Core/data_map.py +225 -0
  70. arctrl/py/Core/identifier_setters.py +31 -0
  71. arctrl/py/Core/iproperty_value.py +36 -0
  72. arctrl/py/Core/ontology_annotation.py +299 -0
  73. arctrl/py/Core/ontology_source_reference.py +114 -0
  74. arctrl/py/Core/person.py +259 -0
  75. arctrl/py/Core/publication.py +161 -0
  76. arctrl/py/Core/template.py +231 -0
  77. arctrl/py/Core/templates.py +148 -0
  78. arctrl/py/Core/uri.py +11 -0
  79. arctrl/py/Core/value.py +188 -0
  80. arctrl/py/FileSystem/__init__.py +0 -0
  81. arctrl/py/FileSystem/commit.py +21 -0
  82. arctrl/py/FileSystem/default_gitattributes.py +5 -0
  83. arctrl/py/FileSystem/default_gitignore.py +5 -0
  84. arctrl/py/FileSystem/file_system.py +58 -0
  85. arctrl/py/FileSystem/file_system_tree.py +426 -0
  86. arctrl/py/FileSystem/path.py +64 -0
  87. arctrl/py/Json/DataMap/__init__.py +0 -0
  88. arctrl/py/Json/DataMap/data_context.py +101 -0
  89. arctrl/py/Json/DataMap/data_map.py +53 -0
  90. arctrl/py/Json/Process/__init__.py +0 -0
  91. arctrl/py/Json/Process/assay_materials.py +46 -0
  92. arctrl/py/Json/Process/component.py +79 -0
  93. arctrl/py/Json/Process/factor.py +107 -0
  94. arctrl/py/Json/Process/factor_value.py +101 -0
  95. arctrl/py/Json/Process/material.py +226 -0
  96. arctrl/py/Json/Process/material_attribute.py +79 -0
  97. arctrl/py/Json/Process/material_attribute_value.py +101 -0
  98. arctrl/py/Json/Process/material_type.py +53 -0
  99. arctrl/py/Json/Process/process.py +296 -0
  100. arctrl/py/Json/Process/process_input.py +83 -0
  101. arctrl/py/Json/Process/process_output.py +67 -0
  102. arctrl/py/Json/Process/process_parameter_value.py +81 -0
  103. arctrl/py/Json/Process/protocol.py +354 -0
  104. arctrl/py/Json/Process/protocol_parameter.py +79 -0
  105. arctrl/py/Json/Process/sample.py +277 -0
  106. arctrl/py/Json/Process/source.py +214 -0
  107. arctrl/py/Json/Process/study_materials.py +52 -0
  108. arctrl/py/Json/Process/value.py +56 -0
  109. arctrl/py/Json/ROCrate/__init__.py +0 -0
  110. arctrl/py/Json/ROCrate/ldcontext.py +133 -0
  111. arctrl/py/Json/ROCrate/ldgraph.py +111 -0
  112. arctrl/py/Json/ROCrate/ldnode.py +290 -0
  113. arctrl/py/Json/ROCrate/ldref.py +44 -0
  114. arctrl/py/Json/ROCrate/ldvalue.py +102 -0
  115. arctrl/py/Json/Table/__init__.py +0 -0
  116. arctrl/py/Json/Table/arc_table.py +393 -0
  117. arctrl/py/Json/Table/cell_table.py +83 -0
  118. arctrl/py/Json/Table/composite_cell.py +136 -0
  119. arctrl/py/Json/Table/composite_header.py +67 -0
  120. arctrl/py/Json/Table/iotype.py +24 -0
  121. arctrl/py/Json/Table/oatable.py +82 -0
  122. arctrl/py/Json/Table/templates.py +281 -0
  123. arctrl/py/Json/__init__.py +0 -0
  124. arctrl/py/Json/assay.py +600 -0
  125. arctrl/py/Json/comment.py +206 -0
  126. arctrl/py/Json/context/rocrate/__init__.py +0 -0
  127. arctrl/py/Json/context/rocrate/isa_assay_context.py +101 -0
  128. arctrl/py/Json/context/rocrate/isa_comment_context.py +60 -0
  129. arctrl/py/Json/context/rocrate/isa_component_context.py +77 -0
  130. arctrl/py/Json/context/rocrate/isa_data_context.py +74 -0
  131. arctrl/py/Json/context/rocrate/isa_factor_context.py +74 -0
  132. arctrl/py/Json/context/rocrate/isa_factor_value_context.py +84 -0
  133. arctrl/py/Json/context/rocrate/isa_investigation_context.py +110 -0
  134. arctrl/py/Json/context/rocrate/isa_material_attribute_context.py +64 -0
  135. arctrl/py/Json/context/rocrate/isa_material_attribute_value_context.py +80 -0
  136. arctrl/py/Json/context/rocrate/isa_material_context.py +71 -0
  137. arctrl/py/Json/context/rocrate/isa_ontology_annotation_context.py +68 -0
  138. arctrl/py/Json/context/rocrate/isa_ontology_source_reference_context.py +75 -0
  139. arctrl/py/Json/context/rocrate/isa_organization_context.py +55 -0
  140. arctrl/py/Json/context/rocrate/isa_person_context.py +131 -0
  141. arctrl/py/Json/context/rocrate/isa_process_context.py +94 -0
  142. arctrl/py/Json/context/rocrate/isa_process_parameter_value_context.py +80 -0
  143. arctrl/py/Json/context/rocrate/isa_protocol_context.py +97 -0
  144. arctrl/py/Json/context/rocrate/isa_protocol_parameter_context.py +64 -0
  145. arctrl/py/Json/context/rocrate/isa_publication_context.py +78 -0
  146. arctrl/py/Json/context/rocrate/isa_sample_context.py +65 -0
  147. arctrl/py/Json/context/rocrate/isa_source_context.py +66 -0
  148. arctrl/py/Json/context/rocrate/isa_study_context.py +125 -0
  149. arctrl/py/Json/context/rocrate/property_value_context.py +73 -0
  150. arctrl/py/Json/context/rocrate/rocrate_context.py +81 -0
  151. arctrl/py/Json/converter_options.py +23 -0
  152. arctrl/py/Json/data.py +356 -0
  153. arctrl/py/Json/data_file.py +63 -0
  154. arctrl/py/Json/decode.py +155 -0
  155. arctrl/py/Json/encode.py +92 -0
  156. arctrl/py/Json/idtable.py +44 -0
  157. arctrl/py/Json/investigation.py +695 -0
  158. arctrl/py/Json/ontology_annotation.py +404 -0
  159. arctrl/py/Json/ontology_source_reference.py +255 -0
  160. arctrl/py/Json/person.py +658 -0
  161. arctrl/py/Json/property_value.py +359 -0
  162. arctrl/py/Json/publication.py +279 -0
  163. arctrl/py/Json/string_table.py +76 -0
  164. arctrl/py/Json/study.py +793 -0
  165. arctrl/py/JsonIO/DataMap/__init__.py +0 -0
  166. arctrl/py/JsonIO/DataMap/data_map.py +53 -0
  167. arctrl/py/JsonIO/Process/__init__.py +0 -0
  168. arctrl/py/JsonIO/Process/component.py +60 -0
  169. arctrl/py/JsonIO/Process/factor.py +36 -0
  170. arctrl/py/JsonIO/Process/factor_value.py +38 -0
  171. arctrl/py/JsonIO/Process/material.py +60 -0
  172. arctrl/py/JsonIO/Process/material_attribute.py +38 -0
  173. arctrl/py/JsonIO/Process/material_attribute_value.py +60 -0
  174. arctrl/py/JsonIO/Process/material_type.py +36 -0
  175. arctrl/py/JsonIO/Process/process.py +60 -0
  176. arctrl/py/JsonIO/Process/process_input.py +38 -0
  177. arctrl/py/JsonIO/Process/process_output.py +60 -0
  178. arctrl/py/JsonIO/Process/process_parameter_value.py +60 -0
  179. arctrl/py/JsonIO/Process/process_sequence.py +71 -0
  180. arctrl/py/JsonIO/Process/protocol.py +60 -0
  181. arctrl/py/JsonIO/Process/protocol_parameter.py +36 -0
  182. arctrl/py/JsonIO/Process/sample.py +60 -0
  183. arctrl/py/JsonIO/Process/source.py +60 -0
  184. arctrl/py/JsonIO/Process/study_materials.py +52 -0
  185. arctrl/py/JsonIO/Process/value.py +32 -0
  186. arctrl/py/JsonIO/Table/__init__.py +0 -0
  187. arctrl/py/JsonIO/Table/arc_table.py +121 -0
  188. arctrl/py/JsonIO/Table/composite_cell.py +36 -0
  189. arctrl/py/JsonIO/Table/composite_header.py +36 -0
  190. arctrl/py/JsonIO/Table/compression.py +85 -0
  191. arctrl/py/JsonIO/Table/iotype.py +36 -0
  192. arctrl/py/JsonIO/Table/templates.py +113 -0
  193. arctrl/py/JsonIO/__init__.py +0 -0
  194. arctrl/py/JsonIO/assay.py +113 -0
  195. arctrl/py/JsonIO/comment.py +80 -0
  196. arctrl/py/JsonIO/data.py +60 -0
  197. arctrl/py/JsonIO/data_file.py +58 -0
  198. arctrl/py/JsonIO/decode.py +9 -0
  199. arctrl/py/JsonIO/encode.py +1 -0
  200. arctrl/py/JsonIO/investigation.py +113 -0
  201. arctrl/py/JsonIO/ldobject.py +106 -0
  202. arctrl/py/JsonIO/ontology_annotation.py +80 -0
  203. arctrl/py/JsonIO/ontology_source_reference.py +80 -0
  204. arctrl/py/JsonIO/person.py +82 -0
  205. arctrl/py/JsonIO/publication.py +82 -0
  206. arctrl/py/JsonIO/study.py +114 -0
  207. arctrl/py/ROCrate/Generic/__init__.py +0 -0
  208. arctrl/py/ROCrate/Generic/comment.py +131 -0
  209. arctrl/py/ROCrate/Generic/dataset.py +817 -0
  210. arctrl/py/ROCrate/Generic/defined_term.py +131 -0
  211. arctrl/py/ROCrate/Generic/file.py +237 -0
  212. arctrl/py/ROCrate/Generic/lab_process.py +324 -0
  213. arctrl/py/ROCrate/Generic/lab_protocol.py +338 -0
  214. arctrl/py/ROCrate/Generic/organization.py +83 -0
  215. arctrl/py/ROCrate/Generic/person.py +484 -0
  216. arctrl/py/ROCrate/Generic/postal_address.py +195 -0
  217. arctrl/py/ROCrate/Generic/property_value.py +696 -0
  218. arctrl/py/ROCrate/Generic/sample.py +202 -0
  219. arctrl/py/ROCrate/Generic/scholarly_article.py +229 -0
  220. arctrl/py/ROCrate/ISAProfile/__init__.py +0 -0
  221. arctrl/py/ROCrate/ISAProfile/assay.py +70 -0
  222. arctrl/py/ROCrate/ISAProfile/data.py +65 -0
  223. arctrl/py/ROCrate/ISAProfile/dataset.py +24 -0
  224. arctrl/py/ROCrate/ISAProfile/investigation.py +73 -0
  225. arctrl/py/ROCrate/ISAProfile/lab_process.py +162 -0
  226. arctrl/py/ROCrate/ISAProfile/lab_protocol.py +37 -0
  227. arctrl/py/ROCrate/ISAProfile/person.py +72 -0
  228. arctrl/py/ROCrate/ISAProfile/property_value.py +98 -0
  229. arctrl/py/ROCrate/ISAProfile/sample.py +64 -0
  230. arctrl/py/ROCrate/ISAProfile/scholarly_article.py +98 -0
  231. arctrl/py/ROCrate/ISAProfile/study.py +74 -0
  232. arctrl/py/ROCrate/__init__.py +0 -0
  233. arctrl/py/ROCrate/arc_rocrate_metadata.py +39 -0
  234. arctrl/py/ROCrate/dyn_obj_extensions.py +1 -0
  235. arctrl/py/ROCrate/helper.py +8 -0
  236. arctrl/py/ROCrate/ldcontext.py +362 -0
  237. arctrl/py/ROCrate/ldobject.py +1247 -0
  238. arctrl/py/ROCrate/rocrate_context.py +51 -0
  239. arctrl/py/Spreadsheet/AnnotationTable/__init__.py +0 -0
  240. arctrl/py/Spreadsheet/AnnotationTable/arc_table.py +193 -0
  241. arctrl/py/Spreadsheet/AnnotationTable/composite_cell.py +78 -0
  242. arctrl/py/Spreadsheet/AnnotationTable/composite_column.py +210 -0
  243. arctrl/py/Spreadsheet/AnnotationTable/composite_header.py +623 -0
  244. arctrl/py/Spreadsheet/DataMapTable/__init__.py +0 -0
  245. arctrl/py/Spreadsheet/DataMapTable/data_map_column.py +114 -0
  246. arctrl/py/Spreadsheet/DataMapTable/data_map_header.py +618 -0
  247. arctrl/py/Spreadsheet/DataMapTable/data_map_table.py +119 -0
  248. arctrl/py/Spreadsheet/Metadata/__init__.py +0 -0
  249. arctrl/py/Spreadsheet/Metadata/assays.py +125 -0
  250. arctrl/py/Spreadsheet/Metadata/comment.py +77 -0
  251. arctrl/py/Spreadsheet/Metadata/contacts.py +134 -0
  252. arctrl/py/Spreadsheet/Metadata/conversions.py +190 -0
  253. arctrl/py/Spreadsheet/Metadata/design_descriptors.py +34 -0
  254. arctrl/py/Spreadsheet/Metadata/factors.py +107 -0
  255. arctrl/py/Spreadsheet/Metadata/ontology_annotation.py +88 -0
  256. arctrl/py/Spreadsheet/Metadata/ontology_source_reference.py +96 -0
  257. arctrl/py/Spreadsheet/Metadata/protocols.py +146 -0
  258. arctrl/py/Spreadsheet/Metadata/publication.py +122 -0
  259. arctrl/py/Spreadsheet/Metadata/run.py +122 -0
  260. arctrl/py/Spreadsheet/Metadata/sparse_table.py +508 -0
  261. arctrl/py/Spreadsheet/Metadata/study.py +312 -0
  262. arctrl/py/Spreadsheet/Metadata/workflow.py +151 -0
  263. arctrl/py/Spreadsheet/__init__.py +0 -0
  264. arctrl/py/Spreadsheet/arc_assay.py +233 -0
  265. arctrl/py/Spreadsheet/arc_investigation.py +418 -0
  266. arctrl/py/Spreadsheet/arc_run.py +190 -0
  267. arctrl/py/Spreadsheet/arc_study.py +144 -0
  268. arctrl/py/Spreadsheet/arc_workflow.py +176 -0
  269. arctrl/py/Spreadsheet/assembly_info.py +1 -0
  270. arctrl/py/Spreadsheet/collection_aux.py +167 -0
  271. arctrl/py/Spreadsheet/data_map.py +44 -0
  272. arctrl/py/Spreadsheet/template.py +460 -0
  273. arctrl/py/ValidationPackages/__init__.py +0 -0
  274. arctrl/py/ValidationPackages/validation_package.py +82 -0
  275. arctrl/py/ValidationPackages/validation_packages_config.py +132 -0
  276. arctrl/py/WebRequest/__init__.py +0 -0
  277. arctrl/py/WebRequest/web_request.py +9 -0
  278. arctrl/py/WebRequest/web_request_py.py +135 -0
  279. arctrl/py/Yaml/__init__.py +0 -0
  280. arctrl/py/Yaml/decode.py +1 -0
  281. arctrl/py/Yaml/encode.py +10 -0
  282. arctrl/py/Yaml/validation_package.py +77 -0
  283. arctrl/py/Yaml/validation_packages_config.py +86 -0
  284. arctrl/py/__init__.py +0 -0
  285. arctrl/py/arc.py +1400 -0
  286. arctrl/py/column_index.py +280 -0
  287. arctrl/py/conversion.py +2184 -0
  288. arctrl/py/cross_async.py +76 -0
  289. arctrl/py/fable_modules/dynamic_obj/__init__.py +0 -0
  290. arctrl/py/fable_modules/dynamic_obj/dyn_obj.py +136 -0
  291. arctrl/py/fable_modules/dynamic_obj/dynamic_obj.py +415 -0
  292. arctrl/py/fable_modules/dynamic_obj/fable_js.py +1 -0
  293. arctrl/py/fable_modules/dynamic_obj/fable_py.py +288 -0
  294. arctrl/py/fable_modules/dynamic_obj/hash_codes.py +82 -0
  295. arctrl/py/fable_modules/dynamic_obj/property_helper.py +25 -0
  296. arctrl/py/fable_modules/dynamic_obj/reflection_utils.py +87 -0
  297. arctrl/py/fable_modules/fable_library/__init__.py +0 -0
  298. arctrl/py/fable_modules/fable_library/array_.py +1528 -0
  299. arctrl/py/fable_modules/fable_library/async_.py +377 -0
  300. arctrl/py/fable_modules/fable_library/async_builder.py +379 -0
  301. arctrl/py/fable_modules/fable_library/big_int.py +330 -0
  302. arctrl/py/fable_modules/fable_library/bit_converter.py +131 -0
  303. arctrl/py/fable_modules/fable_library/boolean.py +26 -0
  304. arctrl/py/fable_modules/fable_library/char.py +237 -0
  305. arctrl/py/fable_modules/fable_library/choice.py +212 -0
  306. arctrl/py/fable_modules/fable_library/date.py +779 -0
  307. arctrl/py/fable_modules/fable_library/date_offset.py +79 -0
  308. arctrl/py/fable_modules/fable_library/decimal_.py +190 -0
  309. arctrl/py/fable_modules/fable_library/diagnostics.py +54 -0
  310. arctrl/py/fable_modules/fable_library/double.py +87 -0
  311. arctrl/py/fable_modules/fable_library/encoding.py +41 -0
  312. arctrl/py/fable_modules/fable_library/event.py +206 -0
  313. arctrl/py/fable_modules/fable_library/file.py +107 -0
  314. arctrl/py/fable_modules/fable_library/fsharp_collections.py +52 -0
  315. arctrl/py/fable_modules/fable_library/fsharp_core.py +123 -0
  316. arctrl/py/fable_modules/fable_library/global_.py +63 -0
  317. arctrl/py/fable_modules/fable_library/guid.py +41 -0
  318. arctrl/py/fable_modules/fable_library/int32.py +73 -0
  319. arctrl/py/fable_modules/fable_library/list.py +1788 -0
  320. arctrl/py/fable_modules/fable_library/long.py +240 -0
  321. arctrl/py/fable_modules/fable_library/mailbox_processor.py +179 -0
  322. arctrl/py/fable_modules/fable_library/map.py +1854 -0
  323. arctrl/py/fable_modules/fable_library/map_util.py +148 -0
  324. arctrl/py/fable_modules/fable_library/mutable_map.py +397 -0
  325. arctrl/py/fable_modules/fable_library/mutable_set.py +279 -0
  326. arctrl/py/fable_modules/fable_library/native.py +45 -0
  327. arctrl/py/fable_modules/fable_library/numeric.py +46 -0
  328. arctrl/py/fable_modules/fable_library/observable.py +222 -0
  329. arctrl/py/fable_modules/fable_library/option.py +128 -0
  330. arctrl/py/fable_modules/fable_library/path.py +62 -0
  331. arctrl/py/fable_modules/fable_library/range.py +117 -0
  332. arctrl/py/fable_modules/fable_library/reflection.py +463 -0
  333. arctrl/py/fable_modules/fable_library/reg_exp.py +137 -0
  334. arctrl/py/fable_modules/fable_library/resize_array.py +31 -0
  335. arctrl/py/fable_modules/fable_library/result.py +212 -0
  336. arctrl/py/fable_modules/fable_library/seq.py +1979 -0
  337. arctrl/py/fable_modules/fable_library/seq2.py +221 -0
  338. arctrl/py/fable_modules/fable_library/set.py +2414 -0
  339. arctrl/py/fable_modules/fable_library/singleton_local_time_zone.py +36 -0
  340. arctrl/py/fable_modules/fable_library/string_.py +573 -0
  341. arctrl/py/fable_modules/fable_library/system_collections_generic.py +462 -0
  342. arctrl/py/fable_modules/fable_library/system_text.py +237 -0
  343. arctrl/py/fable_modules/fable_library/task.py +116 -0
  344. arctrl/py/fable_modules/fable_library/task_builder.py +122 -0
  345. arctrl/py/fable_modules/fable_library/thread.py +5 -0
  346. arctrl/py/fable_modules/fable_library/time_span.py +283 -0
  347. arctrl/py/fable_modules/fable_library/timer.py +24 -0
  348. arctrl/py/fable_modules/fable_library/types.py +401 -0
  349. arctrl/py/fable_modules/fable_library/uri.py +109 -0
  350. arctrl/py/fable_modules/fable_library/util.py +2735 -0
  351. arctrl/py/fable_modules/fable_openpyxl/__init__.py +0 -0
  352. arctrl/py/fable_modules/fable_openpyxl/openpyxl.py +362 -0
  353. arctrl/py/fable_modules/fable_python/cognite-sdk/__init__.py +0 -0
  354. arctrl/py/fable_modules/fable_python/cognite-sdk/cognite_sdk.py +22 -0
  355. arctrl/py/fable_modules/fable_python/flask/__init__.py +0 -0
  356. arctrl/py/fable_modules/fable_python/flask/flask.py +34 -0
  357. arctrl/py/fable_modules/fable_python/jupyter/__init__.py +0 -0
  358. arctrl/py/fable_modules/fable_python/jupyter/ipy_widgets.py +47 -0
  359. arctrl/py/fable_modules/fable_python/jupyter/ipython.py +13 -0
  360. arctrl/py/fable_modules/fable_python/stdlib/__init__.py +0 -0
  361. arctrl/py/fable_modules/fable_python/stdlib/ast.py +1 -0
  362. arctrl/py/fable_modules/fable_python/stdlib/asyncio/__init__.py +0 -0
  363. arctrl/py/fable_modules/fable_python/stdlib/asyncio/events.py +17 -0
  364. arctrl/py/fable_modules/fable_python/stdlib/asyncio/futures.py +52 -0
  365. arctrl/py/fable_modules/fable_python/stdlib/asyncio/tasks.py +38 -0
  366. arctrl/py/fable_modules/fable_python/stdlib/base64_.py +1 -0
  367. arctrl/py/fable_modules/fable_python/stdlib/builtins_.py +38 -0
  368. arctrl/py/fable_modules/fable_python/stdlib/html.py +1 -0
  369. arctrl/py/fable_modules/fable_python/stdlib/json.py +1 -0
  370. arctrl/py/fable_modules/fable_python/stdlib/math_.py +1 -0
  371. arctrl/py/fable_modules/fable_python/stdlib/os_.py +1 -0
  372. arctrl/py/fable_modules/fable_python/stdlib/queue_.py +1 -0
  373. arctrl/py/fable_modules/fable_python/stdlib/string_.py +1 -0
  374. arctrl/py/fable_modules/fable_python/stdlib/sys_.py +30 -0
  375. arctrl/py/fable_modules/fable_python/stdlib/time_.py +1 -0
  376. arctrl/py/fable_modules/fable_python/stdlib/tk_inter.py +1 -0
  377. arctrl/py/fable_modules/fs_spreadsheet/Cells/__init__.py +0 -0
  378. arctrl/py/fable_modules/fs_spreadsheet/Cells/fs_cell.py +338 -0
  379. arctrl/py/fable_modules/fs_spreadsheet/Cells/fs_cells_collection.py +469 -0
  380. arctrl/py/fable_modules/fs_spreadsheet/DSL/__init__.py +0 -0
  381. arctrl/py/fable_modules/fs_spreadsheet/DSL/cell_builder.py +214 -0
  382. arctrl/py/fable_modules/fs_spreadsheet/DSL/column_builder.py +139 -0
  383. arctrl/py/fable_modules/fs_spreadsheet/DSL/dsl.py +50 -0
  384. arctrl/py/fable_modules/fs_spreadsheet/DSL/expression.py +65 -0
  385. arctrl/py/fable_modules/fs_spreadsheet/DSL/operators.py +9 -0
  386. arctrl/py/fable_modules/fs_spreadsheet/DSL/row_builder.py +139 -0
  387. arctrl/py/fable_modules/fs_spreadsheet/DSL/sheet_builder.py +118 -0
  388. arctrl/py/fable_modules/fs_spreadsheet/DSL/table_builder.py +122 -0
  389. arctrl/py/fable_modules/fs_spreadsheet/DSL/transform.py +464 -0
  390. arctrl/py/fable_modules/fs_spreadsheet/DSL/types.py +314 -0
  391. arctrl/py/fable_modules/fs_spreadsheet/DSL/workbook_builder.py +106 -0
  392. arctrl/py/fable_modules/fs_spreadsheet/Json/__init__.py +0 -0
  393. arctrl/py/fable_modules/fs_spreadsheet/Json/cell.py +103 -0
  394. arctrl/py/fable_modules/fs_spreadsheet/Json/column.py +70 -0
  395. arctrl/py/fable_modules/fs_spreadsheet/Json/row.py +70 -0
  396. arctrl/py/fable_modules/fs_spreadsheet/Json/table.py +57 -0
  397. arctrl/py/fable_modules/fs_spreadsheet/Json/value.py +93 -0
  398. arctrl/py/fable_modules/fs_spreadsheet/Json/workbook.py +71 -0
  399. arctrl/py/fable_modules/fs_spreadsheet/Json/worksheet.py +217 -0
  400. arctrl/py/fable_modules/fs_spreadsheet/Ranges/__init__.py +0 -0
  401. arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range.py +47 -0
  402. arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_address.py +186 -0
  403. arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_base.py +90 -0
  404. arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_column.py +78 -0
  405. arctrl/py/fable_modules/fs_spreadsheet/Ranges/fs_range_row.py +48 -0
  406. arctrl/py/fable_modules/fs_spreadsheet/Tables/__init__.py +0 -0
  407. arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table.py +393 -0
  408. arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table_field.py +127 -0
  409. arctrl/py/fable_modules/fs_spreadsheet/Tables/fs_table_row.py +23 -0
  410. arctrl/py/fable_modules/fs_spreadsheet/__init__.py +0 -0
  411. arctrl/py/fable_modules/fs_spreadsheet/fs_address.py +218 -0
  412. arctrl/py/fable_modules/fs_spreadsheet/fs_column.py +172 -0
  413. arctrl/py/fable_modules/fs_spreadsheet/fs_row.py +183 -0
  414. arctrl/py/fable_modules/fs_spreadsheet/fs_workbook.py +180 -0
  415. arctrl/py/fable_modules/fs_spreadsheet/fs_worksheet.py +600 -0
  416. arctrl/py/fable_modules/fs_spreadsheet/sheet_builder.py +330 -0
  417. arctrl/py/fable_modules/fs_spreadsheet_py/__init__.py +0 -0
  418. arctrl/py/fable_modules/fs_spreadsheet_py/cell.py +63 -0
  419. arctrl/py/fable_modules/fs_spreadsheet_py/cell_type.py +50 -0
  420. arctrl/py/fable_modules/fs_spreadsheet_py/fs_extension.py +60 -0
  421. arctrl/py/fable_modules/fs_spreadsheet_py/json.py +47 -0
  422. arctrl/py/fable_modules/fs_spreadsheet_py/table.py +53 -0
  423. arctrl/py/fable_modules/fs_spreadsheet_py/workbook.py +40 -0
  424. arctrl/py/fable_modules/fs_spreadsheet_py/worksheet.py +54 -0
  425. arctrl/py/fable_modules/fs_spreadsheet_py/xlsx.py +37 -0
  426. arctrl/py/fable_modules/thoth_json_core/__init__.py +0 -0
  427. arctrl/py/fable_modules/thoth_json_core/decode.py +1588 -0
  428. arctrl/py/fable_modules/thoth_json_core/encode.py +261 -0
  429. arctrl/py/fable_modules/thoth_json_core/types.py +181 -0
  430. arctrl/py/fable_modules/thoth_json_python/__init__.py +0 -0
  431. arctrl/py/fable_modules/thoth_json_python/decode.py +112 -0
  432. arctrl/py/fable_modules/thoth_json_python/encode.py +72 -0
  433. arctrl/py/fable_modules/thoth_json_python/python.py +1 -0
  434. arctrl/py/fable_modules/yamlicious/Interop/__init__.py +0 -0
  435. arctrl/py/fable_modules/yamlicious/Interop/js_interop.py +1 -0
  436. arctrl/py/fable_modules/yamlicious/Interop/py_interop.py +7 -0
  437. arctrl/py/fable_modules/yamlicious/__init__.py +0 -0
  438. arctrl/py/fable_modules/yamlicious/decode.py +1784 -0
  439. arctrl/py/fable_modules/yamlicious/encode.py +84 -0
  440. arctrl/py/fable_modules/yamlicious/library.py +10 -0
  441. arctrl/py/fable_modules/yamlicious/persil.py +57 -0
  442. arctrl/py/fable_modules/yamlicious/preprocessing.py +99 -0
  443. arctrl/py/fable_modules/yamlicious/reader.py +665 -0
  444. arctrl/py/fable_modules/yamlicious/regex.py +21 -0
  445. arctrl/py/fable_modules/yamlicious/regex_active_patterns.py +256 -0
  446. arctrl/py/fable_modules/yamlicious/writer.py +175 -0
  447. arctrl/py/fable_modules/yamlicious/yamlicious_types.py +128 -0
  448. arctrl/py/json.py +213 -0
  449. arctrl/py/rocrate_io.py +72 -0
  450. arctrl/py/template_web.py +23 -0
  451. arctrl/py/xlsx.py +148 -0
  452. arctrl/rocrate.py +21 -0
  453. arctrl-3.0.0a3.dist-info/LICENSE +21 -0
  454. arctrl-3.0.0a3.dist-info/METADATA +119 -0
  455. arctrl-3.0.0a3.dist-info/RECORD +456 -0
  456. arctrl-3.0.0a3.dist-info/WHEEL +4 -0
@@ -0,0 +1,279 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable
4
+ from typing import Any, Generic, TypeVar
5
+
6
+ from .map_util import get_item_from_dict, try_get_value
7
+ from .option import some
8
+ from .reflection import TypeInfo, class_type
9
+ from .resize_array import find_index
10
+ from .seq import concat, iterate, iterate_indexed, map
11
+ from .types import Array, FSharpRef
12
+ from .util import IEnumerable_1, IEnumerator, IEqualityComparer_1, dispose, get_enumerator, ignore, to_iterator
13
+
14
+
15
+ _T = TypeVar("_T")
16
+
17
+
18
+ def _expr22(gen0: TypeInfo) -> TypeInfo:
19
+ return class_type("Fable.Collections.HashSet", [gen0], HashSet)
20
+
21
+
22
+ class HashSet(Generic[_T]):
23
+ def __init__(self, items: IEnumerable_1[Any], comparer: IEqualityComparer_1[Any]) -> None:
24
+ this: FSharpRef[HashSet[_T]] = FSharpRef(None)
25
+ self.comparer: IEqualityComparer_1[Any] = comparer
26
+ this.contents = self
27
+ self.hash_map: Any = dict([])
28
+ self.init_00409: int = 1
29
+ with get_enumerator(items) as enumerator:
30
+ while enumerator.System_Collections_IEnumerator_MoveNext():
31
+ item: _T = enumerator.System_Collections_Generic_IEnumerator_1_get_Current()
32
+ ignore(HashSet__Add_2B595(this.contents, item))
33
+
34
+ @property
35
+ def Symbol_toStringTag(self, __unit: None = None) -> str:
36
+ return "HashSet"
37
+
38
+ def to_json(self, __unit: None = None) -> Any:
39
+ this: HashSet[_T] = self
40
+ return list(this)
41
+
42
+ def System_Collections_IEnumerable_GetEnumerator(self, __unit: None = None) -> IEnumerator[Any]:
43
+ this: HashSet[_T] = self
44
+ return get_enumerator(this)
45
+
46
+ def GetEnumerator(self, __unit: None = None) -> IEnumerator[_T]:
47
+ this: HashSet[_T] = self
48
+ return get_enumerator(concat(this.hash_map.values()))
49
+
50
+ def __iter__(self) -> IEnumerator[_T]:
51
+ return to_iterator(self.GetEnumerator())
52
+
53
+ def System_Collections_Generic_ICollection_1_Add2B595(self, item: _T | None = None) -> None:
54
+ this: HashSet[_T] = self
55
+ ignore(HashSet__Add_2B595(this, item))
56
+
57
+ def System_Collections_Generic_ICollection_1_Clear(self, __unit: None = None) -> None:
58
+ this: HashSet[_T] = self
59
+ HashSet__Clear(this)
60
+
61
+ def System_Collections_Generic_ICollection_1_Contains2B595(self, item: _T | None = None) -> bool:
62
+ this: HashSet[_T] = self
63
+ return HashSet__Contains_2B595(this, item)
64
+
65
+ def System_Collections_Generic_ICollection_1_CopyToZ3B4C077E(self, array: Array[_T], array_index: int) -> None:
66
+ this: HashSet[_T] = self
67
+
68
+ def action(i: int, e: _T) -> None:
69
+ array[array_index + i] = e
70
+
71
+ iterate_indexed(action, this)
72
+
73
+ def __len__(self, __unit: None = None) -> int:
74
+ this: HashSet[_T] = self
75
+ return HashSet__get_Count(this)
76
+
77
+ def System_Collections_Generic_ICollection_1_get_IsReadOnly(self, __unit: None = None) -> bool:
78
+ return False
79
+
80
+ def System_Collections_Generic_ICollection_1_Remove2B595(self, item: _T | None = None) -> bool:
81
+ this: HashSet[_T] = self
82
+ return HashSet__Remove_2B595(this, item)
83
+
84
+ @property
85
+ def size(self, __unit: None = None) -> int:
86
+ this: HashSet[_T] = self
87
+ return HashSet__get_Count(this)
88
+
89
+ def add(self, k: _T | None = None) -> Set_1[_T]:
90
+ this: HashSet[_T] = self
91
+ ignore(HashSet__Add_2B595(this, k))
92
+ return this
93
+
94
+ def clear(self, __unit: None = None) -> None:
95
+ this: HashSet[_T] = self
96
+ HashSet__Clear(this)
97
+
98
+ def __delitem__(self, k: _T | None = None) -> bool:
99
+ this: HashSet[_T] = self
100
+ return HashSet__Remove_2B595(this, k)
101
+
102
+ def __contains__(self, k: _T | None = None) -> bool:
103
+ this: HashSet[_T] = self
104
+ return HashSet__Contains_2B595(this, k)
105
+
106
+ def keys(self, __unit: None = None) -> IEnumerable_1[_T]:
107
+ this: HashSet[_T] = self
108
+
109
+ def mapping(x: _T | None = None) -> _T | None:
110
+ return x
111
+
112
+ return map(mapping, this)
113
+
114
+ def values(self, __unit: None = None) -> IEnumerable_1[_T]:
115
+ this: HashSet[_T] = self
116
+
117
+ def mapping(x: _T | None = None) -> _T | None:
118
+ return x
119
+
120
+ return map(mapping, this)
121
+
122
+ def entries(self, __unit: None = None) -> IEnumerable_1[tuple[_T, _T]]:
123
+ this: HashSet[_T] = self
124
+
125
+ def mapping(v: _T | None = None) -> tuple[_T, _T]:
126
+ return (v, v)
127
+
128
+ return map(mapping, this)
129
+
130
+ def for_each(self, f: Callable[[_T, _T, Set_1[_T]], None], this_arg: Any | None = None) -> None:
131
+ this: HashSet[_T] = self
132
+
133
+ def action(x: _T | None = None) -> None:
134
+ f(x, x, this)
135
+
136
+ iterate(action, this)
137
+
138
+
139
+ HashSet_reflection = _expr22
140
+
141
+
142
+ def HashSet__ctor_Z6150332D(items: IEnumerable_1[Any], comparer: IEqualityComparer_1[Any]) -> HashSet[_T]:
143
+ return HashSet(items, comparer)
144
+
145
+
146
+ def HashSet__TryFindIndex_2B595(this: HashSet[Any], k: Any) -> tuple[bool, int, int]:
147
+ h: int = this.comparer.GetHashCode(k) or 0
148
+ match_value: tuple[bool, Array[_T]]
149
+ out_arg: Array[_T] = None
150
+
151
+ def _arrow23(__unit: None = None, this: Any = this, k: Any = k) -> Array[_T]:
152
+ return out_arg
153
+
154
+ def _arrow24(v: Array[_T], this: Any = this, k: Any = k) -> None:
155
+ nonlocal out_arg
156
+ out_arg = v
157
+
158
+ match_value = (try_get_value(this.hash_map, h, FSharpRef(_arrow23, _arrow24)), out_arg)
159
+ if match_value[0]:
160
+
161
+ def _arrow25(v_1: _T | None = None, this: Any = this, k: Any = k) -> bool:
162
+ return this.comparer.Equals(k, v_1)
163
+
164
+ return (True, h, find_index(_arrow25, match_value[1]))
165
+
166
+ else:
167
+ return (False, h, -1)
168
+
169
+
170
+ def HashSet__TryFind_2B595(this: HashSet[Any], k: Any) -> Any | None:
171
+ match_value: tuple[bool, int, int] = HashSet__TryFindIndex_2B595(this, k)
172
+ (pattern_matching_result,) = (None,)
173
+ if match_value[0]:
174
+ if match_value[2] > -1:
175
+ pattern_matching_result = 0
176
+
177
+ else:
178
+ pattern_matching_result = 1
179
+
180
+ else:
181
+ pattern_matching_result = 1
182
+
183
+ if pattern_matching_result == 0:
184
+ return some(get_item_from_dict(this.hash_map, match_value[1])[match_value[2]])
185
+
186
+ elif pattern_matching_result == 1:
187
+ return None
188
+
189
+
190
+ def HashSet__get_Comparer(this: HashSet[Any]) -> IEqualityComparer_1[Any]:
191
+ return this.comparer
192
+
193
+
194
+ def HashSet__Clear(this: HashSet[Any]) -> None:
195
+ this.hash_map.clear()
196
+
197
+
198
+ def HashSet__get_Count(this: HashSet[Any]) -> int:
199
+ count: int = 0
200
+ enumerator: Any = get_enumerator(this.hash_map.values())
201
+ try:
202
+ while enumerator.System_Collections_IEnumerator_MoveNext():
203
+ items: Array[_T] = enumerator.System_Collections_Generic_IEnumerator_1_get_Current()
204
+ count = (count + len(items)) or 0
205
+
206
+ finally:
207
+ dispose(enumerator)
208
+
209
+ return count
210
+
211
+
212
+ def HashSet__Add_2B595(this: HashSet[Any], k: Any) -> bool:
213
+ match_value: tuple[bool, int, int] = HashSet__TryFindIndex_2B595(this, k)
214
+ if match_value[0]:
215
+ if match_value[2] > -1:
216
+ return False
217
+
218
+ else:
219
+ value: None = get_item_from_dict(this.hash_map, match_value[1]).append(k)
220
+ ignore(None)
221
+ return True
222
+
223
+ else:
224
+ this.hash_map[match_value[1]] = [k]
225
+ return True
226
+
227
+
228
+ def HashSet__Contains_2B595(this: HashSet[Any], k: Any) -> bool:
229
+ match_value: tuple[bool, int, int] = HashSet__TryFindIndex_2B595(this, k)
230
+ (pattern_matching_result,) = (None,)
231
+ if match_value[0]:
232
+ if match_value[2] > -1:
233
+ pattern_matching_result = 0
234
+
235
+ else:
236
+ pattern_matching_result = 1
237
+
238
+ else:
239
+ pattern_matching_result = 1
240
+
241
+ if pattern_matching_result == 0:
242
+ return True
243
+
244
+ elif pattern_matching_result == 1:
245
+ return False
246
+
247
+
248
+ def HashSet__Remove_2B595(this: HashSet[Any], k: Any) -> bool:
249
+ match_value: tuple[bool, int, int] = HashSet__TryFindIndex_2B595(this, k)
250
+ (pattern_matching_result,) = (None,)
251
+ if match_value[0]:
252
+ if match_value[2] > -1:
253
+ pattern_matching_result = 0
254
+
255
+ else:
256
+ pattern_matching_result = 1
257
+
258
+ else:
259
+ pattern_matching_result = 1
260
+
261
+ if pattern_matching_result == 0:
262
+ get_item_from_dict(this.hash_map, match_value[1]).pop(match_value[2])
263
+ return True
264
+
265
+ elif pattern_matching_result == 1:
266
+ return False
267
+
268
+
269
+ __all__ = [
270
+ "HashSet_reflection",
271
+ "HashSet__TryFindIndex_2B595",
272
+ "HashSet__TryFind_2B595",
273
+ "HashSet__get_Comparer",
274
+ "HashSet__Clear",
275
+ "HashSet__get_Count",
276
+ "HashSet__Add_2B595",
277
+ "HashSet__Contains_2B595",
278
+ "HashSet__Remove_2B595",
279
+ ]
@@ -0,0 +1,45 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+ from typing import Any, Generic, Protocol, TypeVar
5
+
6
+ from .types import Array
7
+
8
+
9
+ _T = TypeVar("_T")
10
+
11
+
12
+ class Cons_1(Protocol, Generic[_T]):
13
+ @abstractmethod
14
+ def Allocate(self, len: int) -> Array[_T]: ...
15
+
16
+
17
+ def Helpers_allocateArrayFromCons(cons: Cons_1[Any], len_1: int) -> Array[Any]:
18
+ if cons is None:
19
+ return (list)([None] * len_1)
20
+
21
+ else:
22
+ return cons([0] * len_1)
23
+
24
+
25
+ def Helpers_fillImpl(array: Array[Any], value: Any, start: int, count: int) -> Array[Any]:
26
+ for i in range(0, (count - 1) + 1, 1):
27
+ array[i + start] = value
28
+ return array
29
+
30
+
31
+ def Helpers_spliceImpl(array: Array[Any], start: int, delete_count: int) -> Array[Any]:
32
+ for _ in range(1, delete_count + 1, 1):
33
+ array.pop(start)
34
+ return array
35
+
36
+
37
+ def Helpers_indexOfImpl(array: Array[Any], item: Any, start: int) -> Any:
38
+ try:
39
+ return array.index(item, start)
40
+
41
+ except Exception as ex:
42
+ return -1
43
+
44
+
45
+ __all__ = ["Helpers_allocateArrayFromCons", "Helpers_fillImpl", "Helpers_spliceImpl", "Helpers_indexOfImpl"]
@@ -0,0 +1,46 @@
1
+ from __future__ import annotations
2
+
3
+ from .types import int64
4
+
5
+
6
+ def to_fixed(x: float, dp: int | None = None) -> str:
7
+ x = int(x) if int(x) == x else x
8
+
9
+ if dp is not None:
10
+ fmt = "{:.%sf}" % dp
11
+ return fmt.format(x)
12
+
13
+ return f"{x}"
14
+
15
+
16
+ def to_precision(x: float, sd: int | None = None) -> str:
17
+ x = int(x) if int(x) == x else x
18
+
19
+ if sd is not None:
20
+ fmt = "{:.%se}" % sd
21
+ return fmt.format(x)
22
+
23
+ return f"{x}"
24
+
25
+
26
+ def to_exponential(x: float, dp: int | None = None) -> str:
27
+ if dp is not None:
28
+ fmt = "{:.%se}" % dp
29
+ return fmt.format(x)
30
+
31
+ return f"{x}"
32
+
33
+
34
+ def to_hex(x: int) -> str:
35
+ def rshift(val: int, n: int) -> int:
36
+ sign = 0x10000000000000000 if isinstance(val, int64) else 0x100000000
37
+ return val >> n if val >= 0 else (val + sign) >> n
38
+
39
+ return f"{rshift(x, 0):x}"
40
+
41
+
42
+ def multiply(x: float, y: float) -> float:
43
+ return x * y
44
+
45
+
46
+ __all__ = ["to_fixed", "to_precision", "to_exponential", "to_hex", "multiply"]
@@ -0,0 +1,222 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+ from collections.abc import Callable
5
+ from typing import Any, Generic, Protocol, TypeVar
6
+
7
+ from .choice import (
8
+ Choice_tryValueIfChoice1Of2, # type: ignore
9
+ Choice_tryValueIfChoice2Of2, # type: ignore
10
+ FSharpChoice_2, # type: ignore
11
+ )
12
+ from .option import value
13
+ from .util import IDisposable
14
+
15
+
16
+ _T = TypeVar("_T")
17
+ _T_co = TypeVar("_T_co", covariant=True)
18
+ _T_contra = TypeVar("_T_contra", contravariant=True)
19
+ _U = TypeVar("_U")
20
+
21
+
22
+ class IObserver(Protocol, Generic[_T_contra]):
23
+ __slots__ = ()
24
+
25
+ @abstractmethod
26
+ def OnNext(self, __value: _T_contra) -> None: ...
27
+
28
+ @abstractmethod
29
+ def OnError(self, __error: Exception) -> None: ...
30
+
31
+ @abstractmethod
32
+ def OnCompleted(self) -> None: ...
33
+
34
+
35
+ def _noop(__arg: Any = None) -> None:
36
+ pass
37
+
38
+
39
+ class Observer(IObserver[_T]):
40
+ __slots__ = "_on_error", "_on_next", "_on_completed"
41
+
42
+ def __init__(
43
+ self,
44
+ on_next: Callable[[_T], None],
45
+ on_error: Callable[[Exception], None] | None = None,
46
+ on_completed: Callable[[], None] | None = None,
47
+ ) -> None:
48
+ self._on_next = on_next
49
+ self._on_error = on_error or _noop
50
+ self._on_completed = on_completed or _noop
51
+
52
+ def OnError(self, error: Exception) -> None:
53
+ return self._on_error(error)
54
+
55
+ def OnNext(self, value: _T) -> None:
56
+ return self._on_next(value)
57
+
58
+ def OnCompleted(self) -> None:
59
+ return self._on_completed()
60
+
61
+
62
+ class IObservable(Protocol, Generic[_T_co]):
63
+ __slots__ = ()
64
+
65
+ @abstractmethod
66
+ def Subscribe(self, __obs: IObserver[_T_co]) -> IDisposable: ...
67
+
68
+
69
+ class Observable(IObservable[_T]):
70
+ __slots__ = "subscribe"
71
+
72
+ def __init__(self, subscribe: Callable[[IObserver[_T]], IDisposable]) -> None:
73
+ self.subscribe = subscribe
74
+
75
+ def Subscribe(self, obv: IObserver[_T]) -> IDisposable:
76
+ return self.subscribe(obv)
77
+
78
+
79
+ def subscribe(callback: Callable[[_T], None], source: IObservable[_T]) -> IDisposable:
80
+ return source.Subscribe(Observer(callback))
81
+
82
+
83
+ def add(callback: Callable[[_T], None], source: IObservable[_T]) -> IDisposable:
84
+ return source.Subscribe(Observer(callback))
85
+
86
+
87
+ def protect(
88
+ f: Callable[[], _T],
89
+ succeed: Callable[[_T], None],
90
+ fail: Callable[[Exception], None],
91
+ ):
92
+ try:
93
+ return succeed(f())
94
+ except Exception as e:
95
+ fail(e)
96
+
97
+
98
+ def choose(chooser: Callable[[_T], _U | None], source: IObservable[_T]) -> IObservable[_U]:
99
+ def subscribe(observer: IObserver[_U]):
100
+ def on_next(t: _T) -> None:
101
+ def success(u: _U | None) -> None:
102
+ if u is not None:
103
+ observer.OnNext(value(u))
104
+
105
+ return protect(lambda: chooser(t), success, observer.OnError)
106
+
107
+ obv = Observer(on_next, observer.OnError, observer.OnCompleted)
108
+ return source.Subscribe(obv)
109
+
110
+ return Observable(subscribe)
111
+
112
+
113
+ def filter(predicate: Callable[[_T], bool], source: IObservable[_T]) -> IObservable[_T]:
114
+ return choose(lambda x: x if predicate(x) else None, source)
115
+
116
+
117
+ def map(mapping: Callable[[_T], _U], source: IObservable[_T]) -> IObservable[_U]:
118
+ def subscribe(observer: IObserver[_U]) -> IDisposable:
119
+ def on_next(value: _T) -> None:
120
+ return protect(lambda: mapping(value), observer.OnNext, observer.OnError)
121
+
122
+ obv = Observer(on_next, observer.OnError, observer.OnCompleted)
123
+ return source.Subscribe(obv)
124
+
125
+ return Observable(subscribe)
126
+
127
+
128
+ def merge(source1: IObservable[_T], source2: IObservable[_T]) -> IObservable[_T]:
129
+ def subscribe(observer: IObserver[_T]) -> IDisposable:
130
+ stopped = False
131
+ completed1 = False
132
+ completed2 = False
133
+
134
+ def on_next(value: _T) -> None:
135
+ if stopped:
136
+ return
137
+ observer.OnNext(value)
138
+
139
+ def on_error(error: Exception) -> None:
140
+ nonlocal stopped
141
+ if stopped:
142
+ return
143
+ stopped = True
144
+ observer.OnError(error)
145
+
146
+ def on_completed1() -> None:
147
+ nonlocal completed1, stopped
148
+ if stopped:
149
+ return
150
+
151
+ completed1 = True
152
+ if completed2:
153
+ stopped = True
154
+ observer.OnCompleted()
155
+
156
+ obv1 = Observer(on_next, on_error, on_completed1)
157
+ h1 = source1.Subscribe(obv1)
158
+
159
+ def on_completed2() -> None:
160
+ nonlocal completed2, stopped
161
+ if stopped:
162
+ return
163
+
164
+ completed2 = True
165
+ if completed1:
166
+ stopped = True
167
+ observer.OnCompleted()
168
+
169
+ obv2 = Observer(on_next, on_error, on_completed2)
170
+ h2 = source2.Subscribe(obv2)
171
+
172
+ def dispose() -> None:
173
+ h1.Dispose()
174
+ h2.Dispose()
175
+
176
+ return IDisposable.create(dispose)
177
+
178
+ return Observable(subscribe)
179
+
180
+
181
+ def pairwise(source: IObservable[_T]) -> IObservable[tuple[_T, _T]]:
182
+ def subscribe(observer: IObserver[tuple[_T, _T]]) -> IDisposable:
183
+ last: _T | None = None
184
+
185
+ def on_next(value: _T) -> None:
186
+ nonlocal last
187
+ if last is not None:
188
+ observer.OnNext((last, value))
189
+
190
+ last = value
191
+
192
+ obv = Observer(on_next, observer.OnError, observer.OnCompleted)
193
+ return source.Subscribe(obv)
194
+
195
+ return Observable(subscribe)
196
+
197
+
198
+ def partition(predicate: Callable[[_T], bool], source: IObservable[_T]) -> tuple[IObservable[_T], IObservable[_T]]:
199
+ return (filter(predicate, source), filter(lambda x: not predicate(x), source))
200
+
201
+
202
+ def scan(collector: Callable[[_U, _T], _U], state: _U, source: IObservable[_T]) -> IObservable[_U]:
203
+ def subscribe(observer: IObserver[_U]) -> IDisposable:
204
+ def on_next(t: _T) -> None:
205
+ def success(u: _U) -> None:
206
+ nonlocal state
207
+ state = u
208
+ observer.OnNext(u)
209
+
210
+ protect(lambda: collector(state, t), success, observer.OnError)
211
+
212
+ obv = Observer(on_next, observer.OnError, observer.OnCompleted)
213
+ return source.Subscribe(obv)
214
+
215
+ return Observable(subscribe)
216
+
217
+
218
+ def split(splitter: Callable[[_T], FSharpChoice_2], source: IObservable[_T]) -> tuple[IObservable[_T], IObservable[_T]]:
219
+ return (
220
+ choose(lambda v: Choice_tryValueIfChoice1Of2(splitter(v)), source),
221
+ choose(lambda v: Choice_tryValueIfChoice2Of2(splitter(v)), source),
222
+ )