<commit_before># -*- coding: utf-8 -*-
'''
Generate roster data, this data is used by non-minion devices which need to be
hit from the master rather than acting as an independent entity. This covers
hitting minions without zeromq in place via an ssh agent, and connecting to
systems that cannot or should not host a minion agent.
'''
from __future__ import absolute_import

# Import salt libs
import salt.loader
import salt.syspaths

import os
import logging
from salt.ext.six import string_types

log = logging.getLogger(__name__)


def get_roster_file(options):
    if options.get('roster_file'):
        template = options.get('roster_file')
    elif 'config_dir' in options.get('__master_opts__', {}):
        template = os.path.join(options['__master_opts__']['config_dir'],
                                'roster')
    elif 'config_dir' in options:
        template = os.path.join(options['config_dir'], 'roster')
    else:
        template = os.path.join(salt.syspaths.CONFIG_DIR, 'roster')

    if not os.path.isfile(template):
        raise IOError('No roster file found')

    return template


class Roster(object):
    '''
    Used to manage a roster of minions allowing the master to become outwardly
    minion aware
    '''<commit_msg>Pick up a specified roster file from the configured locations<commit_after># -*- coding: utf-8 -*-
'''
Generate roster data, this data is used by non-minion devices which need to be
hit from the master rather than acting as an independent entity. This covers
hitting minions without zeromq in place via an ssh agent, and connecting to
systems that cannot or should not host a minion agent.
'''
from __future__ import absolute_import

# Import salt libs
import salt.loader
import salt.syspaths

import os
import logging
from salt.ext.six import string_types

log = logging.getLogger(__name__)


def get_roster_file(options):
    template = None
    if options.get('__disable_custom_roster') and options.get('roster_file'):
        roster = options.get('roster_file').strip('/')
        for roster_location in options.get('rosters'):
            r_file = os.path.join(roster_location, roster)
            if os.path.isfile(r_file):
                template = r_file
                break
        del options['roster_file']

    if not template:
        if options.get('roster_file'):
            template = options.get('roster_file')
        elif 'config_dir' in options.get('__master_opts__', {}):
            template = os.path.join(options['__master_opts__']['config_dir'],
                                    'roster')
        elif 'config_dir' in options:
            template = os.path.join(options['config_dir'], 'roster')
        else:
            template = os.path.join(salt.syspaths.CONFIG_DIR, 'roster')

    if not os.path.isfile(template):
        raise IOError('No roster file found')

    if not os.access(template, os.R_OK):
        raise IOError('Access denied to roster "{}"'.format(template))

    return template


class Roster(object):
    '''
    Used to manage a roster of minions allowing the master to become outwardly
    minion aware
    '''
{'fraction_non_alphanumeric': 0.09621552277100706, 'fraction_numerical': 0.0006414368184733803, 'mean_word_length': 3.040155440414508, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1038023', 'n_tokens_mistral': 901, 'n_tokens_neox': 866, 'n_words': 296}