def get_selinux_context(path):
    out = __salt__['cmd.run'](['ls', '-Z', path], python_shell=False)

    try:
        ret = re.search(r'\w+:\w+:\w+:\w+', out).group(0)
    except AttributeError:
        ret = (
            'No selinux context information is available for {0}'.format(path)
        )

    return ret
Get an SELinux context from a given path
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/get_selinux_context