def _get_account_policy(name):
 cmd = 'pwpolicy -u {0} -getpolicy'.format(name)
 try:
  ret = salt.utils.mac_utils.execute_return_result(cmd)
 except CommandExecutionError as exc:
  if ('Error: user <{0}> not found'.format(name) in exc.strerror):
   raise CommandExecutionError('User not found: {0}'.format(name))
  raise CommandExecutionError('Unknown error: {0}'.format(exc.strerror))
 try:
  policy_list = ret.split('\n')[1].split(' ')
  policy_dict = {}
  for policy in policy_list:
   if ('=' in policy):
    (key, value) = policy.split('=')
    policy_dict[key] = value
  return policy_dict
 except IndexError:
  return {}

def _get_account_policy ( name ) : cmd = 'pwpolicy -u {0} -getpolicy' . format ( name ) try : ret = salt . utils . mac_utils . execute_return_result ( cmd ) except CommandExecutionError as exc : if ( 'Error: user <{0}> not found' . format ( name ) in exc . strerror ) : raise CommandExecutionError ( 'User not found: {0}' . format ( name ) ) raise CommandExecutionError ( 'Unknown error: {0}' . format ( exc . strerror ) ) try : policy_list = ret . split ( '\n' ) [ 1 ] . split ( ' ' ) policy_dict = { } for policy in policy_list : if ( '=' in policy ) : ( key , value ) = policy . split ( '=' ) policy_dict [ key ] = value return policy_dict except IndexError : return { }
get the entire accountpolicy and return it as a dictionary .