From 7fe1d322aab254cd4636ec09cc28d1db42a350fc Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Tue, 16 Aug 2016 08:12:50 +0100 Subject: [PATCH] Increase API wrapper coverage It now wraps everything except the Error class, which is intentionally left unwrapped, as wrapping it would provide no benefit. --- docs/reference.rst | 25 ++++++++++++++++++++++++- src/main.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/docs/reference.rst b/docs/reference.rst index 725348f..b391112 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -2,25 +2,47 @@ API Reference ************* -As this API is just a wrapper for LOOT's C++ API, its documentation is linked to for all non-Python-specific information. +As this API is just a wrapper for LOOT's C++ API, its documentation is linked to +for all non-Python-specific information. Enumerations ============ +The wrapped enumeration types below are classes in Python, but the distinction +makes no difference in practice, so they're grouped here for semantics. + .. autoclass:: loot_api.GameType :members: + :undoc-members: + +.. autoclass:: loot_api.LanguageCode + :members: + :undoc-members: .. autoclass:: loot_api.MessageType :members: + :undoc-members: + +.. autoclass:: loot_api.PluginCleanliness + :members: + :undoc-members: Public-Field Data Structures ============================ +Classes with public fields and no member functions. + +.. autoclass:: loot_api.MasterlistInfo + :members: + :undoc-members: + .. autoclass:: loot_api.Message :members: + :undoc-members: .. autoclass:: loot_api.PluginTags :members: + :undoc-members: Functions @@ -38,3 +60,4 @@ Classes .. autoclass:: loot_api.Version :members: + :undoc-members: diff --git a/src/main.cpp b/src/main.cpp index 04d6136..d323e1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,8 +33,11 @@ PYBIND11_PLUGIN(loot_api) { using loot::DatabaseInterface; using loot::IsCompatible; using loot::GameType; + using loot::LanguageCode; using loot::LootVersion; using loot::MessageType; + using loot::MasterlistInfo; + using loot::PluginCleanliness; using loot::PluginMessage; using loot::PluginTags; @@ -46,11 +49,35 @@ PYBIND11_PLUGIN(loot_api) { enum_(module, "GameType", "Wraps :cpp:type:`GameType `.") .value("tes4", GameType::tes4); + enum_(module, "LanguageCode", "Wraps :cpp:type:`LanguageCode `.") + .value("english", LanguageCode::english) + .value("spanish", LanguageCode::spanish) + .value("russian", LanguageCode::russian) + .value("french", LanguageCode::french) + .value("chinese", LanguageCode::chinese) + .value("polish", LanguageCode::polish) + .value("brazilian_portuguese", LanguageCode::brazilian_portuguese) + .value("finnish", LanguageCode::finnish) + .value("german", LanguageCode::german) + .value("danish", LanguageCode::danish) + .value("korean", LanguageCode::korean); + enum_(module, "MessageType", "Wraps :cpp:type:`MessageType `.") .value("say", MessageType::say) .value("warn", MessageType::warn) .value("error", MessageType::error); + enum_(module, "PluginCleanliness", "Wraps :cpp:type:`Plugin Cleanliness `.") + .value("clean", PluginCleanliness::clean) + .value("dirty", PluginCleanliness::dirty) + .value("do_not_clean", PluginCleanliness::do_not_clean) + .value("unknown", PluginCleanliness::unknown); + + class_(module, "MasterlistInfo", "Wraps :cpp:class:`MasterlistInfo `.") + .def_readwrite("revision_id", &MasterlistInfo::revision_id) + .def_readwrite("revision_date", &MasterlistInfo::revision_date) + .def_readwrite("is_modified", &MasterlistInfo::is_modified); + class_(module, "Message", "Wraps :cpp:class:`PluginMessage `.") .def_readwrite("type", &PluginMessage::type) .def_readwrite("text", &PluginMessage::text); @@ -64,12 +91,20 @@ PYBIND11_PLUGIN(loot_api) { .def_readonly_static("major", &LootVersion::major) .def_readonly_static("minor", &LootVersion::minor) .def_readonly_static("patch", &LootVersion::patch) - .def_readonly_static("revision", &LootVersion::revision); + .def_readonly_static("revision", &LootVersion::revision) + .def("string", LootVersion::string); class_>(module, "DatabaseInterface", "Wraps :cpp:class:`DatabaseInterface `.") .def("load_lists", &DatabaseInterface::LoadLists, "Loads the masterlist and userlist from the paths specified. Wraps :cpp:func:`LoadLists`.") + .def("eval_lists", &DatabaseInterface::EvalLists, "Evaluates all conditions and regular expression metadata entries in the loaded metadata lists. Wraps :cpp:func:`EvalLists`.") + .def("sort_plugins", &DatabaseInterface::SortPlugins, "Calculates a new load order for all a game's installed plugins and outputs the sorted order. Wraps :cpp:func:`SortPlugins`.") + .def("apply_load_order", &DatabaseInterface::ApplyLoadOrder, "Applies the given load order. Wraps :cpp:func:`ApplyLoadOrder`.") + .def("update_masterlist", &DatabaseInterface::UpdateMasterlist, "Updates the given masterlist using the given Git repository details. Wraps :cpp:func:`UpdateMasterlist`.") + .def("get_masterlist_revision", &DatabaseInterface::GetMasterlistRevision, "Gets the give masterlist's source control revision. Wraps :cpp:func:`GetMasterlistRevision`.") .def("get_plugin_tags", &DatabaseInterface::GetPluginTags, "Outputs the Bash Tags suggested for addition and removal by the database for the given plugin. Wraps :cpp:func:`GetPluginTags`.") - .def("get_plugin_messages", &DatabaseInterface::GetPluginMessages, "Outputs the messages associated with the given plugin in the database. Wraps :cpp:func:`GetPluginMessages`."); + .def("get_plugin_messages", &DatabaseInterface::GetPluginMessages, "Outputs the messages associated with the given plugin in the database. Wraps :cpp:func:`GetPluginMessages`.") + .def("get_plugin_cleanliness", &DatabaseInterface::GetPluginCleanliness, "Determines the database's knowledge of a plugin's cleanliness. Wraps :cpp:func:`GetPluginCleanliness`.") + .def("write_minimal_list", &DatabaseInterface::WriteMinimalList, "Writes a minimal metadata file containing only Bash Tag suggestions and/or cleanliness info from the loaded metadata. Wraps :cpp:func:`WriteMinimalList`."); module.def("is_compatible", &IsCompatible, "Checks for API compatibility. Wraps :cpp:func:`IsCompatible `.");