<commit_before>"""Module to handle different store types."""

__all__ = ['git', 'svn', 'web']

import abc


class StoreBase(object):
    """Abstract base class for StoreHandler 'plugins'."""

    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def setup(self):
        """Setup this specific store object."""
        return

    @abc.abstractmethod
    def fetch(self):
        """Retrieve certificates from the store."""
        return

    @abc.abstractmethod
    def write(self, certobj):
        """Write certificate to the central store."""
        return

    @abc.abstractmethod
    def checkpoint(self):
        """Checkpoint any pending actions on the store."""
        return

    def __enter__(self):
        self.setup()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.checkpoint()


def storeerror(name):
    """Error method. Default for getattr to deal with unknown StoreType."""

    print "Unknown StoreType: " + name


def dispatch(name, errorfunc=storeerror):
    """Dispatch a store object to handle this type of Store.

    Returns an object of the appropriate type, or None. Also logs a message
    if the store type could not be found.

    """

    try:
        return __import__('certmgr.StoreHandler.' + name,
            fromlist=name).store()
    except (ImportError, AttributeError), e:
        raise
        return storeerror(name)<commit_msg>Remove debugging statement.<commit_after>"""Module to handle different store types."""

__all__ = ['git', 'svn', 'web']

import abc


class StoreBase(object):
    """Abstract base class for StoreHandler 'plugins'."""

    __metaclass__ = abc.ABCMeta

    @abc.abstractmethod
    def setup(self):
        """Setup this specific store object."""
        return

    @abc.abstractmethod
    def fetch(self):
        """Retrieve certificates from the store."""
        return

    @abc.abstractmethod
    def write(self, certobj):
        """Write certificate to the central store."""
        return

    @abc.abstractmethod
    def checkpoint(self):
        """Checkpoint any pending actions on the store."""
        return

    def __enter__(self):
        self.setup()
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        self.checkpoint()


def storeerror(name):
    """Error method. Default for getattr to deal with unknown StoreType."""

    print "Unknown StoreType: " + name


def dispatch(name, errorfunc=storeerror):
    """Dispatch a store object to handle this type of Store.

    Returns an object of the appropriate type, or None. Also logs a message
    if the store type could not be found.

    """

    try:
        return __import__('certmgr.StoreHandler.' + name,
            fromlist=name).store()
    except (ImportError, AttributeError):
        return storeerror(name)
{'fraction_non_alphanumeric': 0.10481885332395358, 'fraction_numerical': 0.0, 'mean_word_length': 2.732283464566929, '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': '3418185', 'n_tokens_mistral': 779, 'n_tokens_neox': 746, 'n_words': 269}