<commit_before>
import abc
import datetime
import logging
import munge
import os
from vaping.config import parse_interval
import vaping.io
from future.utils import with_metaclass


class PluginBase(vaping.io.Thread):
    """
    Base plugin class

    Initializes:

    - `self.plugin_config` as plugins config
    - `self.log` as a logging object for plugin
    - `self.vaping` as a reference to the main vaping object

    then calls `self.init()` prefork while loading all modules, init() should
    not do anything active, any files opened may be closed

    Calls `self.on_start()` and `self.on_stop()` before and after running in
    case any connections need to be created or cleaned up
    """
    def init(self):
        """
        called after the plugin is initialized, plugin may define this for any
        other initialization code
        """
        pass

    def on_start(self):
        """
        called when the daemon is starting
        """
        pass

    def on_stop(self):
        """
        called when the daemon is stopping
        """
        pass

    def popen(self, args, **kwargs):
        """
        creates a subprocess with passed args
        """
        logging.debug("popen %s", ' '.join(args))
        return vaping.io.subprocess.Popen(args, **kwargs)

    @property
    def log(self):
        if not self._logger:
            self._logger = logging.getLogger('vaping.plugins.' + self.plugin_type)
        return self._logger

    def __init__(self, config, ctx):
        super(PluginBase, self).__init__()

        if hasattr(self, 'default_config'):
            self.pluginmgr_config = munge.util.recursive_update(self.default_config, config)
        else:
            self.pluginmgr_config = config
        self.vaping = ctx
        self._logger = None
<commit_msg>add name property<commit_after>
import abc
import datetime
import logging
import munge
import os
from vaping.config import parse_interval
import vaping.io
from future.utils import with_metaclass


class PluginBase(vaping.io.Thread):
    """
    Base plugin class

    Initializes:

    - `self.plugin_config` as plugins config
    - `self.log` as a logging object for plugin
    - `self.vaping` as a reference to the main vaping object

    then calls `self.init()` prefork while loading all modules, init() should
    not do anything active, any files opened may be closed

    Calls `self.on_start()` and `self.on_stop()` before and after running in
    case any connections need to be created or cleaned up
    """
    def init(self):
        """
        called after the plugin is initialized, plugin may define this for any
        other initialization code
        """
        pass

    def on_start(self):
        """
        called when the daemon is starting
        """
        pass

    def on_stop(self):
        """
        called when the daemon is stopping
        """
        pass

    def popen(self, args, **kwargs):
        """
        creates a subprocess with passed args
        """
        logging.debug("popen %s", ' '.join(args))
        return vaping.io.subprocess.Popen(args, **kwargs)

    @property
    def log(self):
        if not self._logger:
            self._logger = logging.getLogger('vaping.plugins.' + self.plugin_type)
        return self._logger

    def __init__(self, config, ctx):
        super(PluginBase, self).__init__()

        if hasattr(self, 'default_config'):
            self.pluginmgr_config = munge.util.recursive_update(self.default_config, config)
        else:
            self.pluginmgr_config = config
        self.vaping = ctx
        self.name = self.pluginmgr_config.get("name")
        self._logger = None

{'fraction_non_alphanumeric': 0.08903365906623235, 'fraction_numerical': 0.0, 'mean_word_length': 2.3469573115349682, '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': '1523440', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1008, 'n_words': 340}