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 2 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", "configs/\*\*/\*.cfg").

```
[include my_other_config.cfg]
Expand Down
2 changes: 1 addition & 1 deletion klippy/configfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ 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 = glob.glob(include_glob, recursive=True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recursive argument for glob.glob() was added in Python 3.5. AFAIK Klipper still supports running on Python 2.7, so this would be a breaking change.

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