Retrieve GECOS field info and return it in dictionary form

def _get_gecos(name, root=None):
    '''
    Retrieve GECOS field info and return it in dictionary form
    '''
    if root is not None and __grains__['kernel'] != 'AIX':
        getpwnam = functools.partial(_getpwnam, root=root)
    else:
        getpwnam = functools.partial(pwd.getpwnam)
    gecos_field = salt.utils.stringutils.to_unicode(
        getpwnam(_quote_username(name)).pw_gecos).split(',', 4)

    if not gecos_field:
        return {}
    else:
        # Assign empty strings for any unspecified trailing GECOS fields
        while len(gecos_field) < 5:
            gecos_field.append('')
        return {'fullname': salt.utils.data.decode(gecos_field[0]),
                'roomnumber': salt.utils.data.decode(gecos_field[1]),
                'workphone': salt.utils.data.decode(gecos_field[2]),
                'homephone': salt.utils.data.decode(gecos_field[3]),
                'other': salt.utils.data.decode(gecos_field[4])}