Initial commit.

Changed files
+786
src
atpasser
dataFormatter
tests
+216
.gitignore
··· 1 + # Byte-compiled / optimized / DLL files 2 + __pycache__/ 3 + *.py[codz] 4 + *$py.class 5 + 6 + # C extensions 7 + *.so 8 + 9 + # Distribution / packaging 10 + .Python 11 + build/ 12 + develop-eggs/ 13 + dist/ 14 + downloads/ 15 + eggs/ 16 + .eggs/ 17 + lib/ 18 + lib64/ 19 + parts/ 20 + sdist/ 21 + var/ 22 + wheels/ 23 + share/python-wheels/ 24 + *.egg-info/ 25 + .installed.cfg 26 + *.egg 27 + MANIFEST 28 + 29 + # PyInstaller 30 + # Usually these files are written by a python script from a template 31 + # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 + *.manifest 33 + *.spec 34 + 35 + # Installer logs 36 + pip-log.txt 37 + pip-delete-this-directory.txt 38 + 39 + # Unit test / coverage reports 40 + htmlcov/ 41 + .tox/ 42 + .nox/ 43 + .coverage 44 + .coverage.* 45 + .cache 46 + nosetests.xml 47 + coverage.xml 48 + *.cover 49 + *.py.cover 50 + .hypothesis/ 51 + .pytest_cache/ 52 + cover/ 53 + 54 + # Translations 55 + *.mo 56 + *.pot 57 + 58 + # Django stuff: 59 + *.log 60 + local_settings.py 61 + db.sqlite3 62 + db.sqlite3-journal 63 + 64 + # Flask stuff: 65 + instance/ 66 + .webassets-cache 67 + 68 + # Scrapy stuff: 69 + .scrapy 70 + 71 + # Sphinx documentation 72 + docs/_build/ 73 + 74 + # PyBuilder 75 + .pybuilder/ 76 + target/ 77 + 78 + # Jupyter Notebook 79 + .ipynb_checkpoints 80 + 81 + # IPython 82 + profile_default/ 83 + ipython_config.py 84 + 85 + # pyenv 86 + # For a library or package, you might want to ignore these files since the code is 87 + # intended to run in multiple environments; otherwise, check them in: 88 + # .python-version 89 + 90 + # pipenv 91 + # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 92 + # However, in case of collaboration, if having platform-specific dependencies or dependencies 93 + # having no cross-platform support, pipenv may install dependencies that don't work, or not 94 + # install all needed dependencies. 95 + #Pipfile.lock 96 + 97 + # UV 98 + # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. 99 + # This is especially recommended for binary packages to ensure reproducibility, and is more 100 + # commonly ignored for libraries. 101 + #uv.lock 102 + 103 + # poetry 104 + # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 105 + # This is especially recommended for binary packages to ensure reproducibility, and is more 106 + # commonly ignored for libraries. 107 + # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 108 + #poetry.lock 109 + #poetry.toml 110 + 111 + # pdm 112 + # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 113 + # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. 114 + # https://pdm-project.org/en/latest/usage/project/#working-with-version-control 115 + #pdm.lock 116 + #pdm.toml 117 + .pdm-python 118 + .pdm-build/ 119 + 120 + # pixi 121 + # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. 122 + #pixi.lock 123 + # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one 124 + # in the .venv directory. It is recommended not to include this directory in version control. 125 + .pixi 126 + 127 + # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 128 + __pypackages__/ 129 + 130 + # Celery stuff 131 + celerybeat-schedule 132 + celerybeat.pid 133 + 134 + # Redis 135 + *.rdb 136 + *.aof 137 + *.pid 138 + 139 + # RabbitMQ 140 + mnesia/ 141 + rabbitmq/ 142 + rabbitmq-data/ 143 + 144 + # ActiveMQ 145 + activemq-data/ 146 + 147 + # SageMath parsed files 148 + *.sage.py 149 + 150 + # Environments 151 + .env 152 + .envrc 153 + .venv 154 + env/ 155 + venv/ 156 + ENV/ 157 + env.bak/ 158 + venv.bak/ 159 + 160 + # Spyder project settings 161 + .spyderproject 162 + .spyproject 163 + 164 + # Rope project settings 165 + .ropeproject 166 + 167 + # mkdocs documentation 168 + /site 169 + 170 + # mypy 171 + .mypy_cache/ 172 + .dmypy.json 173 + dmypy.json 174 + 175 + # Pyre type checker 176 + .pyre/ 177 + 178 + # pytype static type analyzer 179 + .pytype/ 180 + 181 + # Cython debug symbols 182 + cython_debug/ 183 + 184 + # PyCharm 185 + # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 186 + # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 187 + # and can be added to the global gitignore or merged into this file. For a more nuclear 188 + # option (not recommended) you can uncomment the following to ignore the entire idea folder. 189 + #.idea/ 190 + 191 + # Abstra 192 + # Abstra is an AI-powered process automation framework. 193 + # Ignore directories containing user credentials, local state, and settings. 194 + # Learn more at https://abstra.io/docs 195 + .abstra/ 196 + 197 + # Visual Studio Code 198 + # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore 199 + # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore 200 + # and can be added to the global gitignore or merged into this file. However, if you prefer, 201 + # you could uncomment the following to ignore the entire vscode folder 202 + # .vscode/ 203 + 204 + # Ruff stuff: 205 + .ruff_cache/ 206 + 207 + # PyPI configuration file 208 + .pypirc 209 + 210 + # Marimo 211 + marimo/_static/ 212 + marimo/_lsp/ 213 + __marimo__/ 214 + 215 + # Streamlit 216 + .streamlit/secrets.toml
+237
LICENSE
··· 1 + Dual MIT/Apache-2.0 License 2 + 3 + Copyright (c) 2025 ATPasser Contributors 4 + 5 + Except as otherwise noted in individual files, this software is licensed under 6 + the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, 7 + Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>). 8 + 9 + Downstream projects and end users may chose either license individually, or 10 + both together, at their discretion. The motivation for this dual-licensing is 11 + the additional software patent assurance provided by Apache 2.0. 12 + 13 + ------------------------------------------------------------------------------- 14 + 15 + MIT License 16 + 17 + Permission is hereby granted, free of charge, to any person obtaining a copy 18 + of this software and associated documentation files (the "Software"), to deal 19 + in the Software without restriction, including without limitation the rights 20 + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 21 + copies of the Software, and to permit persons to whom the Software is 22 + furnished to do so, subject to the following conditions: 23 + 24 + The above copyright notice and this permission notice shall be included in all 25 + copies or substantial portions of the Software. 26 + 27 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 29 + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 30 + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 31 + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 32 + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 + SOFTWARE. 34 + 35 + ------------------------------------------------------------------------------- 36 + 37 + Apache License 38 + Version 2.0, January 2004 39 + http://www.apache.org/licenses/ 40 + 41 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 42 + 43 + 1. Definitions. 44 + 45 + "License" shall mean the terms and conditions for use, reproduction, 46 + and distribution as defined by Sections 1 through 9 of this document. 47 + 48 + "Licensor" shall mean the copyright owner or entity authorized by 49 + the copyright owner that is granting the License. 50 + 51 + "Legal Entity" shall mean the union of the acting entity and all 52 + other entities that control, are controlled by, or are under common 53 + control with that entity. For the purposes of this definition, 54 + "control" means (i) the power, direct or indirect, to cause the 55 + direction or management of such entity, whether by contract or 56 + otherwise, or (ii) ownership of fifty percent (50%) or more of the 57 + outstanding shares, or (iii) beneficial ownership of such entity. 58 + 59 + "You" (or "Your") shall mean an individual or Legal Entity 60 + exercising permissions granted by this License. 61 + 62 + "Source" form shall mean the preferred form for making modifications, 63 + including but not limited to software source code, documentation 64 + source, and configuration files. 65 + 66 + "Object" form shall mean any form resulting from mechanical 67 + transformation or translation of a Source form, including but 68 + not limited to compiled object code, generated documentation, 69 + and conversions to other media types. 70 + 71 + "Work" shall mean the work of authorship, whether in Source or 72 + Object form, made available under the License, as indicated by a 73 + copyright notice that is included in or attached to the work 74 + (an example is provided in the Appendix below). 75 + 76 + "Derivative Works" shall mean any work, whether in Source or Object 77 + form, that is based on (or derived from) the Work and for which the 78 + editorial revisions, annotations, elaborations, or other modifications 79 + represent, as a whole, an original work of authorship. For the purposes 80 + of this License, Derivative Works shall not include works that remain 81 + separable from, or merely link (or bind by name) to the interfaces of, 82 + the Work and Derivative Works thereof. 83 + 84 + "Contribution" shall mean any work of authorship, including 85 + the original version of the Work and any modifications or additions 86 + to that Work or Derivative Works thereof, that is intentionally 87 + submitted to Licensor for inclusion in the Work by the copyright owner 88 + or by an individual or Legal Entity authorized to submit on behalf of 89 + the copyright owner. For the purposes of this definition, "submitted" 90 + means any form of electronic, verbal, or written communication sent 91 + to the Licensor or its representatives, including but not limited to 92 + communication on electronic mailing lists, source code control systems, 93 + and issue tracking systems that are managed by, or on behalf of, the 94 + Licensor for the purpose of discussing and improving the Work, but 95 + excluding communication that is conspicuously marked or otherwise 96 + designated in writing by the copyright owner as "Not a Contribution." 97 + 98 + "Contributor" shall mean Licensor and any individual or Legal Entity 99 + on behalf of whom a Contribution has been received by Licensor and 100 + subsequently incorporated within the Work. 101 + 102 + 2. Grant of Copyright License. Subject to the terms and conditions of 103 + this License, each Contributor hereby grants to You a perpetual, 104 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 105 + copyright license to reproduce, prepare Derivative Works of, 106 + publicly display, publicly perform, sublicense, and distribute the 107 + Work and such Derivative Works in Source or Object form. 108 + 109 + 3. Grant of Patent License. Subject to the terms and conditions of 110 + this License, each Contributor hereby grants to You a perpetual, 111 + worldwide, non-exclusive, no-charge, royalty-free, irrevocable 112 + (except as stated in this section) patent license to make, have made, 113 + use, offer to sell, sell, import, and otherwise transfer the Work, 114 + where such license applies only to those patent claims licensable 115 + by such Contributor that are necessarily infringed by their 116 + Contribution(s) alone or by combination of their Contribution(s) 117 + with the Work to which such Contribution(s) was submitted. If You 118 + institute patent litigation against any entity (including a 119 + cross-claim or counterclaim in a lawsuit) alleging that the Work 120 + or a Contribution incorporated within the Work constitutes direct 121 + or contributory patent infringement, then any patent licenses 122 + granted to You under this License for that Work shall terminate 123 + as of the date such litigation is filed. 124 + 125 + 4. Redistribution. You may reproduce and distribute copies of the 126 + Work or Derivative Works thereof in any medium, with or without 127 + modifications, and in Source or Object form, provided that You 128 + meet the following conditions: 129 + 130 + (a) You must give any other recipients of the Work or 131 + Derivative Works a copy of this License; and 132 + 133 + (b) You must cause any modified files to carry prominent notices 134 + stating that You changed the files; and 135 + 136 + (c) You must retain, in the Source form of any Derivative Works 137 + that You distribute, all copyright, patent, trademark, and 138 + attribution notices from the Source form of the Work, 139 + excluding those notices that do not pertain to any part of 140 + the Derivative Works; and 141 + 142 + (d) If the Work includes a "NOTICE" text file as part of its 143 + distribution, then any Derivative Works that You distribute must 144 + include a readable copy of the attribution notices contained 145 + within such NOTICE file, excluding those notices that do not 146 + pertain to any part of the Derivative Works, in at least one 147 + of the following places: within a NOTICE text file distributed 148 + as part of the Derivative Works; within the Source form or 149 + documentation, if provided along with the Derivative Works; or, 150 + within a display generated by the Derivative Works, if and 151 + wherever such third-party notices normally appear. The contents 152 + of the NOTICE file are for informational purposes only and 153 + do not modify the License. You may add Your own attribution 154 + notices within Derivative Works that You distribute, alongside 155 + or as an addendum to the NOTICE text from the Work, provided 156 + that such additional attribution notices cannot be construed 157 + as modifying the License. 158 + 159 + You may add Your own copyright statement to Your modifications and 160 + may provide additional or different license terms and conditions 161 + for use, reproduction, or distribution of Your modifications, or 162 + for any such Derivative Works as a whole, provided Your use, 163 + reproduction, and distribution of the Work otherwise complies with 164 + the conditions stated in this License. 165 + 166 + 5. Submission of Contributions. Unless You explicitly state otherwise, 167 + any Contribution intentionally submitted for inclusion in the Work 168 + by You to the Licensor shall be under the terms and conditions of 169 + this License, without any additional terms or conditions. 170 + Notwithstanding the above, nothing herein shall supersede or modify 171 + the terms of any separate license agreement you may have executed 172 + with Licensor regarding such Contributions. 173 + 174 + 6. Trademarks. This License does not grant permission to use the trade 175 + names, trademarks, service marks, or product names of the Licensor, 176 + except as required for reasonable and customary use in describing the 177 + origin of the Work and reproducing the content of the NOTICE file. 178 + 179 + 7. Disclaimer of Warranty. Unless required by applicable law or 180 + agreed to in writing, Licensor provides the Work (and each 181 + Contributor provides its Contributions) on an "AS IS" BASIS, 182 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 183 + implied, including, without limitation, any warranties or conditions 184 + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 185 + PARTICULAR PURPOSE. You are solely responsible for determining the 186 + appropriateness of using or redistributing the Work and assume any 187 + risks associated with Your exercise of permissions under this License. 188 + 189 + 8. Limitation of Liability. In no event and under no legal theory, 190 + whether in tort (including negligence), contract, or otherwise, 191 + unless required by applicable law (such as deliberate and grossly 192 + negligent acts) or agreed to in writing, shall any Contributor be 193 + liable to You for damages, including any direct, indirect, special, 194 + incidental, or consequential damages of any character arising as a 195 + result of this License or out of the use or inability to use the 196 + Work (including but not limited to damages for loss of goodwill, 197 + work stoppage, computer failure or malfunction, or any and all 198 + other commercial damages or losses), even if such Contributor 199 + has been advised of the possibility of such damages. 200 + 201 + 9. Accepting Warranty or Additional Liability. While redistributing 202 + the Work or Derivative Works thereof, You may choose to offer, 203 + and charge a fee for, acceptance of support, warranty, indemnity, 204 + or other liability obligations and/or rights consistent with this 205 + License. However, in accepting such obligations, You may act only 206 + on Your own behalf and on Your sole responsibility, not on behalf 207 + of any other Contributor, and only if You agree to indemnify, 208 + defend, and hold each Contributor harmless for any liability 209 + incurred by, or claims asserted against, such Contributor by reason 210 + of your accepting any such warranty or additional liability. 211 + 212 + END OF TERMS AND CONDITIONS 213 + 214 + APPENDIX: How to apply the Apache License to your work. 215 + 216 + To apply the Apache License to your work, attach the following 217 + boilerplate notice, with the fields enclosed by brackets "[]" 218 + replaced with your own identifying information. (Don't include 219 + the brackets!) The text should be enclosed in the appropriate 220 + comment syntax for the file format. We also recommend that a 221 + file or class name and description of purpose be included on the 222 + same "printed page" as the copyright notice for easier 223 + identification within third-party archives. 224 + 225 + Copyright [yyyy] [name of copyright owner] 226 + 227 + Licensed under the Apache License, Version 2.0 (the "License"); 228 + you may not use this file except in compliance with the License. 229 + You may obtain a copy of the License at 230 + 231 + http://www.apache.org/licenses/LICENSE-2.0 232 + 233 + Unless required by applicable law or agreed to in writing, software 234 + distributed under the License is distributed on an "AS IS" BASIS, 235 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 236 + See the License for the specific language governing permissions and 237 + limitations under the License.
+1
README.md
··· 1 + # ATPasser
+135
poetry.lock
··· 1 + # This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. 2 + 3 + [[package]] 4 + name = "base58" 5 + version = "1.0.3" 6 + description = "Base58 and Base58Check implementation" 7 + optional = false 8 + python-versions = "*" 9 + groups = ["main"] 10 + files = [ 11 + {file = "base58-1.0.3-py2-none-any.whl", hash = "sha256:1e42993c0628ed4f898c03b522b26af78fb05115732549b21a028bc4633d19ab"}, 12 + {file = "base58-1.0.3-py3-none-any.whl", hash = "sha256:6aa0553e477478993588303c54659d15e3c17ae062508c854a8b752d07c716bd"}, 13 + {file = "base58-1.0.3.tar.gz", hash = "sha256:9a793c599979c497800eb414c852b80866f28daaed5494703fc129592cc83e60"}, 14 + ] 15 + 16 + [[package]] 17 + name = "morphys" 18 + version = "1.0" 19 + description = "Smart conversions between unicode and bytes types for common cases" 20 + optional = false 21 + python-versions = "*" 22 + groups = ["main"] 23 + files = [ 24 + {file = "morphys-1.0-py2.py3-none-any.whl", hash = "sha256:76d6dbaa4d65f597e59d332c81da786d83e4669387b9b2a750cfec74e7beec20"}, 25 + ] 26 + 27 + [[package]] 28 + name = "py-cid" 29 + version = "0.3.0" 30 + description = "Self-describing content-addressed identifiers for distributed systems" 31 + optional = false 32 + python-versions = "*" 33 + groups = ["main"] 34 + files = [ 35 + {file = "py-cid-0.3.0.tar.gz", hash = "sha256:22f432cc6fb68d12a9c35dbdc92c95484fc49e31dfcb9e0efb0082233c5394e3"}, 36 + {file = "py_cid-0.3.0-py2.py3-none-any.whl", hash = "sha256:7c48a6ee0bc50fd114d4b24849cd689a31d3ad5bdf8fa073bf68f846fd58c5da"}, 37 + ] 38 + 39 + [package.dependencies] 40 + base58 = ">=1.0.2,<2.0" 41 + morphys = ">=1.0,<2.0" 42 + py-multibase = ">=1.0.0,<2.0.0" 43 + py-multicodec = "<0.3.0" 44 + py-multihash = ">=0.2.0,<1.0.0" 45 + 46 + [[package]] 47 + name = "py-multibase" 48 + version = "1.0.3" 49 + description = "Multibase implementation for Python" 50 + optional = false 51 + python-versions = "*" 52 + groups = ["main"] 53 + files = [ 54 + {file = "py-multibase-1.0.3.tar.gz", hash = "sha256:d28a20efcbb61eec28f55827a0bf329c7cea80fffd933aecaea6ae8431267fe4"}, 55 + {file = "py_multibase-1.0.3-py2.py3-none-any.whl", hash = "sha256:2677c1fafcc0ae15ddb9c7f444c5becc2530b3889124fd4fa2959ddfefb8c15b"}, 56 + ] 57 + 58 + [package.dependencies] 59 + morphys = ">=1.0,<2.0" 60 + python-baseconv = ">=1.2.0,<2.0" 61 + six = ">=1.10.0,<2.0" 62 + 63 + [[package]] 64 + name = "py-multicodec" 65 + version = "0.2.1" 66 + description = "Multicodec implementation in Python" 67 + optional = false 68 + python-versions = "*" 69 + groups = ["main"] 70 + files = [ 71 + {file = "py-multicodec-0.2.1.tar.gz", hash = "sha256:83021ffe8c0e272d19b5b86bc5b39efa67c8e9f4735ce6cafdbc1ace767ec647"}, 72 + {file = "py_multicodec-0.2.1-py2.py3-none-any.whl", hash = "sha256:55b6bb53088a63e56c434cb11b29795e8805652bac43d50a8f2a9bcf5ca84e1f"}, 73 + ] 74 + 75 + [package.dependencies] 76 + morphys = ">=1.0,<2.0" 77 + six = ">=1.10.0,<2.0" 78 + varint = ">=1.0.2,<2.0.0" 79 + 80 + [[package]] 81 + name = "py-multihash" 82 + version = "0.2.3" 83 + description = "Multihash implementation in Python" 84 + optional = false 85 + python-versions = "*" 86 + groups = ["main"] 87 + files = [ 88 + {file = "py-multihash-0.2.3.tar.gz", hash = "sha256:f0ade4de820afdc4b4aaa40464ec86c9da5cae3a4578cda2daab4b0eb7e5b18d"}, 89 + {file = "py_multihash-0.2.3-py2.py3-none-any.whl", hash = "sha256:a0602c99093587dfbf1634e2e8c7726de39374b0d68587a36093b4c237af6969"}, 90 + ] 91 + 92 + [package.dependencies] 93 + base58 = ">=1.0.2,<2.0" 94 + morphys = ">=1.0,<2.0" 95 + six = ">=1.10.0,<2.0" 96 + varint = ">=1.0.2,<2.0" 97 + 98 + [[package]] 99 + name = "python-baseconv" 100 + version = "1.2.2" 101 + description = "Convert numbers from base 10 integers to base X strings and back again." 102 + optional = false 103 + python-versions = "*" 104 + groups = ["main"] 105 + files = [ 106 + {file = "python-baseconv-1.2.2.tar.gz", hash = "sha256:0539f8bd0464013b05ad62e0a1673f0ac9086c76b43ebf9f833053527cd9931b"}, 107 + ] 108 + 109 + [[package]] 110 + name = "six" 111 + version = "1.17.0" 112 + description = "Python 2 and 3 compatibility utilities" 113 + optional = false 114 + python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" 115 + groups = ["main"] 116 + files = [ 117 + {file = "six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274"}, 118 + {file = "six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81"}, 119 + ] 120 + 121 + [[package]] 122 + name = "varint" 123 + version = "1.0.2" 124 + description = "Simple python varint implementation" 125 + optional = false 126 + python-versions = "*" 127 + groups = ["main"] 128 + files = [ 129 + {file = "varint-1.0.2.tar.gz", hash = "sha256:a6ecc02377ac5ee9d65a6a8ad45c9ff1dac8ccee19400a5950fb51d594214ca5"}, 130 + ] 131 + 132 + [metadata] 133 + lock-version = "2.1" 134 + python-versions = ">=3.13" 135 + content-hash = "580be38abacc718e9e95506ce516be696f017971d15c70d8e89dfa6f23ac70b5"
+18
pyproject.toml
··· 1 + [project] 2 + name = "atpasser" 3 + version = "0.1.0" 4 + description = "Tools for ATProto" 5 + authors = [{ name = "diaowinner", email = "diaowinner@qq.com" }] 6 + readme = "README.md" 7 + requires-python = ">=3.13" 8 + dependencies = ["py-cid (>=0.3.0,<0.4.0)"] 9 + license = "MIT OR Apache-2.0" 10 + license-files = ["LICEN[CS]E.*"] 11 + 12 + [tool.poetry] 13 + packages = [{ include = "atpasser", from = "src" }] 14 + 15 + 16 + [build-system] 17 + requires = ["poetry-core>=2.0.0,<3.0.0"] 18 + build-backend = "poetry.core.masonry.api"
src/atpasser/__init__.py

This is a binary file and will not be displayed.

+179
src/atpasser/dataFormatter/__init__.py
··· 1 + import base64 # Converts between Base64 and byte object 2 + from cid import CIDv0, CIDv1, cid, make_cid # Converts CID to/from object 3 + import json 4 + 5 + # JSON is a string, however we uses the term JSON for dicts which read 6 + # directly using the json library itself, and data for dicts that are 7 + # friendly to Python by implementing bytes and CID support *or* data with 8 + # a type 9 + 10 + 11 + class Data: 12 + """ 13 + Data with a type. 14 + """ 15 + 16 + def __init__(self, type: str, content: dict) -> None: 17 + self.type = type 18 + self.content = jsonToData(content) 19 + 20 + 21 + def jsonToData(json): 22 + """ 23 + Convert 'JSON' to 'data' 24 + """ 25 + if isinstance(json, dict): 26 + if "$bytes" in json: # bytes shown as `$bytes` object in JSON 27 + bytesInB64 = json["$bytes"] 28 + return base64.b64decode(bytesInB64) 29 + elif "$link" in json: # CID link 30 + cidInString = json["$link"] 31 + return make_cid(cidInString) 32 + elif "$type" in json: # data have their lexicons 33 + type = json["$type"] 34 + del json["$type"] # loop if we don't del 35 + return Data(type, json) 36 + else: # general dict 37 + result = {} 38 + for item in json: 39 + result[item] = jsonToData(json[item]) 40 + return result 41 + elif isinstance(json, (list, tuple, set)): # only lists are valid 42 + return [jsonToData(item) for item in json] 43 + else: 44 + return json 45 + 46 + 47 + def dataToJson(data): 48 + """ 49 + Convert 'data' to 'JSON' 50 + """ 51 + if isinstance(data, bytes): # bytes 52 + return {"$bytes": base64.b64encode(data)} 53 + elif isinstance(data, (CIDv0, CIDv1)): # CID link 54 + return {"$link": str(data)} 55 + elif isinstance(data, dict): # general dict 56 + result = {} 57 + for item in data: 58 + result[item] = dataToJson(data[item]) 59 + return result 60 + elif isinstance(data, (list, tuple, set)): # only lists are valid 61 + return [dataToJson(item) for item in data] 62 + else: 63 + return data 64 + 65 + 66 + # We should need a wrapper, converts REAL json TEXT/FILE to so-called data 67 + 68 + 69 + def dump( 70 + obj, 71 + fp, 72 + *w, 73 + skipkeys=False, 74 + ensure_ascii=True, 75 + check_circular=True, 76 + allow_nan=True, 77 + cls=None, 78 + indent=None, 79 + separators=None, 80 + default=None, 81 + sort_keys=False, 82 + **kw 83 + ): 84 + """ 85 + json.dump() like function which replaces json to data instead 86 + """ 87 + json_result = dataToJson(obj) 88 + json.dump( 89 + json_result, 90 + fp, 91 + *w, 92 + skipkeys=skipkeys, 93 + ensure_ascii=ensure_ascii, 94 + check_circular=check_circular, 95 + allow_nan=allow_nan, 96 + cls=cls, 97 + indent=indent, 98 + separators=separators, 99 + default=default, 100 + sort_keys=sort_keys, 101 + **kw, 102 + ) 103 + 104 + 105 + def dumps( 106 + obj, 107 + *w, 108 + skipkeys=False, 109 + ensure_ascii=True, 110 + check_circular=True, 111 + allow_nan=True, 112 + cls=None, 113 + indent=None, 114 + separators=None, 115 + default=None, 116 + sort_keys=False, 117 + **kw 118 + ): 119 + """ 120 + json.dumps() like function which replaces json to data instead 121 + """ 122 + json_result = dataToJson(obj) 123 + json.dumps( 124 + json_result, 125 + *w, 126 + skipkeys=skipkeys, 127 + ensure_ascii=ensure_ascii, 128 + check_circular=check_circular, 129 + allow_nan=allow_nan, 130 + cls=cls, 131 + indent=indent, 132 + separators=separators, 133 + default=default, 134 + sort_keys=sort_keys, 135 + **kw, 136 + ) 137 + 138 + 139 + def load( 140 + fp, 141 + *w, 142 + cls=None, 143 + object_hook=None, 144 + parse_float=None, 145 + parse_int=None, 146 + parse_constant=None, 147 + object_pairs_hook=None, 148 + **kw 149 + ): 150 + """ 151 + json.load() like function which replaces json to data instead 152 + """ 153 + result = json.load( 154 + fp, 155 + *w, 156 + cls=cls, 157 + object_hook=object_hook, 158 + parse_float=parse_float, 159 + parse_int=parse_int, 160 + parse_constant=parse_constant, 161 + object_pairs_hook=object_pairs_hook, 162 + **kw, 163 + ) 164 + return jsonToData(result) 165 + 166 + 167 + def loads( 168 + s, 169 + *w, 170 + cls=None, 171 + object_hook=None, 172 + parse_float=None, 173 + parse_int=None, 174 + parse_constant=None, 175 + object_pairs_hook=None, 176 + **kw 177 + ): 178 + result = json.loads(s,*w,cls=cls,object_hook=object_hook,parse_float=parse_float,parse_int=parse_int,parse_constant=parse_constant,object_pairs_hook=object_pairs_hook,**kw) 179 + return jsonToData(result)
tests/__init__.py

This is a binary file and will not be displayed.