def role_get(user):
 user_roles = []
 with salt.utils.fopen('/etc/user_attr', 'r') as user_attr:
  for role in user_attr:
   role = role.strip().strip().split(':')
   if (len(role) != 5):
    continue
   if (role[0] != user):
    continue
   attrs = {}
   for attr in role[4].strip().split(';'):
    (attr_key, attr_val) = attr.strip().split('=')
    if (attr_key in ['auths', 'profiles', 'roles']):
     attrs[attr_key] = attr_val.strip().split(',')
    else:
     attrs[attr_key] = attr_val
   if ('roles' in attrs):
    user_roles.extend(attrs['roles'])
 return list(set(user_roles))

def role_get ( user ) : user_roles = [ ] with salt . utils . fopen ( '/etc/user_attr' , 'r' ) as user_attr : for role in user_attr : role = role . strip ( ) . strip ( ) . split ( ':' ) if ( len ( role ) != 5 ) : continue if ( role [ 0 ] != user ) : continue attrs = { } for attr in role [ 4 ] . strip ( ) . split ( ';' ) : ( attr_key , attr_val ) = attr . strip ( ) . split ( '=' ) if ( attr_key in [ 'auths' , 'profiles' , 'roles' ] ) : attrs [ attr_key ] = attr_val . strip ( ) . split ( ',' ) else : attrs [ attr_key ] = attr_val if ( 'roles' in attrs ) : user_roles . extend ( attrs [ 'roles' ] ) return list ( set ( user_roles ) )
return a dict with information about users of a postgres server .