From cf76d34cdf8a5a435e6116effd866ebb25130bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 4 May 2022 22:26:05 +0200 Subject: [PATCH] Minor fix to filetree for bindings. --- src/mobase/wrappers/pyfiletree.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/mobase/wrappers/pyfiletree.cpp b/src/mobase/wrappers/pyfiletree.cpp index d102381..2da93ec 100644 --- a/src/mobase/wrappers/pyfiletree.cpp +++ b/src/mobase/wrappers/pyfiletree.cpp @@ -85,11 +85,16 @@ namespace mo2::python { void add_ifiletree_bindings(pybind11::module_& m) { - // FileTreeEntry Scope: + // FileTreeEntry class: auto fileTreeEntryClass = py::class_>(m, "FileTreeEntry"); + // IFileTree class: + auto iFileTreeClass = + py::class_>( + m, "IFileTree", py::multiple_inheritance()); + // we do not use the enum directly, we will mostly bind the FileTypes // (with an S) py::enum_(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(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_>( - m, "IFileTree", py::multiple_inheritance()); - py::enum_(iFileTreeClass, "InsertPolicy") .value("FAIL_IF_EXISTS", IFileTree::InsertPolicy::FAIL_IF_EXISTS) .value("REPLACE", IFileTree::InsertPolicy::REPLACE)