fixing empty value allowance

This commit is contained in:
brent s 2018-08-07 11:35:40 -04:00
parent 8c9a3cd14b
commit 91bff5412c

View File

@ -33,12 +33,14 @@ _loglevel = 'warning'


class cur_ver(object): class cur_ver(object):
def __init__(self): def __init__(self):
_distname = platform.linux_distribution()[0] # TODO: .dist() is deprecated, as is linux_distribution.
if not re.search('^CentOS( Linux)$', _distname, re.IGNORECASE): # switch to distro? https://pypi.org/project/distro
_distname = platform.dist()[0]
if not re.search('^CentOS( Linux)?$', _distname, re.IGNORECASE):
raise ValueError(('You have specified "{cur_ver}" in your ' + raise ValueError(('You have specified "{cur_ver}" in your ' +
'config, but you are not running this script ' + 'config, but you are not running this script ' +
'on CentOS!')) 'on CentOS!'))
_ver = platform.linux_distribution()[1].split('.') _ver = platform.dist()[1].split('.')
self.full = '.'.join(_ver) self.full = '.'.join(_ver)
self.maj = int(_ver[0]) self.maj = int(_ver[0])
self.min = int(_ver[1]) self.min = int(_ver[1])
@ -92,7 +94,8 @@ class MirrorMgr(object):
def __init__(self): def __init__(self):
self.cfg = configparser.ConfigParser( self.cfg = configparser.ConfigParser(
interpolation = configparser.ExtendedInterpolation(), interpolation = configparser.ExtendedInterpolation(),
defaults = dflts['DEFAULT']) defaults = dflts['DEFAULT'],
allow_no_value = True)
self.strvars = {'cur_ver': None, self.strvars = {'cur_ver': None,
'name': None, 'name': None,
'arches': [], 'arches': [],
@ -132,7 +135,8 @@ class MirrorMgr(object):
def gen_cfg(self): def gen_cfg(self):
cfg = configparser.ConfigParser( cfg = configparser.ConfigParser(
interpolation = configparser.ExtendedInterpolation(), interpolation = configparser.ExtendedInterpolation(),
defaults = dflts['DEFAULT']) defaults = dflts['DEFAULT'],
allow_no_value = True)
for i in dflts.keys(): for i in dflts.keys():
if i != 'DEFAULT': if i != 'DEFAULT':
cfg[i] = copy.deepcopy(dflts[i]) cfg[i] = copy.deepcopy(dflts[i])