Anson.py3
Json (de)serialize module in Python 3.
from anson.io.odysz.anson import Anson
Install from testpypi
pip install anson.py3
Guide
- Mapping Java vs Python package structure
Python packages tree is in format of path/to/module/class, while java has no node of module:
├── io
│ └── oz
│ ├── jserv
│ │ └── docs
│ │ └── syn
│ │ └── singleton.py "class AppSettings"
│ └── syn.py "class AnRegistry, SynodeConfig, SynOrg, YellowPages"
Java packages tree:
.
└── io
└── oz
└── jserv
└── docs
└── syn
├── singleton
│ └── AppSettings.java
.
└── io
└── oz
└── syn
├── AnRegistry.java
├── SynodeConfig.java
├── SynOrg.java
└── YellowPages.java
Anson.py3 is using package name path with a top level path. Say, if the json envelope define as
{ type: io.oz.syn.AnRegistry,
...
}
and the user's project include two parts:
- The semantics.py3 name space for json protocol package, the user types.
Which is currently need to be manually keep all fields the same with the java end. Start the project from the source:
github.com/odys-z/antson/semantics.py3
You need use the following commands to build and install it, so it can be imported to the application project.
python -m build
pip install dist/semantics_py3-#.#.#-py3-none-any.whl
- The (client end) source project for applications.
In main.py, call
from semanticshare.your.package import Your_class
Issues
- Printing Anson subclasses with non-default field without value initialization will result in errors
If SynOrg.parent is defined as
class SynOrg(Anson)
parent: str
def __init__(self):
super().__init__()
org = Anson.from_file(...)
print (org)
Error
Traceback (most recent call last):
File "/home/antson/py3/test/testYellowPages.py", line 18, in testAnregistry
print(diction)
File "/usr/lib/python3.12/dataclasses.py", line 262, in wrapper
result = user_function(self)
^^^^^^^^^^^^^^^^^^^
File "<string>", line 3, in __repr__
File "/usr/lib/python3.12/dataclasses.py", line 262, in wrapper
result = user_function(self)
^^^^^^^^^^^^^^^^^^^
File "<string>", line 3, in __repr__
File "/usr/lib/python3.12/dataclasses.py", line 262, in wrapper
result = user_function(self)
^^^^^^^^^^^^^^^^^^^
File "<string>", line 3, in __repr__
AttributeError: 'SynOrg' object has no attribute 'parent'
References
Troubleshootings
.pypirc
[testpypi]
repository: https://test.pypi.org/legacy/
username = __token__
password = pypi-zzz
python3 -m twine --version
twine version 6.1.0 (keyring: 25.6.0, packaging: 24.2, requests: 2.31.0, requests-toolbelt: 1.0.0,
urllib3: 2.0.7, id: 1.5.0)
python3 -m build
python3 -m twine upload --repository testpypi dist/*
ERROR InvalidDistribution: Invalid distribution metadata: unrecognized or malformed field
'license-file'; unrecognized or malformed field 'license-expression'
Install twine 6.1.0 and packaging 24.
pip install packaging -U
See issue #1216.
Metadata
Release files for anson.py3 0.5.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| anson_py3-0.5.8.tar.gz | 33.3 kB | Without provenance | Details for anson_py3-0.5.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| anson_py3-0.5.8-py3-none-any.whl | Python 3 | none | any | Details for anson_py3-0.5.8-py3-none-any.whl |
Total release size: 59.1 kB
Release files / anson_py3-0.5.8.tar.gz
| Download URL | anson_py3-0.5.8.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05798a8bdcc2a288c802ce4c189106906330729f8e7639c9d5cc6d211ecb177c
|
|
BLAKE2b-256 checksum How to use checksums |
33f15c71b00207a5622501aea9dc404e7f99912d5f6e5a035f64740a060d6119
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.1
|
Release files / anson_py3-0.5.8-py3-none-any.whl
| Download URL | anson_py3-0.5.8-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
004ed8908a2436256ee285c3e97b1c7ea7a4cb163f140e5c048506cb082bab98
|
|
BLAKE2b-256 checksum How to use checksums |
3ea9fc884751227a0ff9b714b004ce33006ceae9c51fc672936b16c4dfa82a24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.1
|
Security for anson.py3 0.5.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.