Anson for Python3
Project description
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 tree is:
src
├── io
│ └── oz
│ ├── jserv
│ │ └── docs
│ │ └── syn
│ │ └── singleton.py "class AppSettings"
│ └── syn.py "class AnRegistry, SynodeConfig, SynOrg, YellowPages"
main.py
In main.py, call
Anson.java_src('src')
before
AnRegistry.from_file(path)
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
python3 -m twine upload --repository testpypi dist/*
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anson_py3-0.2.8.tar.gz.
File metadata
- Download URL: anson_py3-0.2.8.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1640c29a8886968917b4c4b3879ff5d3a6dbd4fb552143c9425646acc64a51ba
|
|
| MD5 |
39f95d84daebeae0d47a5a3306e6f978
|
|
| BLAKE2b-256 |
0d9e7e294af9fcaf2313a8d99e703c60a6e42c40ad78fb44d449d8f1eaf51e6e
|
File details
Details for the file anson_py3-0.2.8-py3-none-any.whl.
File metadata
- Download URL: anson_py3-0.2.8-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bccfc102e39c0ce9660aadc241dac860c0539b6de98846010f5a1e8d0a68027
|
|
| MD5 |
76d4397f41701e21828dcfc22b7f4616
|
|
| BLAKE2b-256 |
8a95bd409e5073df19f44f79886e554ad0fb4afc01fe7381dcb2e7a758391665
|