<commit_before>import logging
log = logging.getLogger(__name__)

LX_KSTAT = '/native/usr/bin/kstat'
KSTAT = 'kstat'

def _process_kstat(kstat, cout, digitOnly):
    data = {}
    for line in cout.splitlines():
        key, value = line.split(":")[-1].split()
        if digitOnly:
            if value.isdigit():
                data[key] = value
        else:
            data[key] = value
    return data



def memory_cap(lx=False, digitOnly=False):
    if lx:
        cmd = [ LX_KSTAT, '-p -m memory_cap -c zone_memory_cap']
    else:
        cmd = [ KSTAT, '-p -m memory_cap -c zone_memory_cap']
    output = __salt__['cmd.run'](' '.join(cmd))
    return _process_kstat('memory_cap', output, digitOnly)


def zone_zfs(lx=False, digitOnly=False):
    if lx:
        cmd = [ LX_KSTAT, '-p -m zone_vfs -c zone_vfs']
    else:
        cmd = [ KSTAT, '-p -m zone_vfs -c zone_vfs']
    output = __salt__['cmd.run'](' '.join(cmd))
    return _process_kstat('memory_cap', output, digitOnly)<commit_msg>Take into account recommendations from PR-2<commit_after>import logging
log = logging.getLogger(__name__)

LX_KSTAT = '/native/usr/bin/kstat'
KSTAT = 'kstat'

def _kstat(cmd, lx=False):
    kstat = LX_KSTAT if lx else KSTAT
    cmd = [ kstat, cmd]
    return __salt__['cmd.run'](' '.join(cmd))

def _process_kstat(kstat, cout, digitOnly):
    data = {}
    for line in cout.splitlines():
        key, value = line.split(":")[-1].split()
        if digitOnly:
            v = value
            try:
                v = float(value)
                v = long(value)
            except:
                pass
            if isinstance(v, long) or isinstance(v, float):
                data[key] = v
        else:
            data[key] = value
    return data



def memory_cap(lx=False, digitOnly=False):
    output = _kstat('-p -m memory_cap -c zone_memory_cap', lx)
    return _process_kstat('memory_cap', output, digitOnly)


def zone_zfs(lx=False, digitOnly=False):
    output = _kstat('-p -m zone_vfs -c zone_vfs', lx)
    return _process_kstat('memory_cap', output, digitOnly)
{'fraction_non_alphanumeric': 0.13342967244701348, 'fraction_numerical': 0.001445086705202312, 'mean_word_length': 2.4790619765494135, 'pattern_counts': {'":': 2, '<': 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': '840445', 'n_tokens_mistral': 734, 'n_tokens_neox': 717, 'n_words': 176}