[英]How can I call the svn.client.svn_client_list2 with python SVN API SWIG bindings?
How do I call svn_client_list2
C API function from python via SVN API SWIG bindings? 如何通过SVN API SWIG绑定从python调用svn_client_list2
C API函数?
I can find that function from the svn.client
module, but calling it is the problem , because the callback function it uses is a typedef svn_client_list_func_t
and I don't know how to use that typedef in python. 我可以从svn.client
模块中找到该函数,但是调用它是个问题 ,因为它使用的回调函数是typedef svn_client_list_func_t
,我不知道如何在python中使用该typedef。
Although I can find a class for it from svn.client.svn_client_list_func_t
along with svn.client.svn_client_list_func_tPtr
, but I can't find an example of how to use it. 尽管我可以从svn.client.svn_client_list_func_t
以及svn.client.svn_client_list_func_tPtr
找到它的类,但是我找不到如何使用它的示例。
If you call the svn.client.svn_client_list2
function with a normal python function as callback parameter it gives you an error. 如果使用普通的python函数作为回调参数调用svn.client.svn_client_list2
函数,则会出现错误。
import svn.core, svn.client path = svn.core.svn_path_canonicalize("/path/to/a/working_copy/") pool = svn.core.Pool() ctx = svn.client.svn_client_create_context(pool) revision = svn.core.svn_opt_revision_t() SVN_DIRENT_ALL = 0xffffffffl def _handle_list(path, dirent, abs_path, pool): print(path, dirent, abs_path, pool) svn.client.svn_client_list2(path, revision, revision, svn.core.svn_depth_infinity, SVN_DIRENT_ALL, True, _handle_list, ctx, pool)
TypeError: argument number 7: a 'svn_client_list_func_t *' is expected, 'function(<function _handle_list at 0x01365270>)' is received
Trying to initialize the svn.client.svn_client_list_func_t
will result to an exception. 尝试初始化svn.client.svn_client_list_func_t
将导致异常。
callback_function = svn.client.svn_client_list_func_t()
RuntimeError: No constructor defined
Ideas how I can proceed? 我如何进行想法?
It looks like you can't really do this at the moment. 看来您目前无法真正做到这一点。 When I dug into bit into the SWIG bindings code and documentation it says that when you're using target language functions as the callback function, you need a typemap for it as it says in the SWIG documentation : 当我深入研究SWIG绑定代码和文档时,它说,当您将目标语言函数用作回调函数时,就需要像SWIG文档中所述的那样为其输入类型图:
Although SWIG does not normally allow callback functions to be written in the target language, this can be accomplished with the use of typemaps and other advanced SWIG features. 尽管SWIG通常不允许使用目标语言编写回调函数,但是可以使用类型映射和其他高级SWIG功能来实现。
It looked like it was missing for Python... 似乎Python缺少它...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.