def get_user_diff(ipa_user, module_user):
 result = []
 sshpubkey = None
 if ('ipasshpubkey' in module_user):
  module_user['sshpubkeyfp'] = [get_ssh_key_fingerprint(pubkey) for pubkey in module_user['ipasshpubkey']]
  sshpubkey = module_user['ipasshpubkey']
  del module_user['ipasshpubkey']
 for key in module_user.keys():
  mod_value = module_user.get(key, None)
  ipa_value = ipa_user.get(key, None)
  if (isinstance(ipa_value, list) and (not isinstance(mod_value, list))):
   mod_value = [mod_value]
  if (isinstance(ipa_value, list) and isinstance(mod_value, list)):
   mod_value = sorted(mod_value)
   ipa_value = sorted(ipa_value)
  if (mod_value != ipa_value):
   result.append(key)
 if (sshpubkey is not None):
  del module_user['sshpubkeyfp']
  module_user['ipasshpubkey'] = sshpubkey
 return result

def get_user_diff ( ipa_user , module_user ) : result = [ ] sshpubkey = None if ( 'ipasshpubkey' in module_user ) : module_user [ 'sshpubkeyfp' ] = [ get_ssh_key_fingerprint ( pubkey ) for pubkey in module_user [ 'ipasshpubkey' ] ] sshpubkey = module_user [ 'ipasshpubkey' ] del module_user [ 'ipasshpubkey' ] for key in module_user . keys ( ) : mod_value = module_user . get ( key , None ) ipa_value = ipa_user . get ( key , None ) if ( isinstance ( ipa_value , list ) and ( not isinstance ( mod_value , list ) ) ) : mod_value = [ mod_value ] if ( isinstance ( ipa_value , list ) and isinstance ( mod_value , list ) ) : mod_value = sorted ( mod_value ) ipa_value = sorted ( ipa_value ) if ( mod_value != ipa_value ) : result . append ( key ) if ( sshpubkey is not None ) : del module_user [ 'sshpubkeyfp' ] module_user [ 'ipasshpubkey' ] = sshpubkey return result
return the keys of each dict whereas values are different .