Commit Graph

24 Commits

Author SHA1 Message Date
Kevin O'Connor c56c34fa1c configfile: Use Python2's ConfigParser when running on Python2
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>
2021-10-09 19:37:48 -04:00
Kevin O'Connor 5251bf23f1 configfile: Workaround for non-ascii comments on Python2
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>
2021-10-08 00:23:31 -04:00
Kevin O'Connor c7b65f50e3 configfile: Ignore trailing comments starting with a semicolon
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>
2021-10-06 14:07:32 -04:00
Kevin O'Connor f1747b5118 klippy: Add Python2 module wrappers and use Python3 module naming
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>
2021-10-04 14:36:08 -04:00
Kevin O'Connor 0da3d84a87 configfile: Convert to Python3 string encoding
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-10-01 19:22:13 -04:00
Kevin O'Connor 46167cae67 configfile: Add support for reporting deprecated options
Add a new printer.configfile.warnings with a list of config features
that are deprecated.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-09-16 13:44:54 -04:00
Kevin O'Connor c89db2480d configfile: Setup get_status() results after check_unused_options()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-09-16 13:44:54 -04:00
Kevin O'Connor 84ac5b0146 configfile: Support config.getchoice() with integer keys
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>
2021-08-25 10:36:45 -04:00
Kevin O'Connor f9ca5b9098 configfile: Add helpers for parsing list of parameters from the config
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2021-08-21 18:08:10 -04:00
Kevin O'Connor 8cc1d84180 configfile: Add printer.configfile.settings command template parameter
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>
2021-01-20 16:25:25 -05:00
Kevin O'Connor 16963a8e1a configfile: Improve error message when a required option is missing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-22 20:07:39 -05:00
Kevin O'Connor ca8e6ad89b configfile: Minor line wrapping changes
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-12-22 20:06:15 -05:00
Eric Callahan a8e3afd64a
configfile: report "save_config_pending" via get_status() (#3372)
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2020-09-28 00:05:55 -04:00
Kevin O'Connor a1fc1ac214 configfile: Use "import ConfigParser as configparser"
This minor change makes it easier to port the code to Python3.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-06-15 17:15:53 -04:00
Kevin O'Connor 492cd3d99f configfile: Fix check for unused config sections and options
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>
2020-05-21 17:50:51 -04:00
Kevin O'Connor c186766708 configfile: Use new GCodeCommand wrappers
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-05-05 11:08:11 -04:00
Kevin O'Connor c3899cefa8 configfile: Add get_status() to export raw config file information
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-02-13 22:04:40 -05:00
Kevin O'Connor fdfa26edd6 delta_calibrate: Move stable position conversion to its own class
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2020-01-06 11:41:09 -05:00
Julien Lirochon 12feb6d7fb configfile: Fix the exception raised when an included file is missing (#1931)
Signed-off-by: Julien Lirochon <julien@lirochon.net>
2019-09-01 18:28:18 -04:00
lauckhart 7a344acde8 configfile: Add "include" support (#1359)
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>
2019-03-22 20:31:40 -04:00
Kevin O'Connor 08d03ae0eb configfile: Strip trailing comments
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>
2018-10-16 11:45:20 -04:00
Janar Sööt d9e35481be configfile: add get_prefix_options method
Signed-off-by: Janar Sööt <janar.soot@gmail.com>
2018-09-30 11:51:26 -04:00
Kevin O'Connor 531134f092 configfile: Add support for rewriting the printer config file
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>
2018-09-25 13:48:46 -04:00
Kevin O'Connor f80456a698 configfile: Move config file code from klippy.py to new file
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>
2018-09-25 13:48:46 -04:00