diff options
-rw-r--r-- | release/scripts/modules/bpy_types.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 933e77ce2e3..6f921868ccc 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -671,7 +671,7 @@ class Header(StructRNA, _GenericUI, metaclass=RNAMeta): class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): __slots__ = () - def path_menu(self, searchpaths, operator, props_default={}): + def path_menu(self, searchpaths, operator, props_default={}, filter_ext=None): layout = self.layout # hard coded to set the operators 'filepath' to the filename. @@ -687,17 +687,16 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): files = [] for directory in searchpaths: files.extend([(f, os.path.join(directory, f)) - for f in os.listdir(directory)]) + for f in os.listdir(directory) + if (not f.startswith(".")) + if ((filter_ext is None) or + (filter_ext(os.path.splitext(f)[1]))) + ]) files.sort() for f, filepath in files: - - if f.startswith("."): - continue - - preset_name = bpy.path.display_name(f) - props = layout.operator(operator, text=preset_name) + props = layout.operator(operator, text=bpy.path.display_name(f)) for attr, value in props_default.items(): setattr(props, attr, value) @@ -714,4 +713,5 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): """ import bpy self.path_menu(bpy.utils.preset_paths(self.preset_subdir), - self.preset_operator) + self.preset_operator, + filter_ext=lambda ext: ext.lower() in {".py", ".xml"}) |