@@ -84,6 +84,9 @@ namespace mo2::python {
8484 void add_ifiletree_bindings (pybind11::module_& m)
8585 {
8686
87+ // register generator for walk and glob
88+ register_generator_type<std::shared_ptr<const FileTreeEntry>>(m);
89+
8790 // FileTreeEntry class:
8891 auto fileTreeEntryClass =
8992 py::class_<FileTreeEntry, std::shared_ptr<FileTreeEntry>>(m,
@@ -164,6 +167,11 @@ namespace mo2::python {
164167 .value (" SKIP" , IFileTree::WalkReturn::SKIP)
165168 .export_values ();
166169
170+ py::enum_<IFileTree::GlobPatternType>(iFileTreeClass, " GlobPatternType" )
171+ .value (" GLOB" , IFileTree::GlobPatternType::GLOB)
172+ .value (" REGEX" , IFileTree::GlobPatternType::REGEX)
173+ .export_values ();
174+
167175 // Non-mutable operations:
168176 iFileTreeClass.def (" exists" ,
169177 py::overload_cast<QString, IFileTree::FileTypes>(
@@ -175,10 +183,18 @@ namespace mo2::python {
175183 iFileTreeClass.def (" pathTo" , &IFileTree::pathTo, py::arg (" entry" ),
176184 py::arg (" sep" ) = " \\ " );
177185
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" ) = " \\ " );
186+ iFileTreeClass.def (
187+ " walk" ,
188+ py::overload_cast<
189+ std::function<IFileTree::WalkReturn (
190+ QString const &, std::shared_ptr<const FileTreeEntry>)>,
191+ QString>(&IFileTree::walk, py::const_),
192+ py::arg (" callback" ), py::arg (" sep" ) = " \\ " );
193+
194+ iFileTreeClass.def (" walk" , py::overload_cast<>(&IFileTree::walk, py::const_));
195+
196+ iFileTreeClass.def (" glob" , &IFileTree::glob, py::arg (" pattern" ),
197+ py::arg (" type" ) = IFileTree::GlobPatternType::GLOB);
182198
183199 // Kind-of-static operations:
184200 iFileTreeClass.def (" createOrphanTree" , &IFileTree::createOrphanTree,
0 commit comments