<commit_before># coding: utf-8
from __future__ import unicode_literals

import gevent
import logging
from gevent.pool import Pool
from gevent.monkey import patch_all
patch_all()

from redis import StrictRedis
from importlib import import_module
from slackclient import SlackClient

from settings import APPS, SLACK_TOKEN, REDIS_URL


pool = Pool(20)

CMD_PREFIX = '!'
logger = logging.getLogger()


class RedisBrain(object):
    def __init__(self):
        try:
            self.redis = StrictRedis(host=REDIS_URL)
        except Exception as e:
            logger.error(e)
            self.redis = None

    def set(self, key, value):
        if self.redis:
            self.redis.set(key, value)
            return True
        else:
            return False

    def get(self, key):
        if self.redis:
            return self.redis.get(key)
        return None


class Robot(object):
    def __init__(self):
        self.client = SlackClient(SLACK_TOKEN)
        self.brain = RedisBrain()
        self.apps, self.docs = self.load_apps()

    def load_apps(self):
        docs = ['='*14, '홍모아 사용방법', '='*14]
        apps = {}

        for name in APPS:<commit_msg>add list operation to brain<commit_after># coding: utf-8
from __future__ import unicode_literals

import gevent
import logging
from gevent.pool import Pool
from gevent.monkey import patch_all
patch_all()

from redis import StrictRedis
from importlib import import_module
from slackclient import SlackClient

from settings import APPS, SLACK_TOKEN, REDIS_URL


pool = Pool(20)

CMD_PREFIX = '!'
logger = logging.getLogger()


class RedisBrain(object):
    def __init__(self):
        try:
            self.redis = StrictRedis(host=REDIS_URL)
        except Exception as e:
            logger.error(e)
            self.redis = None

    def set(self, key, value):
        if self.redis:
            self.redis.set(key, value)
            return True
        else:
            return False

    def get(self, key):
        if self.redis:
            return self.redis.get(key)
        return None

    def lpush(self, key, value):
        if self.redis:
            self.redis.lpush(key, value)
            return True
        else:
            return False

    def lpop(self, key):
        if self.redis:
            return self.redis.lpop(key)
        return None

    def lindex(self, key):
        if self.redis:
            return self.redis.lindex(key)
        return None


class Robot(object):
    def __init__(self):
        self.client = SlackClient(SLACK_TOKEN)
        self.brain = RedisBrain()
        self.apps, self.docs = self.load_apps()

    def load_apps(self):
        docs = ['='*14, '홍모아 사용방법', '='*14]
        apps = {}

        for name in APPS:
{'fraction_non_alphanumeric': 0.09024479356960176, 'fraction_numerical': 0.005115089514066497, 'mean_word_length': 2.191142191142191, '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': '5839520', 'n_tokens_mistral': 894, 'n_tokens_neox': 880, 'n_words': 238}