Redid 3 days of work after deleting it
parent
1fbe47943b
commit
eef096777e
|
@ -10,21 +10,8 @@ def verifyConfig(cfg: dict) -> (dict, dict):
|
||||||
|
|
||||||
defaults = []
|
defaults = []
|
||||||
|
|
||||||
if 'default' in cfg:
|
|
||||||
defaultCFG = cfg.pop('default')
|
|
||||||
errMessages = []
|
|
||||||
for key, data in defaultCFG.items():
|
|
||||||
bind = tftypes.bind(key, data)
|
|
||||||
if bind.targetType is not None:
|
|
||||||
bind = bind.targetType(bind.key, bind.fields)
|
|
||||||
defaults.append(bind)
|
|
||||||
|
|
||||||
errMessages.extend(bind.errors)
|
|
||||||
|
|
||||||
if len(errMessages) > 0:
|
|
||||||
errors.update({'default': errMessages})
|
|
||||||
|
|
||||||
classList = [
|
classList = [
|
||||||
|
'default',
|
||||||
'scout',
|
'scout',
|
||||||
'soldier',
|
'soldier',
|
||||||
'pyro',
|
'pyro',
|
||||||
|
@ -36,10 +23,12 @@ def verifyConfig(cfg: dict) -> (dict, dict):
|
||||||
'spy'
|
'spy'
|
||||||
]
|
]
|
||||||
|
|
||||||
for cclass in classList:
|
for isclass, cclass in enumerate(classList):
|
||||||
|
|
||||||
classCFG = None
|
classCFG = None
|
||||||
classBinds = []
|
classBinds = []
|
||||||
className = cclass
|
className = cclass
|
||||||
|
|
||||||
if isinstance(cclass, str) and cclass in cfg:
|
if isinstance(cclass, str) and cclass in cfg:
|
||||||
classCFG = cfg.pop(cclass)
|
classCFG = cfg.pop(cclass)
|
||||||
elif isinstance(cclass, tuple):
|
elif isinstance(cclass, tuple):
|
||||||
|
@ -53,18 +42,22 @@ def verifyConfig(cfg: dict) -> (dict, dict):
|
||||||
# It may be less efficient this way, but
|
# It may be less efficient this way, but
|
||||||
# it makes for more descriptive error messages
|
# it makes for more descriptive error messages
|
||||||
continue
|
continue
|
||||||
|
|
||||||
errMessages = []
|
errMessages = []
|
||||||
for key, data in classCFG.items():
|
for key, data in classCFG.items():
|
||||||
bind = tftypes.bind(key, data)
|
bind = tftypes.bind(key, data)
|
||||||
|
|
||||||
if bind.targetType is not None:
|
bind = bind.toTargetType()
|
||||||
bind = bind.targetType(bind.key, bind.fields)
|
if isclass:
|
||||||
classBinds.append(bind)
|
classBinds.append(bind)
|
||||||
|
else:
|
||||||
|
defaults.append(bind)
|
||||||
|
|
||||||
errMessages.extend(bind.errors)
|
errMessages.extend(bind.errors)
|
||||||
|
|
||||||
if len(errMessages) > 0:
|
if len(errMessages) > 0:
|
||||||
errors.update( {className: errMessages} )
|
errors.update( {className: errMessages} )
|
||||||
|
|
||||||
verifiedConfig.update({className: classBinds})
|
verifiedConfig.update({className: classBinds})
|
||||||
|
|
||||||
# Turn list into only strings by expanding tuples
|
# Turn list into only strings by expanding tuples
|
||||||
|
|
Loading…
Reference in New Issue