From b73abb11f9dc0612a07b952a7fac9fedfe619ad7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Mon, 8 Apr 2024 10:14:19 +0200 Subject: [PATCH 1/4] 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,)) From 44a78cf646d964e7e6e8c96658e8c219ccab79c4 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 9 Apr 2024 17:42:03 +0200 Subject: [PATCH 2/4] Updated Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ed76fb56..abb0672b3 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ 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) +- [configfile: recursive globs](https://github.com/DangerKlippers/danger-klipper/pull/200) / ([klipper#6375](https://github.com/Klipper3d/klipper/pull/6375)) 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): From 8e4b9cc6b41b46e1f173608acb9694ee8426d8e7 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 9 Apr 2024 17:42:12 +0200 Subject: [PATCH 3/4] Added CI tests --- test/klippy/recursive_globs.cfg | 1 + test/klippy/recursive_globs.test | 4 ++ .../recursive_globs.include | 1 + .../recursive_globs_include.cfg | 71 +++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 test/klippy/recursive_globs.cfg create mode 100644 test/klippy/recursive_globs.test create mode 100644 test/klippy/recursive_globs_include/recursive_globs.include create mode 100644 test/klippy/recursive_globs_include/recursive_globs_include.cfg diff --git a/test/klippy/recursive_globs.cfg b/test/klippy/recursive_globs.cfg new file mode 100644 index 000000000..c9fd79e8d --- /dev/null +++ b/test/klippy/recursive_globs.cfg @@ -0,0 +1 @@ +[include **/_.include] diff --git a/test/klippy/recursive_globs.test b/test/klippy/recursive_globs.test new file mode 100644 index 000000000..f4dd9f826 --- /dev/null +++ b/test/klippy/recursive_globs.test @@ -0,0 +1,4 @@ +CONFIG recursive_globs.cfg +DICTIONARY atmega2560.dict + +G28 diff --git a/test/klippy/recursive_globs_include/recursive_globs.include b/test/klippy/recursive_globs_include/recursive_globs.include new file mode 100644 index 000000000..8632530db --- /dev/null +++ b/test/klippy/recursive_globs_include/recursive_globs.include @@ -0,0 +1 @@ +[include ./**/*.cfg] diff --git a/test/klippy/recursive_globs_include/recursive_globs_include.cfg b/test/klippy/recursive_globs_include/recursive_globs_include.cfg new file mode 100644 index 000000000..c7c253db9 --- /dev/null +++ b/test/klippy/recursive_globs_include/recursive_globs_include.cfg @@ -0,0 +1,71 @@ +[stepper_x] +step_pin: PF0 +dir_pin: PF1 +enable_pin: !PD7 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PE5 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_y] +step_pin: PF6 +dir_pin: !PF7 +enable_pin: !PF2 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PJ1 +position_endstop: 0 +position_max: 200 +homing_speed: 50 + +[stepper_z] +step_pin: PL3 +dir_pin: PL1 +enable_pin: !PK0 +microsteps: 16 +rotation_distance: 8 +endstop_pin: probe:z_virtual_endstop +position_max: 200 + +[extruder] +step_pin: PA4 +dir_pin: PA6 +enable_pin: !PA2 +microsteps: 16 +rotation_distance: 33.5 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: PB4 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PK5 +control: pid +pid_Kp: 22.2 +pid_Ki: 1.08 +pid_Kd: 114 +min_temp: 0 +max_temp: 250 + +[heater_bed] +heater_pin: PH5 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PK6 +control: watermark +min_temp: 0 +max_temp: 130 + +[probe] +pin: PH6 +z_offset: 1.15 +drop_first_result: true + +[mcu] +serial: /dev/ttyACM0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 From 2fabb823fb81d6943e93ac39854928a06c23b731 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Tue, 9 Apr 2024 18:04:15 +0200 Subject: [PATCH 4/4] writing the right name for what you want to include actually helps --- test/klippy/recursive_globs.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/klippy/recursive_globs.cfg b/test/klippy/recursive_globs.cfg index c9fd79e8d..1ebfdc5b0 100644 --- a/test/klippy/recursive_globs.cfg +++ b/test/klippy/recursive_globs.cfg @@ -1 +1 @@ -[include **/_.include] +[include **/recursive_globs.include]