<commit_before>#!/usr/bin/env python

__author__ = '<NAME>'
__license__ = 'Apache 2.0'

#from pyon.public import log

class BaseService(object):
    """
    Something that provides a 'service'.
    Not dependent on messaging.
    Probably will have a simple start/stop interface.
    """

    name = None
    running = 0

services_by_name = {}

def build_service_map():
    global services_by_name

    for cls in BaseService.__subclasses__():
        if cls.name is None:
            raise AssertionError('Service class must define name value. Service class in error: %s' % (str(cls)))
        services_by_name[cls.name] = cls

def add_service_by_name(name, service):
    services_by_name[name] = service

def get_service_by_name(name):
    if services_by_name.has_key(name):
        return services_by_name[name]
    else:
        return None

build_service_map()<commit_msg>Added service_init and service_start method stubs<commit_after>#!/usr/bin/env python

__author__ = '<NAME>'
__license__ = 'Apache 2.0'

class BaseService(object):
    """
    Something that provides a 'service'.
    Not dependent on messaging.
    Probably will have a simple start/stop interface.
    """

    name = None
    running = 0

    def service_init(self):
        """
        Method to be overridden as neccessary by
        implementing service classes to perform
        initialization actions prior to service
        start.  Configuration parameters are
        accessible via the self.CFG dict.
        """
        pass

    def service_start(self):
        """
        Method called at service startup.
        """
        pass

services_by_name = {}

def build_service_map():
    global services_by_name

    for cls in BaseService.__subclasses__():
        if cls.name is None:
            raise AssertionError('Service class must define name value. Service class in error: %s' % (str(cls)))
        services_by_name[cls.name] = cls

def add_service_by_name(name, service):
    services_by_name[name] = service

def get_service_by_name(name):
    if name in services_by_name:
        return services_by_name[name]
    else:
        return None

build_service_map()
{'fraction_non_alphanumeric': 0.08468301712170291, 'fraction_numerical': 0.002776492364645997, 'mean_word_length': 2.881508078994614, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1645730', 'n_tokens_mistral': 640, 'n_tokens_neox': 633, 'n_words': 191}