Adjusted get_actions()

* Handle 'If answer' & 'Win10 Only' options
This commit is contained in:
2Shirt 2019-05-10 14:25:00 -06:00
parent 9553cbcbc8
commit de247c919b
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -124,12 +124,10 @@ SETUP_ACTIONS = OrderedDict({
})
SETUP_ACTION_KEYS = (
'Function',
'If answer',
'If not activated',
'Just run',
'KWArgs',
'Pause',
'Win10 only',
)
SETUP_QUESTIONS = {
# AV
@ -149,11 +147,22 @@ SETUP_QUESTIONS = {
# Functions
def get_actions(setup_mode):
def get_actions(setup_mode, answers):
"""Get actions to perform based on setup_mode, returns OrderedDict."""
actions = OrderedDict({})
for _key, _val in SETUP_ACTIONS.items():
_action = {'Enabled': _val.get(setup_mode, False)}
_action = {}
_if_answer = _val.get('If answer', False)
_win10_only = _val.get('Win10 only', False)
# Set enabled status
_action['Enabled'] = _val.get(setup_mode, False)
if _if_answer:
_action['Enabled'] &= answers[_if_answer]
if _win10_only:
_action['Enabled'] &= global_vars['OS']['Version'] == '10'
# Set other keys
for _sub_key in SETUP_ACTION_KEYS:
_action[_sub_key] = _val.get(_sub_key, None)
actions[_key] = _action
@ -258,12 +267,12 @@ def main():
# Get setup mode
setup_mode = get_mode()
# Get actions to perform
actions = get_actions(setup_mode)
# Get answers to setup questions
answers = get_answers(setup_mode)
# Get actions to perform
actions = get_actions(setup_mode, answers)
# Perform actions
# TODO