Alternative implementation for getspnam, that use only /etc/shadow

def _getspnam(name, root=None):
    '''
    Alternative implementation for getspnam, that use only /etc/shadow
    '''
    root = '/' if not root else root
    passwd = os.path.join(root, 'etc/shadow')
    with salt.utils.files.fopen(passwd) as fp_:
        for line in fp_:
            line = salt.utils.stringutils.to_unicode(line)
            comps = line.strip().split(':')
            if comps[0] == name:
                # Generate a getspnam compatible output
                for i in range(2, 9):
                    comps[i] = int(comps[i]) if comps[i] else -1
                return spwd.struct_spwd(comps)
    raise KeyError