<commit_before>""" pynpoint redis client """

import pyredis
from pynpoint.config import Config


class Redis(pyredis.Redis):
    """ A Borg-style Redis client class. """
    __shared_state = {}

    def __new__(cls):
        self = object.__new__(cls)
        self.__dict__ = cls.__shared_state
        return self

    def __init__(self, config=Config()):
        if not self.__dict__:
            print "Opening a new redis connection"
            kwargs = {"host": config.redis_hostname,
                      "port": config.redis_port,
                      "db": config.redis_db}

            pyredis.Redis.__init__(self, **kwargs)<commit_msg>Apparently pyredis was deprecated for redis-py which is a nicer client anyway.<commit_after>""" pynpoint redis client """

from __future__ import absolute_import
import redis as pyredis
from pynpoint.config import Config


class Redis(object):
    """ A Borg-style wrapper for Redis client class. """
    __shared_state = {}

    def __new__(cls, config=Config()):
        self = object.__new__(cls)
        self.__dict__ = cls.__shared_state
        return self

    def __init__(self, config=Config()):
        if not self.__dict__:
            print "Opening a new redis connection"
            kwargs = {"host": config.redis_hostname,
                      "port": config.redis_port,
                      "db": config.redis_db}

            self.conn = pyredis.Redis(**kwargs)

    def __getattr__(self, name):
        def call(*args):
            """ Pass through the query to our redis connection """
            cmd = getattr(self.conn, name)
            return cmd(*args)

        if name in self.__dict__:
            return self.__dict__.get(name)

        return call
{'fraction_non_alphanumeric': 0.10011574074074074, 'fraction_numerical': 0.0, 'mean_word_length': 2.2197392923649906, 'pattern_counts': {'":': 6, '<': 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': '5855107', 'n_tokens_mistral': 501, 'n_tokens_neox': 482, 'n_words': 139}