From b73abb11f9dc0612a07b952a7fac9fedfe619ad7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Mon, 8 Apr 2024 10:14:19 +0200 Subject: [PATCH] Initial Implementation --- README.md | 2 ++ docs/Config_Reference.md | 2 +- klippy/configfile.py | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a0c6b6349..1ed76fb56 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ If I want my printer to light itself on fire, I should be able to make my printe - [filament_switch|motion_sensor: runout distance, smart and runout gcode](https://github.com/DangerKlippers/danger-klipper/pull/158) +- [configfile: recursive globs](https://github.com/Klipper3d/klipper/pull/6375) / (https://github.com/DangerKlippers/danger-klipper/pull/200) + If you're feeling adventurous, take a peek at the extra features in the bleeding-edge branch [feature documentation](docs/Bleeding_Edge.md) and [feature configuration reference](docs/Config_Reference_Bleeding_Edge.md): diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 7077274f8..6df69033a 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2019,7 +2019,7 @@ aliases_: Include file support. One may include additional config file from the main printer config file. Wildcards may also be used (eg, -"configs/\*.cfg"). +"configs/\*.cfg", or "configs/\*\*/\*.cfg" if using python version >=3.5). ``` [include my_other_config.cfg] diff --git a/klippy/configfile.py b/klippy/configfile.py index 7c83fdbc8..b715d93dd 100644 --- a/klippy/configfile.py +++ b/klippy/configfile.py @@ -364,7 +364,10 @@ def _resolve_include( dirname = os.path.dirname(source_filename) include_spec = include_spec.strip() include_glob = os.path.join(dirname, include_spec) - include_filenames = glob.glob(include_glob) + if sys.version_info >= (3, 5): + include_filenames = glob.glob(include_glob, recursive=True) + else: + include_filenames = glob.glob(include_glob) if not include_filenames and not glob.has_magic(include_glob): # Empty set is OK if wildcard but not for direct file reference raise error("Include file '%s' does not exist" % (include_glob,))