added missing python bindign for create_torrent

This commit is contained in:
Arvid Norberg
2009-02-21 08:39:26 +00:00
parent bed92597a9
commit 8ce5774307
5 changed files with 61 additions and 0 deletions

View File

@ -28,6 +28,10 @@
* added support for bitcomet padding files
* improved support for sparse files on windows
release 0.14.3
* added python binding for create_torrent
release 0.14.2
* added missing functions to the python bindings torrent_info::map_file,

View File

@ -36,6 +36,7 @@ python-extension libtorrent
: src/module.cpp
src/big_number.cpp
src/converters.cpp
src/create_torrent.cpp
src/fingerprint.cpp
src/utility.cpp
src/session.cpp

View File

@ -0,0 +1,53 @@
// Copyright Daniel Wallin & Arvid Norberg 2009. Use, modification and distribution is
// subject to the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python.hpp>
#include <libtorrent/create_torrent.hpp>
#include <libtorrent/file_storage.hpp>
#include "libtorrent/intrusive_ptr_base.hpp"
using namespace boost::python;
using namespace libtorrent;
void bind_create_torrent()
{
void (file_storage::*add_file0)(file_entry const&) = &file_storage::add_file;
void (file_storage::*add_file1)(fs::path const&, size_type) = &file_storage::add_file;
class_<file_storage>("file_storage")
.def("is_valid", &file_storage::is_valid)
.def("add_file", add_file0)
.def("add_file", add_file1)
.def("num_files", &file_storage::num_files)
.def("at", &file_storage::at, return_internal_reference<>())
.def("total_size", &file_storage::total_size)
.def("set_num_pieces", &file_storage::set_num_pieces)
.def("num_pieces", &file_storage::num_pieces)
.def("set_piece_length", &file_storage::set_piece_length)
.def("piece_length", &file_storage::piece_length)
.def("piece_size", &file_storage::piece_size)
.def("set_name", &file_storage::set_name)
.def("name", &file_storage::name, return_internal_reference<>())
;
class_<create_torrent>("create_torrent", no_init)
.def(init<file_storage&>())
.def(init<file_storage&, int>())
.def("generate", &create_torrent::generate)
.def("files", &create_torrent::files, return_internal_reference<>())
.def("set_comment", &create_torrent::set_comment)
.def("set_creator", &create_torrent::set_creator)
.def("set_hash", &create_torrent::set_hash)
.def("add_url_seed", &create_torrent::add_url_seed)
.def("add_node", &create_torrent::add_node)
.def("add_tracker", &create_torrent::add_tracker)
.def("set_priv", &create_torrent::set_priv)
.def("num_pieces", &create_torrent::num_pieces)
.def("piece_length", &create_torrent::piece_length)
.def("piece_size", &create_torrent::piece_size)
.def("priv", &create_torrent::priv)
;
}

View File

@ -24,6 +24,7 @@ void bind_peer_info();
void bind_ip_filter();
void bind_magnet_uri();
void bind_converters();
void bind_create_torrent();
BOOST_PYTHON_MODULE(libtorrent)
{
@ -52,4 +53,5 @@ BOOST_PYTHON_MODULE(libtorrent)
bind_ip_filter();
bind_magnet_uri();
bind_converters();
bind_create_torrent();
}

View File

@ -146,6 +146,7 @@ void bind_torrent_info()
)
.def_readonly("offset", &file_entry::offset)
.def_readonly("size", &file_entry::size)
.def_readonly("file_base", &file_entry::file_base)
;
class_<announce_entry>("announce_entry", init<std::string const&>())