expose verified_pieces and the enums passed in to torrent_handle::status to python

This commit is contained in:
Arvid Norberg 2011-08-07 19:03:19 +00:00
parent d12c97e495
commit 587de62205
2 changed files with 17 additions and 7 deletions

View File

@ -384,4 +384,11 @@ void bind_torrent_handle()
.value("alert_when_available", torrent_handle::alert_when_available)
;
enum_<torrent_handle::status_flags_t>("status_flags_t")
.value("query_distributed_copies", torrent_handle::query_distributed_copies)
.value("query_accurate_download_counters", torrent_handle::query_accurate_download_counters)
.value("query_last_seen_complete", torrent_handle::query_last_seen_complete)
.value("query_pieces", torrent_handle::query_pieces)
.value("query_verified_pieces", torrent_handle::query_verified_pieces)
;
}

View File

@ -9,16 +9,18 @@
using namespace boost::python;
using namespace libtorrent;
object pieces(torrent_status const& s)
object bitfield_to_list(bitfield const& bf)
{
list result;
list ret;
for (bitfield::const_iterator i(s.pieces.begin()), e(s.pieces.end()); i != e; ++i)
result.append(*i);
return result;
for (bitfield::const_iterator i(bf.begin()), e(bf.end()); i != e; ++i)
ret.append(*i);
return ret;
}
object pieces(torrent_status const& s) { return bitfield_to_list(s.pieces); }
object verified_pieces(torrent_status const& s) { return bitfield_to_list(s.verified_pieces); }
void bind_torrent_status()
{
scope status = class_<torrent_status>("torrent_status")
@ -60,7 +62,8 @@ void bind_torrent_status()
.def_readonly("num_incomplete", &torrent_status::num_incomplete)
.def_readonly("list_seeds", &torrent_status::list_seeds)
.def_readonly("list_peers", &torrent_status::list_peers)
.add_property("pieces", pieces)
.add_property("pieces", &pieces)
.add_property("verified_pieces", &verified_pieces)
.def_readonly("num_pieces", &torrent_status::num_pieces)
.def_readonly("total_done", &torrent_status::total_done)
.def_readonly("total_wanted_done", &torrent_status::total_wanted_done)