updated python bindings

This commit is contained in:
Arvid Norberg 2007-08-27 10:31:35 +00:00
parent 79e0e06fa9
commit 056b9709ac
4 changed files with 54 additions and 10 deletions

View File

@ -25,6 +25,8 @@ extern char const* peer_error_alert_doc;
extern char const* invalid_request_alert_doc;
extern char const* peer_request_doc;
extern char const* torrent_finished_alert_doc;
extern char const* torrent_paused_alert_doc;
extern char const* storage_moved_alert_doc;
extern char const* metadata_failed_alert_doc;
extern char const* metadata_received_alert_doc;
extern char const* fastresume_rejected_alert_doc;
@ -140,7 +142,18 @@ void bind_alert()
)
.def_readonly("handle", &torrent_finished_alert::handle)
;
class_<torrent_paused_alert, bases<alert>, noncopyable>(
"torrent_paused_alert", torrent_paused_alert_doc, no_init
)
.def_readonly("handle", &torrent_paused_alert::handle)
;
class_<storage_moved_alert, bases<alert>, noncopyable>(
"storage_moved_alert", storage_moved_alert_doc, no_init
)
.def_readonly("handle", &storage_moved_alert::handle)
;
class_<metadata_failed_alert, bases<alert>, noncopyable>(
"metadata_failed_alert", metadata_failed_alert_doc, no_init
)

View File

@ -246,6 +246,17 @@ char const* torrent_finished_alert_doc =
"It contains a `torrent_handle` to the torrent in question. This alert\n"
"is generated as severity level `alert.severity_levels.info`.";
char const* torrent_paused_alert_doc =
"This alert is generated when a torrent switches from being a\n"
"active to paused.\n"
"It contains a `torrent_handle` to the torrent in question. This alert\n"
"is generated as severity level `alert.severity_levels.warning`.";
char const* storage_moved_alert_doc =
"This alert is generated when a torrent moves storage.\n"
"It contains a `torrent_handle` to the torrent in question. This alert\n"
"is generated as severity level `alert.severity_levels.warning`.";
char const* metadata_failed_alert_doc =
"This alert is generated when the metadata has been completely\n"
"received and the info-hash failed to match it. i.e. the\n"

View File

@ -80,11 +80,10 @@ namespace
torrent_handle add_torrent(session& s, torrent_info const& ti
, boost::filesystem::path const& save, entry const& resume
, bool compact, int block_size)
, bool compact, bool paused)
{
allow_threading_guard guard;
return s.add_torrent(ti, save, resume, compact, block_size
, default_storage_constructor);
return s.add_torrent(ti, save, resume, compact, paused, default_storage_constructor);
}
} // namespace unnamed
@ -169,7 +168,7 @@ void bind_session()
"add_torrent", &add_torrent
, (
arg("torrent_info"), "save_path", arg("resume_data") = entry()
, arg("compact_mode") = true, arg("block_size") = 16 * 1024
, arg("compact_mode") = true, arg("paused") = false
)
, session_add_torrent_doc
)

View File

@ -16,7 +16,6 @@ namespace
return i.trackers().begin();
}
std::vector<announce_entry>::const_iterator end_trackers(torrent_info& i)
{
return i.trackers().end();
@ -41,6 +40,29 @@ namespace
return result;
}
std::vector<file_entry>::const_iterator begin_files(torrent_info& i, bool storage)
{
return i.begin_files(storage);
}
std::vector<file_entry>::const_iterator end_files(torrent_info& i, bool storage)
{
return i.end_files(storage);
}
//list files(torrent_info const& ti, bool storage) {
list files(torrent_info const& ti, bool storage) {
list result;
typedef std::vector<file_entry> list_type;
for (list_type::const_iterator i = ti.begin_files(storage); i != ti.end_files(storage); ++i)
result.append(*i);
return result;
}
} // namespace unnamed
void bind_torrent_info()
@ -71,9 +93,9 @@ void bind_torrent_info()
.def("hash_for_piece", &torrent_info::hash_for_piece, copy)
.def("piece_size", &torrent_info::piece_size)
.def("num_files", &torrent_info::num_files)
.def("num_files", &torrent_info::num_files, (arg("storage")=false))
.def("file_at", &torrent_info::file_at, return_internal_reference<>())
.def("files", range(&torrent_info::begin_files, &torrent_info::end_files))
.def("files", &files, (arg("storage")=false))
.def("priv", &torrent_info::priv)
.def("set_priv", &torrent_info::set_priv)
@ -84,9 +106,8 @@ void bind_torrent_info()
.def("add_node", &add_node)
.def("nodes", &nodes)
;
class_<file_entry>("file_entry")
.add_property(
.add_property(
"path"
, make_getter(
&file_entry::path, return_value_policy<copy_non_const_reference>()