Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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 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

  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.
Release History

Release History

This version
History Node

0.9

History Node

0.8.2

History Node

0.8.1

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5.11

History Node

0.5.10

History Node

0.5.9

History Node

0.5.8

History Node

0.5.7

History Node

0.5.6

History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyaxon-0.9-cp27-cp27m-macosx_10_6_intel.whl (678.5 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jun 30, 2016
pyaxon-0.9-cp27-cp27m-win32.whl (289.8 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jun 30, 2016
pyaxon-0.9-cp27-cp27m-win_amd64.whl (331.2 kB) Copy SHA256 Checksum SHA256 cp27 Wheel Jun 30, 2016
pyaxon-0.9-cp33-cp33m-macosx_10_6_x86_64.whl (692.4 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jun 30, 2016
pyaxon-0.9-cp33-none-win32.whl (293.2 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jun 30, 2016
pyaxon-0.9-cp33-none-win_amd64.whl (330.7 kB) Copy SHA256 Checksum SHA256 cp33 Wheel Jun 30, 2016
pyaxon-0.9-cp34-cp34m-macosx_10_6_intel.whl (692.4 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jun 30, 2016
pyaxon-0.9-cp34-cp34m-win32.whl (293.4 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jun 30, 2016
pyaxon-0.9-cp34-cp34m-win_amd64.whl (332.3 kB) Copy SHA256 Checksum SHA256 cp34 Wheel Jun 30, 2016
pyaxon-0.9-cp35-cp35m-macosx_10_6_intel.whl (643.8 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jun 30, 2016
pyaxon-0.9-cp35-cp35m-win32.whl (285.3 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jun 30, 2016
pyaxon-0.9-cp35-cp35m-win_amd64.whl (334.1 kB) Copy SHA256 Checksum SHA256 cp35 Wheel Jun 30, 2016
pyaxon-0.9.tar.gz (438.0 kB) Copy SHA256 Checksum SHA256 Source Jun 30, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting