Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: Allow config includes to use subfolder globs #6375

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ aliases_<name>:

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]
Expand Down
6 changes: 5 additions & 1 deletion klippy/configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ def _resolve_include(self, source_filename, include_spec, fileconfig,
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)
include_filenames = None
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,))
Expand Down