<commit_before># -*- coding: utf-8 -*-
"""
    logbook.notifiers
    ~~~~~~~~~~~~~~~~~

    System notify handlers for OSX and Linux.

    :copyright: (c) 2010 by <NAME>, <NAME>.
    :license: BSD, see LICENSE for more details.
"""
import os

from logbook.base import NOTSET, ERROR, WARNING
from logbook.handlers import Handler
from logbook.helpers import get_application_name


def create_notification_handler(application_name=None, level=NOTSET, icon=None):
    """Creates a handler perfectly fit the current platform.  On Linux
    systems this creates a :class:`LibNotifyHandler`, on OS X systems it
    will create a :class:`GrowlHandler`.
    """
    if os.name == 'posix':
        return LibNotifyHandler(application_name, level=level, icon=icon)
    return GrowlHandler(application_name, level=level, icon=icon)


class GrowlHandler(Handler):
    """A handler that dispatches to Growl.  Requires that either growl-py or
    py-Growl are installed.
    """

    def __init__(self, application_name=None, icon=None, host=None,
                 password=<PASSWORD>, level=NOTSET, filter=None, bubble=False):
        Handler.__init__(self, level, filter, bubble)

        # growl is using the deprecated md5 module, but we really don't need
        # to see that deprecation warning
        from warnings import filterwarnings
        filterwarnings(module='Growl', category=DeprecationWarning,
                       action='ignore')

        try:
            import Growl
            self._growl = Growl
        except ImportError:
            raise RuntimeError('The growl module is not available.  You have '
                               'to install either growl-py or py-Growl to '
                               'use the GrowlHandler.')

        # if no application name is provided, guess it from the executable
        if application_name is None:
            application_name = get_application_name()

        if icon is not None:
            if not os.path.isfile(icon):<commit_msg>Fix create_notification_handler on os x<commit_after># -*- coding: utf-8 -*-
"""
    logbook.notifiers
    ~~~~~~~~~~~~~~~~~

    System notify handlers for OSX and Linux.

    :copyright: (c) 2010 by <NAME>, <NAME>.
    :license: BSD, see LICENSE for more details.
"""
import os
import sys

from logbook.base import NOTSET, ERROR, WARNING
from logbook.handlers import Handler
from logbook.helpers import get_application_name


def create_notification_handler(application_name=None, level=NOTSET, icon=None):
    """Creates a handler perfectly fit the current platform.  On Linux
    systems this creates a :class:`LibNotifyHandler`, on OS X systems it
    will create a :class:`GrowlHandler`.
    """
    if os.platform == 'darwin':
        return GrowlHandler(application_name, level=level, icon=icon)
    return LibNotifyHandler(application_name, level=level, icon=icon)


class GrowlHandler(Handler):
    """A handler that dispatches to Growl.  Requires that either growl-py or
    py-Growl are installed.
    """

    def __init__(self, application_name=None, icon=None, host=None,
                 password=<PASSWORD>, level=NOTSET, filter=None, bubble=False):
        Handler.__init__(self, level, filter, bubble)

        # growl is using the deprecated md5 module, but we really don't need
        # to see that deprecation warning
        from warnings import filterwarnings
        filterwarnings(module='Growl', category=DeprecationWarning,
                       action='ignore')

        try:
            import Growl
            self._growl = Growl
        except ImportError:
            raise RuntimeError('The growl module is not available.  You have '
                               'to install either growl-py or py-Growl to '
                               'use the GrowlHandler.')

        # if no application name is provided, guess it from the executable
        if application_name is None:
            application_name = get_application_name()

        if icon is not None:
            if not os.path.isfile(icon):
{'fraction_non_alphanumeric': 0.08915304606240713, 'fraction_numerical': 0.0029717682020802376, 'mean_word_length': 2.655203619909502, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6773924', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1065, 'n_words': 371}