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>
This commit is contained in:
Kevin O'Connor 2020-06-12 10:03:28 -04:00
parent 40da3f406a
commit a1fc1ac214
1 changed files with 5 additions and 5 deletions

View File

@ -3,15 +3,15 @@
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net> # Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
# #
# This file may be distributed under the terms of the GNU GPLv3 license. # This file may be distributed under the terms of the GNU GPLv3 license.
import os, glob, re, time, logging, ConfigParser, StringIO import os, glob, re, time, logging, ConfigParser as configparser, StringIO
error = ConfigParser.Error error = configparser.Error
class sentinel: class sentinel:
pass pass
class ConfigWrapper: class ConfigWrapper:
error = ConfigParser.Error error = configparser.Error
def __init__(self, printer, fileconfig, access_tracking, section): def __init__(self, printer, fileconfig, access_tracking, section):
self.printer = printer self.printer = printer
self.fileconfig = fileconfig self.fileconfig = fileconfig
@ -194,7 +194,7 @@ class PrinterConfig:
if pos >= 0: if pos >= 0:
line = line[:pos] line = line[:pos]
# Process include or buffer line # Process include or buffer line
mo = ConfigParser.RawConfigParser.SECTCRE.match(line) mo = configparser.RawConfigParser.SECTCRE.match(line)
header = mo and mo.group('header') header = mo and mo.group('header')
if header and header.startswith('include '): if header and header.startswith('include '):
self._parse_config_buffer(buffer, filename, fileconfig) self._parse_config_buffer(buffer, filename, fileconfig)
@ -206,7 +206,7 @@ class PrinterConfig:
self._parse_config_buffer(buffer, filename, fileconfig) self._parse_config_buffer(buffer, filename, fileconfig)
visited.remove(path) visited.remove(path)
def _build_config_wrapper(self, data, filename): def _build_config_wrapper(self, data, filename):
fileconfig = ConfigParser.RawConfigParser() fileconfig = configparser.RawConfigParser()
self._parse_config(data, filename, fileconfig, set()) self._parse_config(data, filename, fileconfig, set())
return ConfigWrapper(self.printer, fileconfig, {}, 'printer') return ConfigWrapper(self.printer, fileconfig, {}, 'printer')
def _build_config_string(self, config): def _build_config_string(self, config):