@@ -163,9 +163,11 @@ namespace mo2::python {
163163 .value (" SKIP" , IFileTree::WalkReturn::SKIP)
164164 .export_values ();
165165
166- py::enum_<IFileTree::GlobPatternType>(iFileTreeClass, " GlobPatternType" )
167- .value (" GLOB" , IFileTree::GlobPatternType::GLOB)
168- .value (" REGEX" , IFileTree::GlobPatternType::REGEX)
166+ // in C++ this is not an inner enum due to the conditional feature of glob(),
167+ // but in Python this makes more sense as a inner enum
168+ py::enum_<GlobPatternType>(iFileTreeClass, " GlobPatternType" )
169+ .value (" GLOB" , GlobPatternType::GLOB)
170+ .value (" REGEX" , GlobPatternType::REGEX)
169171 .export_values ();
170172
171173 // Non-mutable operations:
@@ -187,17 +189,21 @@ namespace mo2::python {
187189 QString>(&IFileTree::walk, py::const_),
188190 py::arg (" callback" ), py::arg (" sep" ) = " \\ " );
189191
190- iFileTreeClass.def (" walk" , [](IFileTree const * tree) {
191- return make_generator (tree->walk ());
192+ // the walk() and glob() generator version are free functions in C++ due to the
193+ // conditional nature, but in Python, it makes more sense to have them as method
194+ // of IFileTree directly
195+
196+ iFileTreeClass.def (" walk" , [](std::shared_ptr<const IFileTree> tree) {
197+ return make_generator (walk (tree));
192198 });
193199
194200 iFileTreeClass.def (
195- " glob" , // &IFileTree::glob,
196- [](IFileTree const * tree, QString pattern,
197- IFileTree:: GlobPatternType patternType) {
198- return make_generator (tree-> glob (pattern, patternType));
201+ " glob" ,
202+ [](std::shared_ptr< const IFileTree> tree, QString pattern,
203+ GlobPatternType patternType) {
204+ return make_generator (glob (tree, pattern, patternType));
199205 },
200- py::arg (" pattern" ), py::arg (" type" ) = IFileTree:: GlobPatternType::GLOB);
206+ py::arg (" pattern" ), py::arg (" type" ) = GlobPatternType::GLOB);
201207
202208 // Kind-of-static operations:
203209 iFileTreeClass.def (" createOrphanTree" , &IFileTree::createOrphanTree,
0 commit comments