This project has been archived by its maintainers, and is no longer receiving any updates.
icemac.songbeamer
Library to read and write SongBeamer files.
This package is licensed under the MIT License, see LICENSE.TXT inside the package.
Supported SongBeamer versions
Currently Songbeamer versions 2 to 4 are supported. (Internal version number in .sng files: #Version=3.)
Supported Python version
Runs only on Python 3.7. Older Python versions are not supported.
Running Tests
To run the tests call:
$ tox
(You maybe have to install tox beforehand using: pip install tox.)
Hacking
Fork me on: https://github.com:/icemac/icemac.songbeamer
Changes
1.0 (2018-11-02)
Backwards incompatible changes
The icemac.songbeamer.SNG instances no longer store the data on the data attribute but it now behaves like a dict thus allowing direct dict access to the data.
It is no longer possible to use attributes on icemac.songbeamer.SNG instances to read and store encoded bytes data. Either read/write text data from/to the icemac.songbeamer.SNG instance using the dict API or use the parse function (see next item) to import resp. use .SNG.export() to export the data encoded.
Add a function icemac.songbeamer.parse() converting a byte stream into a icemac.songbeamer.SNG instance. It replaces the class method on the SNG instance. It returns None if the data cannot be parsed and it logs an error message.
Drop support for Python 3.5, 3.6 and PyPy3, thus only supporting Python 3.7 now.
Features
Add a function icemac.songbeamer.open() to open a file given by a path and get a icemac.songbeamer.SNG instance.
Make .SNG.export() robust against missing text in songs.
Add a command line script songbeamer-xls-export exporting titles and song book numbers from folder containing SongBeamer files to an XLS file. To be able to use it icemac.songbeamer has to be installed with the xls extra like this:
$ pip install "icemac.songbeamer[xls]"
Support UTF-8 encoded SongBeamer files starting with the UTF-8 BOM.
Change license from ZPL to MIT.
0.3 (2018-10-07)
Add support for Python 3.5 to 3.7 and PyPy3.
Drop support for Python 3.2 and 3.3.
0.2.0 (2012-10-31)
Add ability to parse bytes objects.
Sorting keys in export file to be compatible across Python 3.2 and 3.3.
0.1.0 (2012-05-05)
Initial public release.
To do
Implementations
import/export of .col files (schedules)
Open Questions
Are Transpose and Speed actually int values?
Usage
Importing a .sng file
To import a .sng file use the open function in the module icemac.songbeamer. It expects a filename and path and returns a SNG instance:
>>> import icemac.songbeamer >>> import pkg_resources >>> filename = pkg_resources.resource_filename( ... 'icemac.songbeamer.tests', 'example.sng') >>> sng = icemac.songbeamer.open(filename) >>> sng.__class__ <class 'icemac.songbeamer.sng.SNG'>
Alternatively there is a function parse in the same module which parses bytes (e. g. read from a binary file) into an SNG instance:
>>> with open(filename, 'rb') as file: ... sng = icemac.songbeamer.parse(file.read()) >>> sng.__class__ <class 'icemac.songbeamer.sng.SNG'>
Accessing a file’s data
The SNG instance extends dict so the date is accessible via the usual python dict API:
>>> from pprint import pprint
>>> pprint(sng)
{'Author': 'me',
'Text': ['La la la', '---', 'Lei lei lei'],
'Version': 3}
>>> sng['Title'] = 'Mÿ šôñg'
The values are stored as numbers resp. strings (text):
>>> sng['Version'] 3 >>> sng['Author'] 'me'
Exporting a .sng file
>>> from tempfile import TemporaryFile
To export to a .sng file use the export method. It expects a byte stream (io.BytesIO or open binary file) as argument to write into:
>>> with TemporaryFile() as file: ... sng.export(file) ... _ = file.seek(0) ... pprint(file.readlines()) [b'#Author=me\r\n', b'#Title=M\xff \x9a\xf4\xf1g\r\n', b'#Version=3\r\n', b'---\r\n', b'La la la\r\n', b'---\r\n', b'Lei lei lei']
Release files for icemac.songbeamer 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| icemac.songbeamer-1.0.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| icemac.songbeamer-1.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 26.8 kB
Release files / icemac.songbeamer-1.0.tar.gz
| Download URL | icemac.songbeamer-1.0.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ddb798612043e4cfae806a1a2914dd485c14ec56034195873a0786702373167
|
|
BLAKE2b-256 checksum How to use checksums |
bf15fd6db50d69c547e1fd558303c5c224b087a08b071221708bfaeae24d7e01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/2.7.15
|
Release files / icemac.songbeamer-1.0-py2.py3-none-any.whl
| Download URL | icemac.songbeamer-1.0-py2.py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5371e7c61fc4ccdbd767283d1d6f6013e0541cd88e8d990b75736a7df7a675c7
|
|
BLAKE2b-256 checksum How to use checksums |
04a22c657a0c3ba76b02d2b8797c07763399a969b5452117a34089ea2d9b9b71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.19.7 CPython/2.7.15
|