Package: icemac.songbeamer
icemac.songbeamerLibrary to read and writeSongBeamerfiles.This package is licensed under the MIT License, see LICENSE.TXT inside the
package.Contentsicemac.songbeamerSupported SongBeamer versionsSupported Python versionRunning TestsHackingChanges1.0 (2018-11-02)Backwards incompatible changesFeatures0.3 (2018-10-07)0.2.0 (2012-10-31)0.1.0 (2012-05-05)To doImplementationsOpen QuestionsUsageImporting a .sng fileAccessing a file’s dataExporting a .sng fileSupported SongBeamer versionsCurrently Songbeamer versions 2 to 4 are supported. (Internal version
number in .sng files:#Version=3.)Supported Python versionRuns only on Python 3.7. Older Python versions are not supported.Running TestsTo run the tests call:$ tox(You maybe have to installtoxbeforehand using:pip install tox.)HackingFork me on:https://github.com:/icemac/icemac.songbeamerChanges1.0 (2018-11-02)Backwards incompatible changesTheicemac.songbeamer.SNGinstances no longer store the data on thedataattribute but it now behaves like adictthus allowing direct dict
access to the data.It is no longer possible to use attributes onicemac.songbeamer.SNGinstances to read and store encoded bytes data. Either read/write text data
from/to theicemac.songbeamer.SNGinstance using thedictAPI or use
theparsefunction (see next item) to import resp. use.SNG.export()to export the data encoded.Add a functionicemac.songbeamer.parse()converting a byte stream
into aicemac.songbeamer.SNGinstance. It replaces the class method on
theSNGinstance. It returnsNoneif 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.FeaturesAdd a functionicemac.songbeamer.open()to open a file given by a path
and get aicemac.songbeamer.SNGinstance.Make.SNG.export()robust against missing text in songs.Add a command line scriptsongbeamer-xls-exportexporting titles and song
book numbers from folder containing SongBeamer files to an XLS file. To be
able to use iticemac.songbeamerhas to be installed with thexlsextra
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 doImplementationsimport/export of .col files (schedules)Open QuestionsAreTransposeandSpeedactually int values?UsageImporting a .sng fileTo import a.sngfile use theopenfunction in the moduleicemac.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 functionparsein 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 dataThe SNG instance extendsdictso the date is accessible via the usual
pythondictAPI:>>> 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 TemporaryFileTo export to a .sng file use theexportmethod. 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']