Vestaboard client library
Project description
Vesta
Vesta is a Vestaboard client library for Python. It provides an API client and character encoding utilities.
Installation
Vesta requires Python 3.7 or later. It can be installed via PyPI:
$ python -m pip install vesta
It's only runtime dependency is the Requests library, which will be installed automatically.
Usage
API Client
The Client
type is initialized with an API key and secret:
>>> import vesta
>>> client = vesta.Client(API_KEY, API_SECRET)
Then, you can make API calls using one of the provided methods:
>>> client.get_viewer()
{'_id': ..., '_created': '1629081092624', 'type': 'installation', 'installation': {'_id': ...}}
>>> client.get_subscriptions()
[{'_id': ..., '_created': '1629081092624', 'title': None, 'icon': None, 'installation': {'_id': ..., 'installable': {'_id': ...}}, 'boards': [{'_id': ...}]}]
>>> client.post_message(SUBSCRIPTION_ID, "Hello, World")
{'message': {'id': ..., 'text': 'Hello, World', 'created': '1635801572442'}}
Character Encoding
All Vestaboard characters (letters, numbers, symbols, and colors) are encoded as integer character codes. Vesta includes some useful routines for working with these character codes.
encode()
encodes a string as a list of character codes. In addition to
printable characters, the string can contain character code sequences inside
curly braces, such as {5}
or {65}
.
>>> vesta.encode("{67} Hello, World {68}")
[67, 0, 8, 5, 12, 12, 15, 55, 0, 23, 15, 18, 12, 4, 0, 68]
encode_row()
encodes a string as a row of character codes. It builds on
encode()
by providing alignment control.
>>> vesta.encode_row("{67} Hello, World {68}", align="center")
[0, 0, 0, 67, 0, 8, 5, 12, 12, 15, 55, 0, 23, 15, 18, 12, 4, 0, 68, 0, 0, 0]
encode_text()
encodes a string of text into rows of character codes, further
building on encode()
and encode_row()
with the addition of alignment,
margin control, and line breaks.
>>> encode_text("multiple\nlines\nof\ntext", align="center", valign="middle")
[
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 13, 21, 12, 20, 9, 16, 12, 5, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 12, 9, 14, 5, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 5, 24, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
]
Lastly, pprint()
can be used to pretty-print encoded characters to the
console, which can be useful during development.
>>> vesta.pprint([0, 0, 0, 67, 0, 8, 5, 12, 12, 15, 55, 0, 23, 15, 18, 12, 4, 0, 68, 0, 0, 0])
| | | |◼︎| |H|E|L|L|O|,| |W|O|R|L|D| |◼︎| | | |
Message Posting
Messages can be posted as either text strings or two-dimensional arrays of character codes representing the exact positions of characters on the board.
If text is specified, lines will be centered horizontally and vertically if possible. Character codes will be inferred for alphanumeric and punctuation, or can be explicitly specified in-line in the message with curly braces containing the character code.
License
This project is licensed under the terms of the MIT license.
Copyright (c) 2021 Jon Parise jon@indelible.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Changelog
0.7.1 - 2021-12-19
Fixed
encode_text()
was adding a leading blank character to the row after a line break.
0.7.0 - 2021-12-19
Added
encode_text()
offers avalign
argument for controlling vertical alignment within the board.Client.post_message()
now raises ValueError ifmessage
is a list of encoded characters with the wrong dimensions.
Changed
encode_text()
now always produces six rows of output (a full board).
Removed
- Dropped support for Python 3.6, which has officially reached the end of its supported life.
0.6.0 - 2021-12-05
Added
encode_text()
for encoding lines of text
Fixed
- Fix space character encoding
0.5.1 - 2021-11-06
Added
- Initial Sphinx-based documentation
0.5.0 - 2021-11-01
- Initial release
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
File details
Details for the file vesta-0.7.1.tar.gz
.
File metadata
- Download URL: vesta-0.7.1.tar.gz
- Upload date:
- Size: 35.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23cf50eb0fdf478f3a479f997b519c7c3d30bd7051a6d9e28abfb4de3592e29b |
|
MD5 | 4a9ece147d3b83e9cac256ae341f8185 |
|
BLAKE2b-256 | b1d40bd4c4492097f46054edcf099d942880ec6acff7fe7c8b45b6feeb80bb63 |
Provenance
File details
Details for the file vesta-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: vesta-0.7.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a37bd9df066c2e159eb6c38bdb0fd87018608040b2d76a5bede03be9f27abe65 |
|
MD5 | 186a17f10b6f5858c4858de3e6d8b258 |
|
BLAKE2b-256 | 5b83a2ebb1732eec9e8089f156c3d35132f1644fc011fc16ad41767477839eb3 |