要从SongBeamer格式导入和导出的Python3库。

icemac.songbeamer的Python项目详细描述


icemac.songbeamer

https://travis-ci.com/icemac/icemac.songbeamer.svg?branch=masterhttps://coveralls.io/repos/github/icemac/icemac.songbeamer/badge.svg?branch=master

用于读取和写入SongBeamer文件的库。

此软件包是在麻省理工学院许可下授权的,请参阅 包裹。

Supported SongBeamer versions

目前支持SongBeamer版本2到4。(内部版本 .sng文件中的编号:#Version=3

Supported Python version

仅在Python3.7上运行。不支持旧的python版本。

Running Tests

要运行测试,请调用:

$ tox

(您可能必须事先使用:pip install tox安装tox

Changes

1.0 (2018-11-02)

Backwards incompatible changes

  • icemac.songbeamer.SNG实例不再将数据存储在 data属性,但它现在的行为类似于dict,因此允许直接dict 访问数据。
  • 无法再对^{tt3}使用属性$ 用于读取和存储编码字节数据的实例。读/写文本数据 使用dictapi或使用 要导入resp的parse函数(请参阅下一项)。使用.SNG.export() 导出编码的数据。
  • 添加函数icemac.songbeamer.parse()转换字节流 变成一个icemac.songbeamer.SNG实例。它替换了 sng实例。如果数据不能为None,则返回None。 分析并记录错误消息。
  • 放弃对Python3.5、3.6和PyPy3的支持,因此只支持Python3.7 现在。

Features

  • 添加函数icemac.songbeamer.open()以打开由路径给定的文件 并获取一个icemac.songbeamer.SNG实例。

  • 使.SNG.export()健壮,防止歌曲中缺少文本。

  • 添加命令行脚本 从包含SongBeamer文件的文件夹到XLS文件的书号。成为 要使用它,必须安装附加的xls 像这样:

    $ pip install "icemac.songbeamer[xls]"
    
  • 支持以utf-8bom开始的utf-8编码的songbeamer文件。

  • 将许可证从zpl更改为mit。

0.3 (2018-10-07)

  • 添加对Python3.5到3.7和PyPy3的支持。
  • 放弃对Python3.2和3.3的支持。

0.2.0 (2012-10-31)

  • 添加解析字节对象的功能。
  • 将导出文件中的键排序为与Python3.2和3.3兼容。

0.1.0 (2012-05-05)

  • 首次公开发行。

To do

Implementations

  • 导入/导出.col文件(计划)

Open Questions

  • 转置速度是否实际为int值?

Usage

Importing a .sng file

要导入.sng文件,请使用模块中的open函数 icemac.songbeamer。它需要一个文件名和路径并返回一个sng 实例:

>>> 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'>

或者,在同一个模块中有一个函数parse,用于解析 字节(例如从二进制文件读取)到sng实例:

>>> with open(filename, 'rb') as file:
...     sng = icemac.songbeamer.parse(file.read())
>>> sng.__class__
<class 'icemac.songbeamer.sng.SNG'>

Accessing a file’s data

sng实例扩展了dict,因此可以通过通常的 pythondictapi:

>>> from pprint import pprint
>>> pprint(sng)
{'Author': 'me',
 'Text': ['La la la', '---', 'Lei lei lei'],
 'Version': 3}
>>> sng['Title'] = 'Mÿ šôñg'

这些值分别以数字形式存储。字符串(文本):

>>> sng['Version']
3
>>> sng['Author']
'me'

Exporting a .sng file

>>> from tempfile import TemporaryFile

要导出到.sng文件,请使用export方法。它需要一个字节流 (io.bytesio或打开二进制文件)作为参数写入:

>>> 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']

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
c#Java Tcp服务器和。Net Tcp客户端的发送和接收问题   安卓应用程序上的java标记地理位置,其位置位于我周围5Km半径范围内。   向java添加对话框并检索html文件   当eclipse甚至无法打开时,java会在eclipse中更改不兼容的JVM   java中同一jframe中的jlabel和paintComponent   基于另一数组排序的java排序   java AADSTS7000012:该补助金是为另一个租户获得的   java在JSF中使用foreach循环   java如何通过maven为运行junit测试创建运行配置?   java Selenium webDriver不稳定错误堆栈跟踪   java有没有办法创建以键为大写的JSON对象?