A pure Python library supporting Uniform eXchange Format, a plain text human readable optionally typed storage format.
Project description
Python UXF Library
For details of the Uniform eXchange Format (UXF) supported by this library, see the UXF Overview. (PyPI link to UXF Overview.)
The Python uxf library works out of the box with the standard library, and
will use dateutil if available.
- Install:
python3 -m pip install uxf - Run:
python3 -m uxf -h# this shows the command line help - Use:
import uxf# see theuxf.pymodule docs for the API
Most Python types convert losslessly to and from UXF types. In particular:
| Python Type | UXF type |
|---|---|
None |
null |
bool |
bool |
int |
int |
float |
real |
datetime.date |
date |
datetime.datetime |
datetime |
str |
str |
bytes |
bytes |
bytearray |
bytes |
uxf.List |
list |
uxf.Map |
map |
uxf.Table |
table |
A uxf.List is a Python collections.UserList subclass with .data (the
list), .comment and .vtype attributes. Similarly a uxf.Map is a Python
collections.UserDict subclass with .data (the dict), .comment,
.ktype, and .vtype attributes. The uxf.Table class has .records,
.comment, and .fields attributes; with .fields holding a list of
uxf.Field values (which each has a field name and type). In all cases a
type of None signifies that any type valid for the context may be used.
For complex numbers you could create a ttype such as: = Complex Real real Imag real. Then you could include single complex values like (Complex 1.5 7.2), or many of them such as (Complex 1.5 7.2 8.3 -9.4 14.8 0.6).
For custom types (e.g., enums; or as an alternative to using a ttype for
complex numbers, or for any other custom type), use uxf.add_converter().
See test_converters.py for examples.
For collection types such as set, frozenset, tuple, or
collections.deque, either manually convert to/from a List, or set
uxf.AutoConvertSequences = True, in which case any of these will be
automatically converted to a List when they are encountered. Of course,
these are one way conversions.
Using uxf as an executable (with python3 -m uxf ...) provides a means of
doing .uxf to .uxf conversions (e.g., compress or uncompress, or make
more human readable or more compact).
Installed alongside uxf.py is uxfconvert.py which might prove useful to
see how to use uxf. For example, uxfconvert.py can losslessly convert
.uxf to .json or .xml and back. It can also do some simple conversions
to and from .csv, to .ini, and to and from .sqlite, but these are
really to illustrate use of the uxf APIs. And also see the ../t/* test
files and the ../eg folder (for example, the ../eg/slides.uxf and
../eg/slides.py files).
If you just want to create a small standalone .pyz, simply copy
py/uxf.py as uxf.py into your project folder and inlude it in your
.pyz file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uxf-0.27.0.tar.gz.
File metadata
- Download URL: uxf-0.27.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.4.2 requests/2.22.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc1a8d8800449ee6fc080a795b081d54014a53dccafbbeeacd0ea728099684c
|
|
| MD5 |
b1a3579e360fc8d17d689f70a89ef718
|
|
| BLAKE2b-256 |
c059285122bbc89ba65391d0c1b93b70f558f1272b9c551c8f0b9784770f901e
|
File details
Details for the file uxf-0.27.0-py3-none-any.whl.
File metadata
- Download URL: uxf-0.27.0-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.4.2 requests/2.22.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0be8739f67a6a24d5bcd5fc94d7607dad7212bed6d8763c8357a868afd65cd3
|
|
| MD5 |
1b52b6918583c7b71b70ccce67d3b033
|
|
| BLAKE2b-256 |
981d042a68ddba127fe90c6482f9174ccae904576cdfc0f5fc9b36b82b1b554e
|