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>
This commit is contained in:
Kevin O'Connor 2018-09-04 20:49:47 -04:00 committed by KevinOConnor
parent 5144c5f01e
commit f80456a698
3 changed files with 130 additions and 116 deletions

View file

@ -5,9 +5,7 @@
# Copyright (C) 2018 Janar Sööt <janar.soot@gmail.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import os, ConfigParser, logging
import sys, ast, re
import klippy
import os, logging, sys, ast, re
class error(Exception):
@ -963,10 +961,9 @@ class MenuManager:
desc=self.cmd_DO_help)
# Parse local config file in same directory as current module
fileconfig = ConfigParser.RawConfigParser()
pconfig = self.printer.lookup_object('configfile')
localname = os.path.join(os.path.dirname(__file__), 'menu.cfg')
fileconfig.read(localname)
localconfig = klippy.ConfigWrapper(self.printer, fileconfig, {}, None)
localconfig = pconfig.read_config(localname)
# Load items from local config
self.load_menuitems(localconfig)