@@ -49,7 +49,7 @@ namespace mo2::detail {
4949 return std::make_shared<PyFileTree>(parent, name, m_Callback);
5050 }
5151
52- bool doPopulate (std::shared_ptr<const IFileTree> parent,
52+ bool doPopulate ([[maybe_unused]] std::shared_ptr<const IFileTree> parent,
5353 std::vector<std::shared_ptr<FileTreeEntry>>&) const override
5454 {
5555 return true ;
@@ -83,7 +83,6 @@ namespace mo2::python {
8383
8484 void add_ifiletree_bindings (pybind11::module_& m)
8585 {
86-
8786 // FileTreeEntry class:
8887 auto fileTreeEntryClass =
8988 py::class_<FileTreeEntry, std::shared_ptr<FileTreeEntry>>(m,
@@ -164,6 +163,11 @@ namespace mo2::python {
164163 .value (" SKIP" , IFileTree::WalkReturn::SKIP)
165164 .export_values ();
166165
166+ py::enum_<IFileTree::GlobPatternType>(iFileTreeClass, " GlobPatternType" )
167+ .value (" GLOB" , IFileTree::GlobPatternType::GLOB)
168+ .value (" REGEX" , IFileTree::GlobPatternType::REGEX)
169+ .export_values ();
170+
167171 // Non-mutable operations:
168172 iFileTreeClass.def (" exists" ,
169173 py::overload_cast<QString, IFileTree::FileTypes>(
@@ -175,10 +179,25 @@ namespace mo2::python {
175179 iFileTreeClass.def (" pathTo" , &IFileTree::pathTo, py::arg (" entry" ),
176180 py::arg (" sep" ) = " \\ " );
177181
178- // Note: walk() would probably be better as a generator in python, but
179- // it is likely impossible to construct from the C++ walk() method.
180- iFileTreeClass.def (" walk" , &IFileTree::walk, py::arg (" callback" ),
181- py::arg (" sep" ) = " \\ " );
182+ iFileTreeClass.def (
183+ " walk" ,
184+ py::overload_cast<
185+ std::function<IFileTree::WalkReturn (
186+ QString const &, std::shared_ptr<const FileTreeEntry>)>,
187+ QString>(&IFileTree::walk, py::const_),
188+ py::arg (" callback" ), py::arg (" sep" ) = " \\ " );
189+
190+ iFileTreeClass.def (" walk" , [](IFileTree const * tree) {
191+ return make_generator (tree->walk ());
192+ });
193+
194+ iFileTreeClass.def (
195+ " glob" , // &IFileTree::glob,
196+ [](IFileTree const * tree, QString pattern,
197+ IFileTree::GlobPatternType patternType) {
198+ return make_generator (tree->glob (pattern, patternType));
199+ },
200+ py::arg (" pattern" ), py::arg (" type" ) = IFileTree::GlobPatternType::GLOB);
182201
183202 // Kind-of-static operations:
184203 iFileTreeClass.def (" createOrphanTree" , &IFileTree::createOrphanTree,
0 commit comments