mirror of
https://github.com/ModOrganizer2/modorganizer-plugin_python.git
synced 2026-07-27 14:03:33 -07:00
Minor fix to filetree for bindings.
This commit is contained in:
@@ -85,11 +85,16 @@ namespace mo2::python {
|
||||
void add_ifiletree_bindings(pybind11::module_& m)
|
||||
{
|
||||
|
||||
// FileTreeEntry Scope:
|
||||
// FileTreeEntry class:
|
||||
auto fileTreeEntryClass =
|
||||
py::class_<FileTreeEntry, std::shared_ptr<FileTreeEntry>>(m,
|
||||
"FileTreeEntry");
|
||||
|
||||
// IFileTree class:
|
||||
auto iFileTreeClass =
|
||||
py::class_<IFileTree, FileTreeEntry, std::shared_ptr<IFileTree>>(
|
||||
m, "IFileTree", py::multiple_inheritance());
|
||||
|
||||
// we do not use the enum directly, we will mostly bind the FileTypes
|
||||
// (with an S)
|
||||
py::enum_<FileTreeEntry::FileType>(fileTreeEntryClass, "FileType",
|
||||
@@ -130,12 +135,7 @@ namespace mo2::python {
|
||||
|
||||
.def("isFile", &FileTreeEntry::isFile)
|
||||
.def("isDir", &FileTreeEntry::isDir)
|
||||
// Forcing the conversion to FileTypeS to avoid having to expose
|
||||
// FileType in python:
|
||||
.def("fileType", &FileTreeEntry::fileType)
|
||||
// This should probably not be exposed in python since we provide
|
||||
// automatic downcast: .def("getTree",
|
||||
// static_cast<std::shared_ptr<IFileTree>(FileTreeEntry::*)()>(&FileTreeEntry::astree))
|
||||
.def("name", &FileTreeEntry::name)
|
||||
.def("suffix", &FileTreeEntry::suffix)
|
||||
.def(
|
||||
@@ -150,7 +150,7 @@ namespace mo2::python {
|
||||
return entry->hasSuffix(suffix);
|
||||
},
|
||||
py::arg("suffix"))
|
||||
.def("parent", py::overload_cast<>(&FileTreeEntry::parent), "[optional]")
|
||||
.def("parent", py::overload_cast<>(&FileTreeEntry::parent))
|
||||
.def("path", &FileTreeEntry::path, py::arg("sep") = "\\")
|
||||
.def("pathFrom", &FileTreeEntry::pathFrom, py::arg("tree"),
|
||||
py::arg("sep") = "\\")
|
||||
@@ -174,11 +174,6 @@ namespace mo2::python {
|
||||
return "FileTreeEntry(\"" + entry->name() + "\")";
|
||||
});
|
||||
|
||||
// IFileTree scope:
|
||||
auto iFileTreeClass =
|
||||
py::class_<IFileTree, FileTreeEntry, std::shared_ptr<IFileTree>>(
|
||||
m, "IFileTree", py::multiple_inheritance());
|
||||
|
||||
py::enum_<IFileTree::InsertPolicy>(iFileTreeClass, "InsertPolicy")
|
||||
.value("FAIL_IF_EXISTS", IFileTree::InsertPolicy::FAIL_IF_EXISTS)
|
||||
.value("REPLACE", IFileTree::InsertPolicy::REPLACE)
|
||||
|
||||
Reference in New Issue
Block a user