Skip to main content

Command Line Tool to Work with Transit Format

Project description

Documentation Status

Command Line Tool to Work with Transit Format

Features

  • convert to and form json, edn, transit
  • read content from stdin or files

Usage

$ transito -h
usage: transito [-h] {t2j,j2t,e2t,t2e,http} ...

Transit CLI

positional arguments:
  {t2j,j2t,e2t,t2e,http}
    t2j                 convert transit to json
    j2t                 convert json to transit
    e2t                 convert edn to transit
    t2e                 convert transit to edn
    http                make http requests with transit data

optional arguments:
  -h, --help            show this help message and exit

Conversions

Convert Transit to JSON from a file:

$ transito t2j examples/ex1.transit

[":keyword", "~lala", 1, 1.2, true, null, [], ["hi", "a"]]

Convert Transit to JSON from stdin:

$ transito t2j -

["~#list",["~:keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]
[":keyword", "~lala", 1, 1.2, true, null, [], ["hi", "a"]]

Note

The first line is the input, then I pressed Enter and Ctrl+D

Piping from another command:

$ echo '["~#list",["~:keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]' | transito t2j -

[":keyword", "~lala", 1, 1.2, true, null, [], ["hi", "a"]]

Same for Edn:

$ transito t2e examples/ex1.transit

(keyword lala 1 1.2 true nil [] ["hi" \a])
$ echo '["~#list",["~:keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]' | transito t2e -

(keyword lala 1 1.2 true nil [] ["hi" \a])
$ transito t2e -

["~#list",["~:keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]
(keyword lala 1 1.2 true nil [] ["hi" \a])

you should get the idea, some with transit as output just in case:

$ transito e2t -
(keyword lala 1 1.2 true nil [] ["hi" \a])
["~#list",["~$keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]

$ transito t2j -
["~#list",["~$keyword","~$lala",1,1.2,true,null,[],["hi",["~#char","a"]]]]
["~keyword", "~lala", 1, 1.2, true, null, [], ["hi", "a"]]

Note

to json conversions are lossy, this means that in order to not crash when serializing keywords, symbols and chars we do a lossy serialization, chars are strings, keywords are strings starting with : and symbols are strings starting with ~.

The idea of this translation is to provide a way to view the edn or transit as json and shouldn’t be used to send this data to a production system.

HTTP Requests

You an make an http request that supports transit, json or edn but writting and reading the request and response in a more readable way, for example, make a request writing edn that will be transformed to transit before being sent, the response will be transformed to edn if possible to make it more readable:

$ echo '(increment {:value 20})' | transito http post http://localhost:8080/action e2t -

Status: 200
Content-Type: application/transit+json
Content-Length: 28

{:value [:count]}

You may ask, isn’t it complected? yes, yes it is.

Credits

Tools used in rendering this package:

History

0.1.3 (2015-12-01)

  • add support for keywords with namespaces in edn

0.1.2 (2015-26-11)

  • fix edn encoding from transit on http response

0.1.1 (2015-25-11)

  • add support for http requests
  • fix keyword serialization in edn

0.1.0 (2015-25-11)

  • First release on PyPI.

Project details


Release history Release notifications

This version
History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
transito-0.1.6-py2.py3-none-any.whl (28.5 kB) Copy SHA256 hash SHA256 Wheel 2.7 Feb 26, 2016
transito-0.1.6.tar.gz (16.1 kB) Copy SHA256 hash SHA256 Source None Feb 26, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page