1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

python compat: remove ConfigParser

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
David Mulder 2020-08-20 15:51:47 -06:00 committed by Andrew Bartlett
parent 3c026ba492
commit 4a252f6e0f
3 changed files with 10 additions and 12 deletions

View File

@ -71,11 +71,6 @@ if PY3:
# compat functions
from functools import cmp_to_key as cmp_to_key_fn
# alias
def ConfigParser(defaults=None, dict_type=dict, allow_no_value=False):
from configparser import ConfigParser
return ConfigParser(defaults, dict_type, allow_no_value, interpolation=None)
else:
raise NotImplementedError("Samba versions >= 4.11 do not support Python 2.x")

View File

@ -22,7 +22,7 @@ import collections
import re
from xml.etree.ElementTree import Element, SubElement
from samba.compat import ConfigParser
from configparser import ConfigParser
from io import StringIO
from samba.gp_parse import GPParser, ENTITY_USER_ID
@ -34,7 +34,8 @@ class GPIniParser(GPParser):
def parse(self, contents):
# Required dict_type in Python 2.7
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict)
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict,
interpolation=None)
self.ini_conf.optionxform = str
self.ini_conf.readfp(StringIO(contents.decode(self.encoding)))
@ -88,7 +89,8 @@ class GPIniParser(GPParser):
def load_xml(self, root):
# Required dict_type in Python 2.7
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict)
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict,
interpolation=None)
self.ini_conf.optionxform = str
for s in root.findall('Section'):
@ -110,7 +112,8 @@ class GPTIniParser(GPIniParser):
super(GPTIniParser, self).parse(contents)
except UnicodeDecodeError:
# Required dict_type in Python 2.7
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict)
self.ini_conf = ConfigParser(dict_type=collections.OrderedDict,
interpolation=None)
self.ini_conf.optionxform = str
# Fallback to Latin-1 which RSAT appears to use

View File

@ -21,7 +21,7 @@ import errno
import tdb
sys.path.insert(0, "bin/python")
from samba import NTSTATUSError
from samba.compat import ConfigParser
from configparser import ConfigParser
from io import StringIO
from samba.compat import get_bytes
from abc import ABCMeta, abstractmethod
@ -326,7 +326,7 @@ class gp_ext(object):
class gp_inf_ext(gp_ext):
def read(self, data_file):
policy = open(data_file, 'rb').read()
inf_conf = ConfigParser()
inf_conf = ConfigParser(interpolation=None)
inf_conf.optionxform = str
try:
inf_conf.readfp(StringIO(policy.decode()))
@ -525,7 +525,7 @@ def parse_gpext_conf(smb_conf):
else:
lp.load_default()
ext_conf = lp.state_path('gpext.conf')
parser = ConfigParser()
parser = ConfigParser(interpolation=None)
parser.read(ext_conf)
return lp, parser