<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""This is a command-line tool for PyKayacIM.

Functions defined in this module should not be used directly.

"""

from __future__ import unicode_literals
from __future__ import absolute_import
import pykayacim.api
import pykayacim.exceptions
import argparse
import sys
import builtins
import logging
import atexit

_ez_logger = logging.getLogger("EzKayacIM")
api_logger = logging.getLogger(pykayacim.api.__name__)

@atexit.register
def finish():
    """Called when this command-line tool exits.
    
    """
    
    _ez_logger.info("EzKayacIM exits.")

def decode_params(params):
    """Decode values of the provided dictionary if necessary. 
    
    """
    
    decoded_params = dict()
    for k, v in params.items():
        if isinstance(v, builtins.bytes):
            decoded_params[k] = v.decode(sys.stdin.encoding)
        else:
            decoded_params[k] = v
    _ez_logger.debug("Decoded the provided parameters.")
    return decoded_params

def _send_notification(args):
    """Send a notification.
    
    """
    
    init_params = {"username": args.username, "method": args.method}
    send_params = {"message": args.message, "handler": args.scheme}
    if args.method == "password":
        init_params["key"] = args.pw
    elif args.method == "secret":
        init_params["key"] = args.key
    
    _ez_logger.debug("Initializing an KayacIMAPI instance.")
    api = pykayacim.api.KayacIMAPI(**decode_params(init_params))
    
    _ez_logger.debug("Sending a notification.")
    try:
        api.send(**send_params)
    except pykayacim.exceptions.PyKayacIMError as err:
        _ez_logger.error("Failed to send a notification.")
        sys.exit(-1)
    else:
        _ez_logger.info("Successfully sent a notification.")
        

def main():
    """Used if this module is run as a script.
    
    """
    
    # Logging
    _ez_logger.setLevel(logging.DEBUG)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.ERROR)
    formatter = logging.Formatter(<commit_msg>Oops! I forgot decoding<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""This is a command-line tool for PyKayacIM.

Functions defined in this module should not be used directly.

"""

from __future__ import unicode_literals
from __future__ import absolute_import
import pykayacim.api
import pykayacim.exceptions
import argparse
import sys
import builtins
import logging
import atexit

_ez_logger = logging.getLogger("EzKayacIM")
api_logger = logging.getLogger(pykayacim.api.__name__)

@atexit.register
def finish():
    """Called when this command-line tool exits.
    
    """
    
    _ez_logger.info("EzKayacIM exits.")

def decode_params(params):
    """Decode values of the provided dictionary if necessary. 
    
    """
    
    decoded_params = dict()
    for k, v in params.items():
        if isinstance(v, builtins.bytes):
            decoded_params[k] = v.decode(sys.stdin.encoding)
        else:
            decoded_params[k] = v
    _ez_logger.debug("Decoded the provided parameters.")
    return decoded_params

def _send_notification(args):
    """Send a notification.
    
    """
    
    init_params = {"username": args.username, "method": args.method}
    send_params = {"message": args.message, "handler": args.scheme}
    if args.method == "password":
        init_params["key"] = args.pw
    elif args.method == "secret":
        init_params["key"] = args.key
    
    _ez_logger.debug("Initializing an KayacIMAPI instance.")
    api = pykayacim.api.KayacIMAPI(**decode_params(init_params))
    
    _ez_logger.debug("Sending a notification.")
    try:
        api.send(**decode_params(send_params))
    except pykayacim.exceptions.PyKayacIMError as err:
        _ez_logger.error("Failed to send a notification.")
        sys.exit(-1)
    else:
        _ez_logger.info("Successfully sent a notification.")
        

def main():
    """Used if this module is run as a script.
    
    """
    
    # Logging
    _ez_logger.setLevel(logging.DEBUG)
    console_handler = logging.StreamHandler()
    console_handler.setLevel(logging.ERROR)
    formatter = logging.Formatter(
{'fraction_non_alphanumeric': 0.11095204008589836, 'fraction_numerical': 0.000954426151276545, 'mean_word_length': 3.09375, 'pattern_counts': {'":': 12, '<': 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': '3673546', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1276, 'n_words': 318}