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.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')
>>> 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 Distribution

pyaxon-0.8.tar.gz (411.7 kB view details)

Uploaded Source

Built Distributions

pyaxon-0.8-cp34-none-win_amd64.whl (299.4 kB view details)

Uploaded CPython 3.4Windows x86-64

pyaxon-0.8-cp34-none-win32.whl (271.4 kB view details)

Uploaded CPython 3.4Windows x86

pyaxon-0.8-cp34-cp34m-macosx_10_6_intel.whl (654.9 kB view details)

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

pyaxon-0.8-cp33-none-win_amd64.whl (299.3 kB view details)

Uploaded CPython 3.3Windows x86-64

pyaxon-0.8-cp33-none-win32.whl (271.3 kB view details)

Uploaded CPython 3.3Windows x86

pyaxon-0.8-cp33-cp33m-macosx_10_6_intel.whl (654.6 kB view details)

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

pyaxon-0.8-cp27-none-win_amd64.whl (298.9 kB view details)

Uploaded CPython 2.7Windows x86-64

pyaxon-0.8-cp27-none-win32.whl (267.1 kB view details)

Uploaded CPython 2.7Windows x86

pyaxon-0.8-cp27-none-macosx_10_6_intel.whl (641.0 kB view details)

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

File details

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

File metadata

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

File hashes

Hashes for pyaxon-0.8.tar.gz
Algorithm Hash digest
SHA256 eb0d8331bd0045b7208d055f993edc5d0cd6a9020b9eb88a5225a118ab7a9489
MD5 ec6e46a734190f0e8ae840958e84f1ea
BLAKE2b-256 4422c8ed851e14c151058389242085e9d6c174b584b5f6b99ffc99dc35ff33b6

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp34-none-win_amd64.whl.

File metadata

File hashes

Hashes for pyaxon-0.8-cp34-none-win_amd64.whl
Algorithm Hash digest
SHA256 1abdd14321807d0158fdf30e8b69b554f13298b78bd271423e94169f89f3e9d8
MD5 3314148bcb4ecd41f8e160176cbf02cc
BLAKE2b-256 2ba9d7e8666a25e9da237f0497531d3e372997783c25d0d71c0a13595e760745

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp34-none-win32.whl.

File metadata

  • Download URL: pyaxon-0.8-cp34-none-win32.whl
  • Upload date:
  • Size: 271.4 kB
  • Tags: CPython 3.4, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.8-cp34-none-win32.whl
Algorithm Hash digest
SHA256 fe54175fa67743e28e43174bba208ca27b38e496f43fb75118e70941af0cd67d
MD5 fe3d22c8e150a9f113ccf2af83d40734
BLAKE2b-256 34f656501f33eb8895abb0334ffb8e957d7774a44ffe8f774b387aae8468d773

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyaxon-0.8-cp34-cp34m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 09b3535f0b17d0d29256e73565bf7978804e061b596352b6a0ab473a02094282
MD5 56fdb45abbdeb398018dd890783777f2
BLAKE2b-256 286c07fabc80c91c8bcd55606660add6777942d44f873b21f0e83cc93cdcf69c

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp33-none-win_amd64.whl.

File metadata

File hashes

Hashes for pyaxon-0.8-cp33-none-win_amd64.whl
Algorithm Hash digest
SHA256 d17beee3f0f4ea4d3d9ef20f4f6d34fa62d8a59d08470d2eaae7d5e97617ea6a
MD5 882f197f3df68e28c2af7e5d8f86b1c7
BLAKE2b-256 c89e8feab5fcbf4aaa80ea24a21618d29abfd5c869a9a355ce047372b2ede4d1

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp33-none-win32.whl.

File metadata

  • Download URL: pyaxon-0.8-cp33-none-win32.whl
  • Upload date:
  • Size: 271.3 kB
  • Tags: CPython 3.3, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.8-cp33-none-win32.whl
Algorithm Hash digest
SHA256 2ee43e2ac6865fe3eb2a6c66579a848bfebd4441841d159548e199057d162d99
MD5 fb9166deecc5998e1171333cadd936b0
BLAKE2b-256 10c591928325a3401d61a8f2ab379c3183f14034f50464a229267818d40dd995

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyaxon-0.8-cp33-cp33m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 15119878f3f13f9130c7344c5898b36662a30c592fa897cf24ab26db2fd11882
MD5 ee048f1d19f8108b0fdc80b14f80122a
BLAKE2b-256 5e971c4636bcb3d98d8fec009b31ed64c85f8ccc7b853e6810c11db86e219bb7

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp27-none-win_amd64.whl.

File metadata

File hashes

Hashes for pyaxon-0.8-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 9081c034f963bc40c0e1372647e6c2ccd7c06ae793b4bd0aba8a665b6523fde1
MD5 887849517e572bb8761728f60f15a033
BLAKE2b-256 9952b1107ebce62a9bfa97e0d69f8055e7abbeb2502e1626bf02cf2f1d036b96

See more details on using hashes here.

File details

Details for the file pyaxon-0.8-cp27-none-win32.whl.

File metadata

  • Download URL: pyaxon-0.8-cp27-none-win32.whl
  • Upload date:
  • Size: 267.1 kB
  • Tags: CPython 2.7, Windows x86
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyaxon-0.8-cp27-none-win32.whl
Algorithm Hash digest
SHA256 62812dc639917bb192a863edb318419bbb43617c0d4df790c87c06995596cd2d
MD5 969c88e97ecd527121fc1c43e2cd0bcc
BLAKE2b-256 952bdb13c1753515526d6c1810e063f6c8196e08e307449b868dff67612e84ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyaxon-0.8-cp27-none-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 7c3f23ba359474a8a3c24ed72e0fd85a870264345ac8b59488622e24b9d96f37
MD5 775e8c7e9d3f8721de2a2a1217597ce3
BLAKE2b-256 8b7716389a300e9febcb9d1af33c2b4fce415bad6bb55614523bb58f6b606c84

See more details on using hashes here.

Supported by

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