the following code inside a function def seems to me to be unwieldy. Is there a better way to conditionally prefer one parameter over a dict. This came from some impedance mismatch between robotframework which does not (IMO) have a satisfactory handle on kwargs:
def get_passwd(input_dict=None, **kwargs):
pswd = None
if input_dict:
if input_dict and input_dict.get('passphrase_confirm'):
pswd = input_dict['passphrase_confirm']
elif kwargs.get('passphrase_confirm'):
pswd = kwargs['passphrase_confirm']
if not pswd:
# here because there was no password_confirm or no input_dict, we look again in kwargs
if 'passphrase_confirm' in kwargs and kwargs['passphrase_confirm']:
pswd = kwargs['passphrase_confirm']
elif input_dict and 'passphrase' in input_dict and input_dict['passphrase_confirm']:
pswd = input_dict['passphrase']
elif 'passphrase' in kwargs and kwargs['passphrase']:
pswd = kwargs['passphrase']
return pswd