mirror of https://github.com/mamba-org/mamba.git
Safe id2pkginfo
This commit is contained in:
parent
13a6a4c086
commit
cabd3bf640
|
@ -8,7 +8,9 @@
|
|||
#define MAMBA_CORE_POOL_HPP
|
||||
|
||||
#include <list>
|
||||
#include <optional>
|
||||
#include "repo.hpp"
|
||||
#include "package_info.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -39,6 +41,8 @@ namespace mamba
|
|||
std::vector<Id> select_solvables(Id id);
|
||||
Id matchspec2id(const std::string& ms);
|
||||
|
||||
std::optional<PackageInfo> id2pkginfo(Id id);
|
||||
|
||||
operator Pool*();
|
||||
|
||||
MRepo& add_repo(MRepo&& repo);
|
||||
|
|
|
@ -98,6 +98,15 @@ namespace mamba
|
|||
return id;
|
||||
}
|
||||
|
||||
std::optional<PackageInfo> MPool::id2pkginfo(Id id)
|
||||
{
|
||||
if (id == 0 || id >= m_pool->nsolvables)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return pool_id2solvable(m_pool, id);
|
||||
}
|
||||
|
||||
MRepo& MPool::add_repo(MRepo&& repo)
|
||||
{
|
||||
m_repo_list.push_back(std::move(repo));
|
||||
|
|
|
@ -67,10 +67,9 @@ PYBIND11_MODULE(bindings, m)
|
|||
.def(py::init<>())
|
||||
.def("set_debuglevel", &MPool::set_debuglevel)
|
||||
.def("create_whatprovides", &MPool::create_whatprovides)
|
||||
.def("select_solvables", &MPool::select_solvables)
|
||||
.def("matchspec2id", &MPool::matchspec2id)
|
||||
.def("id2pkginfo",
|
||||
[](MPool& self, Id id) { return PackageInfo(pool_id2solvable(self, id)); });
|
||||
.def("select_solvables", &MPool::select_solvables, py::arg("id"))
|
||||
.def("matchspec2id", &MPool::matchspec2id, py::arg("ms"))
|
||||
.def("id2pkginfo", &MPool::id2pkginfo, py::arg("id"));
|
||||
|
||||
py::class_<MultiPackageCache>(m, "MultiPackageCache")
|
||||
.def(py::init<std::vector<fs::path>>())
|
||||
|
|
Loading…
Reference in New Issue