<commit_before># -*- coding: utf-8 -*-
'''
    Detect SSDs
'''

# Import python libs
import glob
import salt.utils
import logging

log = logging.getLogger(__name__)


def ssds():
    '''
    Return list of disk devices that are SSD (non-rotational)
    '''
    ssd_devices = []
    for entry in glob.glob('/sys/block/*/queue/rotational'):
        with salt.utils.fopen(entry) as entry_fp:
            device = entry.split('/')[3]
            flag = entry_fp.read(1)
            if flag == '0':
                ssd_devices.append(device)
                log.trace('Device {0} reports itself as an SSD'.format(device))
            elif flag == '1':
                log.trace('Device {0} does not report itself as an SSD'.format(device))
            else:
                log.trace('Unable to identify device {0} as an SSD or not. It does not report 0 or 1'.format(device))
    return {'SSDs': ssd_devices}
<commit_msg>Making salt.grains.ssds python3 compatible<commit_after># -*- coding: utf-8 -*-
'''
    Detect SSDs
'''
from __future__ import absolute_import

# Import python libs
import glob
import salt.utils
import logging

log = logging.getLogger(__name__)


def ssds():
    '''
    Return list of disk devices that are SSD (non-rotational)
    '''
    ssd_devices = []
    for entry in glob.glob('/sys/block/*/queue/rotational'):
        with salt.utils.fopen(entry) as entry_fp:
            device = entry.split('/')[3]
            flag = entry_fp.read(1)
            if flag == '0':
                ssd_devices.append(device)
                log.trace('Device {0} reports itself as an SSD'.format(device))
            elif flag == '1':
                log.trace('Device {0} does not report itself as an SSD'.format(device))
            else:
                log.trace('Unable to identify device {0} as an SSD or not. It does not report 0 or 1'.format(device))
    return {'SSDs': ssd_devices}

{'fraction_non_alphanumeric': 0.12631578947368421, 'fraction_numerical': 0.011052631578947368, 'mean_word_length': 2.2329931972789114, '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': '2534810', 'n_tokens_mistral': 581, 'n_tokens_neox': 553, 'n_words': 175}