问题描述
我的工作与几个音乐播放器整合。此刻我最喜欢的是exaile。
I am working on integrating with several music players. At the moment my favorite is exaile.
在新版本中它们从sqlite3的数据库格式迁移到内部味酸格式。我想知道是否有访问咸菜格式的文件,而无需逆向工程手工格式的方法。
In the new version they are migrating the database format from SQLite3 to an internal Pickle format. I wanted to know if there is a way to access pickle format files without having to reverse engineer the format by hand.
我知道是cPickle的Python模块,但我不知道,如果它是直接调用从C。
I know there is the cPickle python module, but I am unaware if it is callable directly from C.
推荐答案
有一个叫我帮助维持这可能是有用的PicklingTools库:它可以让你形成的数据结构在C ++中,你可以再泡菜/ unpickle ...这是C ++,不是C,但是这不应该是一个问题,这些天(假设你正在使用的GCC / G ++套件)。
There is a library called the PicklingTools which I help maintain which might be useful: it allows you to form data structures in C++ that you can then pickle/unpickle ... it is C++, not C, but that shouldn't be a problem these days (assuming you are using the gcc/g++ suite).
该库是一个普通的C ++库(有示出如何使用在从C ++和Python的插座和文件库中的分布内的C ++中的例子和Python),但在一般情况下,酸洗的文件的基础知识可用
The library is a plain C++ library (there are examples of C++ and Python within the distribution showing how to use the library over sockets and files from both C++ and Python), but in general, the basics of pickling to files is available.
其基本思想是PicklingTools库为您提供了从C蟒蛇般的数据结构+ +,这样你就可以序列化和反序列化到/ Python的/ C ++。 (?)所有基本类型:整型,长整型,字符串,无,复杂的,dictionarys,列表,有序字典和元组的支持。很少有钩子做自定义类,但是这部分是有点不成熟:库的其余部分是pretty稳定,一直活跃了8年。
The basic idea is that the PicklingTools library gives you "python-like" data structures from C++ so that you can then serialize and deserialize to/from Python/C++. All (?) the basic types: int, long int,string, None, complex, dictionarys, lists, ordered dictionaries and tuples are supported. There are few hooks to do custom classes, but that part is a bit immature: the rest of the library is pretty stable and has been active for 8 (?) years.
简单的例子:
#include "chooseser.h"
int main()
{
Val a_dict = Tab("{ 'a':1, 'b':[1,2.2,'three'], 'c':None }");
cout << a_dict["b"][0]; // value of 1
// Dump to a file
DumpValToFile(a_dict, "example.p0", SERIALIZE_P0);
// .. from Python, can load the dictionary with pickle.load(file('example.p0'))
// Get the result back
Val result;
LoadValFromFile(result, "example.p0", SERIALIZE_P0);
cout << result << endl;
}
有是在网站上更多的文件(常见问题解答和用户指南)。
There is further documentation (FAQ and User's Guide) on the web site.
希望这是有用的:
Gooday,
里奇
这篇关于我怎样才能读取从C蟒蛇咸菜数据库/文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!