Ordered map parser and writer.¶
This package provides:
A library for reading and writing ordered maps.
A command line interface for converting an ordered map to YAML and vice versa.
Ordered maps are used in the Arduino platform software to handle configurations made of key/value pairs stored in files with an INI like syntax.
Please see ReadTheDocs for the latest documentation.
Introduction¶
This package provides a library for reading and writing ordered maps and a command line interface for converting an ordered map to YAML and vice versa.
Ordered maps are used in the Arduino platform software to handle configurations made of key/value pairs stored in files with an INI like syntax.
Installation¶
The software is distributed via PyPI, it can be installed with pip
:
pip install ordered-map
Usage¶
The command line interface can be used for converting an ordered map to a YAML
file or vice versa. It currently has two subcommands: read
and write
.
Use the -h
option for more information.
ordered_map -h
Reading ordered maps¶
The read
subcommand is used for reading an ordered map and converting it to
YAML.
ordered_map read boards.txt boards.yml
Writing ordered maps¶
The write
subcommand is used for reading a YAML file and converting it to
an ordered map.
ordered_map write boards.yml boards.txt
Command Line Interface¶
Ordered map parser and writer.
usage: ordered_map [-h] [-v] {read,write} ...
Positional Arguments¶
- subcommand
Possible choices: read, write
Named Arguments¶
- -v
show program’s version number and exit
Sub-commands:¶
Copyright (c) Jeroen F.J. Laros <jlaros@fixedpoint.nl>
Library¶
The API library provides the read
and write
functions.
>>> from ordered_map import read, write
The read
function reads an ordered map file string and returns a nested
dictionary.
>>> data = read(open('boards.txt').read())
>>> data['FTDI_PID_6001']['vid'][0]
'0x0403'
The write
function writes a nested dictionary to an ordered map file
string.
>>> open('/tmp/x.txt', 'w').write(write(data))
API documentation¶
- ordered_map.ordered_map.read(string: str) → dict¶
Parse an ordered map file.
- Parameters
string – Content of an ordered map file.
- Returns
An ordered map.
- ordered_map.ordered_map.write(data: dict) → str¶
Write an odered map to a file.
- Parameters
data – An ordered map.
- Returns
Content of an ordered map file.
Contributors¶
Jeroen F.J. Laros <jlaros@fixedpoint.nl> (Original author, maintainer)
Find out who contributed:
git shortlog -s -e