diff --git a/README.md b/README.md index a0c6b6349..abb0672b3 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/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): diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index a027ca4c4..5683dd79c 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,)) diff --git a/test/klippy/recursive_globs.cfg b/test/klippy/recursive_globs.cfg new file mode 100644 index 000000000..1ebfdc5b0 --- /dev/null +++ b/test/klippy/recursive_globs.cfg @@ -0,0 +1 @@ +[include **/recursive_globs.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