PYAXON
pyaxon is an MIT Licensed python library for AXON. AXON is eXtended Object Notation. It’s a simple text based format for interchanging objects, documents and data. It tries to combine the best of JSON, XML and YAML.
links
Installation
pyaxon runs under Python 2.7, 3.3, 3.4 and 3.5
It can be installed via pip:
pip install pyaxon
It can be installed from sources:
python setup.py install
Quick start
First import axon module:
>>> import axon
Load and dump lists, dicts, tuples:
>>> from decimal import Decimal
>>> from datetime import datetime, time, date
>>> text = axon.dumps([['abc абв', 1, 3.14, True],
[datetime.now(), Decimal('3.14')]])
>>> print(text)
["abc абв" 1 3.14 true]
[^2015-05-12T13:08:37.078189 3.14D]
>>> vals = [{'id':1, 'nickname':'nick', 'time':time(12, 31, 34), 'text':'hello!'},
{'id':2, 'nickname':'mark', 'time':time(12, 32, 3), 'text':'hi!'}]
>>> text = axon.dumps(vals)
>>> print(text)
{id:1 nickname:"nick" text:"hello!" time:^12:31:34}
{id:2 nickname:"mark" text:"hi!" time:^12:32:03}
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
{ id: 1
nickname: "nick"
text: "hello!"
time: ^12:31:34}
{ id: 2
nickname: "mark"
text: "hi!"
time: ^12:32:03}
>>> vals == axon.loads(text)
True
>>> vals = [[{'a':1, 'b':2, 'c':3}, {'a':[1,2,3], 'b':(1,2,3), 'c':{1,2,3}}]]
>>> text = axon.dumps(vals)
>>> print(text)
[{a:1 b:2 c:3} {a:[1 2 3] b:(1 2 3) c:{1 2 3}}]
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
[ { a: 1
b: 2
c: 3}
{ a: [1 2 3]
b: (1 2 3)
c: {1 2 3}}]
>>> vals == axon.loads(text)
True
Dump, load objects in “safe” mode:
>>> vals = axon.loads('person{name:"nick" age:32 email:"nail@example.com"}')
>>> print(type(vals[0]))
<class 'axon._objects.Node'>
>>> print(vals[0])
node('person', {'email': 'nail@example.com', 'age': 32, 'name': 'nick'})
>>> text = axon.dumps(vals)
>>> print(text)
person{age:32 email:"nail@example.com" name:"nick"}
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
person
age: 32
email: "nail@example.com"
name: "nick"
>>> text = axon.dumps(vals, pretty=1, braces=1)
>>> print(text)
person {
age: 32
email: "nail@example.com"
name: "nick"}
Dump, load objects in unsafe mode:
class Person:
def __init__(self, name, age, email):
self.name = name
self.age = age
self.email = email
def __str__(self):
return "Person(name=%r, age=%r, email=%r)" % (self.name, self.age, self.email)
@axon.reduce(Person)
def reduce_Person(p):
return axon.node('person', {'name':p.name, 'age':p.age, 'email': p.email})
@axon.factory('person')
def factory_Person(attrs, vals):
return Person(name=attrs['name'], age=attrs['age'], email=attrs['email'])
>>> p = Person('nick', 32, 'mail@example.com')
>>> text = axon.dumps([p])
>>> print(text)
person{age:32 email:"mail@example.com" name:"nick"}
>>> val = axon.loads(text, mode='strict')[0]
>>> print(val)
Person(name='nick', age=32, email='mail@example.com')
Features
Provide simple API for loading and dumping of objects in textual AXON format.
Provide safe loading and dumping by default.
Provide unsafe loading and dumping of objects on the base of registration of factory/reduce callables.
Provide a way for fully controlled by application/framework/library unsafe loading and dumping.
It’s sufficiently fast so as to be useful.
Metadata
Release files for pyaxon 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyaxon-0.10-cp37-cp37m-macosx_10_9_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.9+ x86-64 | Details |
Release files / pyaxon-0.10-cp37-cp37m-macosx_10_9_x86_64.whl
| Download URL | pyaxon-0.10-cp37-cp37m-macosx_10_9_x86_64.whl |
|---|---|
| Size | 494.3 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
611dcc7f3a8bbd96d4920ec155e762202d79701b8a3dcfa714f129cccb037c4a
|
|
BLAKE2b-256 checksum How to use checksums |
74ec8524565bf6287e50b147c06d9399c8adf5a1f35f686d94243f340ede250b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Security for pyaxon 0.10
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.