aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/configfile.py
Commit message (Collapse)AuthorAgeFilesLines
* configfile: Fix comments on same line as [include xxx.cfg] directiveKevin O'Connor2024-11-121-0/+4
| | | | | | | | Commit 9d4ab862 broke support for '#' style comments on the same line as [include] config directives. Fix by adding back in the check for comments in _parse_config(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Separate access tracking to new ConfigValidate classKevin O'Connor2024-10-301-38/+73
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Only check for [include file] directives from main printer.cfgKevin O'Connor2024-10-301-37/+52
| | | | | | | Don't look for includes in autosave data nor from the internal menu, display, and temperature configs. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Don't read the autosave data if multiple autosave headers presentKevin O'Connor2024-10-301-1/+6
| | | | | | Also, verify new autosave looks valid prior to writing it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Split configfile code into three separate classesKevin O'Connor2024-10-301-160/+203
| | | | | | | | | | | | Separate out the low-level parsing code to a new ConfigFileReader() class. Separate out the auto-save handling code to a new ConfigAutoSave() class. This simplifies the main PrinterConfig() class. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Allow getchoice() to take a listKevin O'Connor2024-06-171-0/+2
| | | | | | If a list is passed to getchoice(), seamlessly convert it to a dict. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Replace logging.warn usage with logging.warningJelle van der Waa2024-05-011-1/+1
| | | | | | | logging.warn is an alias to logging.warning since Python 3.3 and will be removed in Python 3.13. Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
* klippy: remove a few unused variable assignments (#6504)Kamil Domański2024-04-051-1/+0
| | | Signed-off-by: Kamil Domański <kamil@domanski.co>
* configfile: Add support for reporting runtime_warnings via the API serverKevin O'Connor2024-03-131-2/+10
| | | | | | | Add a new runtime_warning() method that will add a 'runtime_warning' type message to the printer.configfile.warnings object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Improve support for python3.12Kevin O'Connor2023-11-161-1/+4
| | | | | | | It seems python3.12 has removed support for readfp() - use read_file() instead. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Replace deprecated logger.warn with logger.warning (#6385)Thijs Triemstra2023-11-161-4/+4
| | | | | | | Replace deprecated logger.warn with logger.warning logger.warn will be removed in Python 3.13 Signed-off-by: Thijs Triemstra <info@collab.nl>
* configfile: Make getlists return an empty list on empty string. (#6042)Jordan Woyak2023-02-091-2/+6
| | | Signed-off-by: Jordan Woyak <jordan.woyak@gmail.com>
* configfile: Expose options awaiting to be saved (#5270)Kurt Haenen2022-06-201-3/+22
| | | | | | | Adds a save_config_pending_items to the status reported by configfile reflecting the items and values that a future SAVE_CONFIG would actually persist. Signed-off-by: Kurt Haenen <kurt.haenen@gmail.com>
* configfile: Use Python2's ConfigParser when running on Python2Kevin O'Connor2021-10-091-4/+6
| | | | | | | | | The backport of Python3's configparser causes issues when there is unicode characters in the config file. To avoid introducing new errors, go back to using the Python2 version of ConfigParser when running on Python2. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Workaround for non-ascii comments on Python2Kevin O'Connor2021-10-081-1/+2
| | | | | | | | Explicitly specify the comment_prefixes as regular Python2 strings - otherwise the configparser wont ignore non-ascii characters in comments. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Ignore trailing comments starting with a semicolonKevin O'Connor2021-10-061-1/+2
| | | | | | | | Newer versions of configparser no longer default to ignoring trailing comments that start with a semicolon. Add that setting explicitly to avoid breaking existing config files. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: Add Python2 module wrappers and use Python3 module namingKevin O'Connor2021-10-041-4/+4
| | | | | | | Add wrappers for some common Python modules so that the code can run on both Python2 and Python3. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Convert to Python3 string encodingKevin O'Connor2021-10-011-2/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add support for reporting deprecated optionsKevin O'Connor2021-09-161-0/+26
| | | | | | | Add a new printer.configfile.warnings with a list of config features that are deprecated. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Setup get_status() results after check_unused_options()Kevin O'Connor2021-09-161-5/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Support config.getchoice() with integer keysKevin O'Connor2021-08-251-1/+4
| | | | | | | | If the choice mapping uses integer keys then lookup the config option using self.getint(). This simplifies the callers and improves the encoding of the printer.configfile.settings export. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add helpers for parsing list of parameters from the configKevin O'Connor2021-08-211-0/+28
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add printer.configfile.settings command template parameterKevin O'Connor2021-01-201-7/+16
| | | | | | | Make available the parsed value (or default value) for config options to command templates and to the api server. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Improve error message when a required option is missingKevin O'Connor2020-12-221-3/+5
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Minor line wrapping changesKevin O'Connor2020-12-221-18/+16
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: report "save_config_pending" via get_status() (#3372)Eric Callahan2020-09-281-1/+5
| | | Signed-off-by: Eric Callahan <arksine.code@gmail.com>
* configfile: Use "import ConfigParser as configparser"Kevin O'Connor2020-06-151-5/+5
| | | | | | This minor change makes it easier to port the code to Python3. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Fix check for unused config sections and optionsKevin O'Connor2020-05-211-16/+21
| | | | | | | | Commit c3899cef inadvertently broke the error check for unused config options. Add a new note_valid parameter to the config access wrappers and use that in get_status() to fix the check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Use new GCodeCommand wrappersKevin O'Connor2020-05-051-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Add get_status() to export raw config file informationKevin O'Connor2020-02-131-3/+13
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* delta_calibrate: Move stable position conversion to its own classKevin O'Connor2020-01-061-0/+2
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Fix the exception raised when an included file is missing (#1931)Julien Lirochon2019-09-011-1/+1
| | | Signed-off-by: Julien Lirochon <julien@lirochon.net>
* configfile: Add "include" support (#1359)lauckhart2019-03-221-14/+65
| | | | | | | | | Allows configuration files to include other configuration files using [include filename.cfg] syntax. Klippy loads include files in the position of the include header; subsequent definitions override included values. Supports wildcards (e.g. [include macros/*.cfg). Allows included files to include other files but blocks recursion. Signed-off-by: Greg Lauckhart <greg@lauckhart.com>
* configfile: Strip trailing commentsKevin O'Connor2018-10-161-0/+8
| | | | | | | The Python 2.x ConfigParser doesn't support stripping of trailing '#' style comments. Do that manually before parsing the config. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: add get_prefix_options methodJanar Sööt2018-09-301-0/+3
| | | | Signed-off-by: Janar Sööt <janar.soot@gmail.com>
* configfile: Add support for rewriting the printer config fileKevin O'Connor2018-09-251-17/+148
| | | | | | | Add support for writing back the main printer config file with additional calibration data stored in it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* configfile: Move config file code from klippy.py to new fileKevin O'Connor2018-09-251-0/+116
Add a klippy/configfile.py file with the code needed to read the main printer config file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>