<commit_before>'''
Support for Linux File Access Control Lists
'''

import sys
import pprint

# Import salt libs
import salt.utils


def __virtual__():
    '''
    Only load the module if lvm is installed
    '''
    if salt.utils.which('getfacl'):
        return 'acl'
    return False


def version():
    '''
    Return LVM version from lvm version

    CLI Example::

        salt '*' lvm.version
    '''
    cmd = 'getfacl --version'
    out = __salt__['cmd.run'](cmd).splitlines()
    ret = out[0].split()
    return ret[1].strip()


def getfacl(*args):
    '''
    Return information about the physical volume(s)
    CLI Example::

        salt '*' acl.getfacl /tmp/house/kitchen
    '''
    ret = {}
    cmd = 'getfacl -p'
    for dentry in args:
        cmd += ' {0}'.format(dentry)
    out = __salt__['cmd.run'](cmd).splitlines()
    dentry = ''
    for line in out:
        if not line:
            continue
        elif line.startswith('getfacl'):
            continue
        elif line.startswith('#'):
            comps = line.replace('# ', '').split(': ')
            if comps[0] == 'file':
                dentry = comps[1]
                ret[dentry] = {'comments': {},
                               'users': [],
                               'groups': []}
            ret[dentry]['comments'][comps[0]] = comps[1]
            if comps[0] == 'flags':
                flags = list(comps[1])
                if flags[0] == 's':
                    ret[dentry]['suid'] = True
                if flags[1] == 's':
                    ret[dentry]['sgid'] = True
                if flags[2] == 't':
                    ret[dentry]['sticky'] = True
        else:
            vals = _parse_acl(acl=line,
                              user=ret[dentry]['comments']['owner'],
                              group=ret[dentry]['comments']['group'])
            pprint.pprint(vals)
            acl_type = vals['type']
            del(vals['type'])
            for entity in ('user', 'group'):
                plural = entity + 's'
                if entity in vals.keys():
                    usergroup = vals[entity]
                    del(vals[entity])
                    if acl_type == 'acl':
                        ret[dentry][plural].append({usergroup: vals})
                    elif acl_type == 'default':
                        if 'defaults' not in ret[dentry].keys():
                            ret[dentry]['defaults'] = {}
                        if plural not in ret[dentry]['defaults'].keys():
                            ret[dentry]['defaults'][plural] = []
                        ret[dentry]['defaults'][plural].append({usergroup: vals})<commit_msg>Removing prints<commit_after>'''
Support for Linux File Access Control Lists
'''

# Import salt libs
import salt.utils


def __virtual__():
    '''
    Only load the module if lvm is installed
    '''
    if salt.utils.which('getfacl'):
        return 'acl'
    return False


def version():
    '''
    Return LVM version from lvm version

    CLI Example::

        salt '*' lvm.version
    '''
    cmd = 'getfacl --version'
    out = __salt__['cmd.run'](cmd).splitlines()
    ret = out[0].split()
    return ret[1].strip()


def getfacl(*args):
    '''
    Return information about the physical volume(s)
    CLI Example::

        salt '*' acl.getfacl /tmp/house/kitchen
    '''
    ret = {}
    cmd = 'getfacl -p'
    for dentry in args:
        cmd += ' {0}'.format(dentry)
    out = __salt__['cmd.run'](cmd).splitlines()
    dentry = ''
    for line in out:
        if not line:
            continue
        elif line.startswith('getfacl'):
            continue
        elif line.startswith('#'):
            comps = line.replace('# ', '').split(': ')
            if comps[0] == 'file':
                dentry = comps[1]
                ret[dentry] = {'comments': {},
                               'users': [],
                               'groups': []}
            ret[dentry]['comments'][comps[0]] = comps[1]
            if comps[0] == 'flags':
                flags = list(comps[1])
                if flags[0] == 's':
                    ret[dentry]['suid'] = True
                if flags[1] == 's':
                    ret[dentry]['sgid'] = True
                if flags[2] == 't':
                    ret[dentry]['sticky'] = True
        else:
            vals = _parse_acl(acl=line,
                              user=ret[dentry]['comments']['owner'],
                              group=ret[dentry]['comments']['group'])
            acl_type = vals['type']
            del(vals['type'])
            for entity in ('user', 'group'):
                plural = entity + 's'
                if entity in vals.keys():
                    usergroup = vals[entity]
                    del(vals[entity])
                    if acl_type == 'acl':
                        ret[dentry][plural].append({usergroup: vals})
                    elif acl_type == 'default':
                        if 'defaults' not in ret[dentry].keys():
                            ret[dentry]['defaults'] = {}
                        if plural not in ret[dentry]['defaults'].keys():
                            ret[dentry]['defaults'][plural] = []
                        ret[dentry]['defaults'][plural].append({usergroup: vals})
{'fraction_non_alphanumeric': 0.14737041241013998, 'fraction_numerical': 0.004540295119182747, 'mean_word_length': 1.4420323325635105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1174444', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1476, 'n_words': 341}