<commit_before>from st2actions.runners.pythonrunner import Action
from requests import Request
import logging
from utils import sanitize_payload

logger = logging.getLogger(__name__)


class SaltPackage(object):
    _expression_forms = [
        'glob',
        'grain',
        'pillar',
        'nodegroup',
        'list',
        'compound'
    ]
    _data = {"eauth": "",
             "username": "",
             "password": "",
             "client": "",
             "fun": ""}

    def __init__(self, client='local'):
        self._data['client'] = client

    @property
    def data(self):
        return self._data

    @data.setter
    def data(self, key_value=[]):
        key, value = key_value
        self._data[key] = value


class SaltAction(Action):

    def __init__(self, config):
        super(SaltAction, self).__init__(config=config)
        self.url = self.config.get('api_url', None)
        self.eauth = self.config.get('eauth', None)
        self.username = self.config.get('username', None)
        self.password = self.config.get('password', None)

    def generate_package(self, client='local', cmd=None, **kwargs):
        self.data = SaltPackage(client).data
        self.data['eauth'] = self.eauth
        self.data['username'] = self.username
        self.data['password'] = self.password
        if cmd:
            self.data['fun'] = cmd
        if client is 'local':
            self.data['tgt'] = kwargs.get('target', '*')
            self.data['expr_form'] = kwargs.get('expr_form', 'glob')
        if kwargs['data'] is not None:
            d = dict()
            d['kwarg'] = kwargs['data']['kwargs']
            self.data.update(d)
        logging.info("Sending To Salt API: {0}".format(sanitize_payload(('username', 'password'), self.data)))

    def generate_request(self):
        req = Request('POST',
                      "{0}/run".format(self.url),
                      headers={'content-type': 'application/json',
                               'charset': 'utf-8'})
        return req.prepare()<commit_msg>typo: logger name<commit_after>from st2actions.runners.pythonrunner import Action
from requests import Request
import logging
from utils import sanitize_payload

logger = logging.getLogger(__name__)


class SaltPackage(object):
    _expression_forms = [
        'glob',
        'grain',
        'pillar',
        'nodegroup',
        'list',
        'compound'
    ]
    _data = {"eauth": "",
             "username": "",
             "password": "",
             "client": "",
             "fun": ""}

    def __init__(self, client='local'):
        self._data['client'] = client

    @property
    def data(self):
        return self._data

    @data.setter
    def data(self, key_value=[]):
        key, value = key_value
        self._data[key] = value


class SaltAction(Action):

    def __init__(self, config):
        super(SaltAction, self).__init__(config=config)
        self.url = self.config.get('api_url', None)
        self.eauth = self.config.get('eauth', None)
        self.username = self.config.get('username', None)
        self.password = self.config.get('password', None)

    def generate_package(self, client='local', cmd=None, **kwargs):
        self.data = SaltPackage(client).data
        self.data['eauth'] = self.eauth
        self.data['username'] = self.username
        self.data['password'] = self.password
        if cmd:
            self.data['fun'] = cmd
        if client is 'local':
            self.data['tgt'] = kwargs.get('target', '*')
            self.data['expr_form'] = kwargs.get('expr_form', 'glob')
        if kwargs['data'] is not None:
            d = dict()
            d['kwarg'] = kwargs['data']['kwargs']
            self.data.update(d)
        logger.info("Sending To Salt API: {0}".format(sanitize_payload(('username', 'password'), self.data)))

    def generate_request(self):
        req = Request('POST',
                      "{0}/run".format(self.url),
                      headers={'content-type': 'application/json',
                               'charset': 'utf-8'})
        return req.prepare()
{'fraction_non_alphanumeric': 0.15076474872541878, 'fraction_numerical': 0.0019422189851905803, 'mean_word_length': 2.166794773251345, 'pattern_counts': {'":': 10, '<': 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': '6621392', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1188, 'n_words': 247}