Skip to main content

Python library for AXON

Project description

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.

Installation

pyaxon runs under Python 2.7/3.3/3.4.

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':[]}]]
>>> text = axon.dumps(vals)
>>> print(text)
[{a:1 b:2 c:3} {a:[1 2 3] b:(1 2 3) c:[]}]
>>> text = axon.dumps(vals, pretty=1)
>>> print(text)
[ { a: 1
    b: 2
    c: 3}
  { a: [1 2 3]
    b: (1 2 3)
    c: []}]
>>> 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.Mapping'>
    >>> print(vals[0])
mapping('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:

lass 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',
                     [axon.attribute('name', p.name),
                      axon.attribute('age', p.age),
                      axon.attribute('email', p.email)])

@axon.factory('person')
def factory_Person(p):
    a1, a2, a3 = p
    return Person(p[0].value, p[1].value, p[2].value)

>>> 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')
>>> print(val.name==p.name, val.age==p.age, val.email==p.email)
True True True

Features

  1. Provide simple API for loading and dumping of objects in textual AXON format.

  2. Provide safe loading and dumping by default.

  3. Provide unsafe loading and dumping of objects on the base of registration of factory/reduce callables.

  4. Provide a way for fully controlled by application/framework/library unsafe loading and dumping.

  5. It’s sufficiently fast so as to be useful.

Project details


Download files

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

Source Distributions

pyaxon-0.6.zip (480.3 kB view details)

Uploaded Source

pyaxon-0.6.tar.gz (443.9 kB view details)

Uploaded Source

Built Distributions

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

pyaxon-0.6.win32-py3.4.exe (527.1 kB view details)

Uploaded Source

pyaxon-0.6.win32-py3.3.exe (528.5 kB view details)

Uploaded Source

pyaxon-0.6.win32-py2.7.exe (523.3 kB view details)

Uploaded Source

pyaxon-0.6-cp34-cp34m-macosx_10_6_intel.whl (746.7 kB view details)

Uploaded CPython 3.4mmacOS 10.6+ Intel (x86-64, i386)

pyaxon-0.6-cp33-cp33m-macosx_10_6_intel.whl (745.7 kB view details)

Uploaded CPython 3.3mmacOS 10.6+ Intel (x86-64, i386)

pyaxon-0.6-cp27-none-macosx_10_6_intel.whl (737.9 kB view details)

Uploaded CPython 2.7macOS 10.6+ Intel (x86-64, i386)

File details

Details for the file pyaxon-0.6.zip.

File metadata

  • Download URL: pyaxon-0.6.zip
  • Upload date:
  • Size: 480.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.6.zip
Algorithm Hash digest
SHA256 6df552da9fb34b4b5b37650b41cb2a4ac7b94021c81cf4806be72952cd2f004e
MD5 4ee4631fc5b3fd6a6ab0ea8f4b43b28e
BLAKE2b-256 7381d95ff135a966574755b94e696606e9855067c7095fe7b0cfbdd6c4b0766d

See more details on using hashes here.

File details

Details for the file pyaxon-0.6.tar.gz.

File metadata

  • Download URL: pyaxon-0.6.tar.gz
  • Upload date:
  • Size: 443.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.6.tar.gz
Algorithm Hash digest
SHA256 a1972dc72306e858c459ee6a4e8ece4683b23887f07d7a582b609e1dd1391010
MD5 cfb6ca731662533ddfe6ca88d8a3cdef
BLAKE2b-256 20b5bb8315db8371d4849b971d7ea90cc9e6392688a5efd4f7f691edf612926b

See more details on using hashes here.

File details

Details for the file pyaxon-0.6.win32-py3.4.exe.

File metadata

  • Download URL: pyaxon-0.6.win32-py3.4.exe
  • Upload date:
  • Size: 527.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.6.win32-py3.4.exe
Algorithm Hash digest
SHA256 a40ba16b952e41738616a7c473f71b492d5109fd0ba0a973317e81ddbc3522f6
MD5 5f71f67d0918bd031616aa1c41ea45e1
BLAKE2b-256 0fa881d1b72e468379e189c11df903c3a5d059bc9dbb605096e7d06de0517c5a

See more details on using hashes here.

File details

Details for the file pyaxon-0.6.win32-py3.3.exe.

File metadata

  • Download URL: pyaxon-0.6.win32-py3.3.exe
  • Upload date:
  • Size: 528.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.6.win32-py3.3.exe
Algorithm Hash digest
SHA256 b82c3ccc9572ec3fba5f52ce7aab929b09eff3c5d3844c6437344c490c89f7e4
MD5 595a5954333c47e99701bcadedbda765
BLAKE2b-256 77e292b83352f61546a335be4d7a20915b35f06f7af96397284795836acbb579

See more details on using hashes here.

File details

Details for the file pyaxon-0.6.win32-py2.7.exe.

File metadata

  • Download URL: pyaxon-0.6.win32-py2.7.exe
  • Upload date:
  • Size: 523.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.6.win32-py2.7.exe
Algorithm Hash digest
SHA256 c70c1c67476fbab7348c5e7eacc30bbba4a4db4157ac6487d3bd6148ea0d9614
MD5 d010f7ca0a569c4d712bd415ffedb6e3
BLAKE2b-256 cf9e22475916fcbb04af522c03b71dea4334ebcaf78b77803cb7851d5d8df1e7

See more details on using hashes here.

File details

Details for the file pyaxon-0.6-cp34-cp34m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pyaxon-0.6-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f8eccfde5945206a6f06f26ac1b2e36e1273c5c3702b15a6a354dbd95e4b2492
MD5 495e93199259f9ea3c8f80c763f0b6e9
BLAKE2b-256 bd65596565f70c4be76f9d0f784a3b85fe46b178aa0825c0043d744507389997

See more details on using hashes here.

File details

Details for the file pyaxon-0.6-cp33-cp33m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pyaxon-0.6-cp33-cp33m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 777d505d40a34c96287a4fc80027beaa9863ca22e1ce87be2b58c620c42bf65b
MD5 48d48331cd12a465439fb03ed2754884
BLAKE2b-256 d12b3715b4cddf8380d56177fb815303689e79f3ac18d6564b21de0fd1e0d7a4

See more details on using hashes here.

File details

Details for the file pyaxon-0.6-cp27-none-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pyaxon-0.6-cp27-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b572318bfd3928cc01a8c6505f3c0c2b7a0cf6dc92a3280c96a280e4dc7e3f6b
MD5 39ef84b2238f69e2d6e166f3f7bd2b1e
BLAKE2b-256 69881b8f8d62305cb53b4cea2dff002a73294e56d4ed11d46374be7529571e6a

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