Skip to main content

Anson for Python3

Project description

PyPI version

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anson_py3-0.4.3.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anson_py3-0.4.3-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file anson_py3-0.4.3.tar.gz.

File metadata

  • Download URL: anson_py3-0.4.3.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.1

File hashes

Hashes for anson_py3-0.4.3.tar.gz
Algorithm Hash digest
SHA256 133b1e84a7b8873d8e358497c596c929aad0e2fd0a18dea01f7f811c3871566b
MD5 3233050ef8cb940000a5e60f9ebb6d51
BLAKE2b-256 e9501203abda5e72202eef9d2d8fc1adb386fdf895d9bdccf8280db331e4e638

See more details on using hashes here.

File details

Details for the file anson_py3-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: anson_py3-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.1

File hashes

Hashes for anson_py3-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c48b7b41bd5c11a092d8816f28c79ff3c1344c79aeca3678ad0060faa47e2204
MD5 94f5c9b44cab1994001db50f294a0670
BLAKE2b-256 42b96d5855da39648632f5a9c2d7f75bab38624ed7dda093a963e29f8fd8aac9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page