# Path: KPC/classes.py
# class Error:
#     '''An individual error from a check against an entry. One check
#     usually returns list of errors or empty list if there's no error.
#     '''
#     SUCCESS = 0
#     DEPRECATED = 1
#     WARNING = 2
#     ERROR = 3
# 
#     def __init__(self, message):
#         self.pos = 0
#         self.level = Error.ERROR
#         self.message = message
# 
# class BaseCheck:
#     '''Base class to check an entry from PO files. Subclasses should
#     implement check() function. check() returns list of errors if any.
#     '''
#     def _get_context(self, entry):
#         if not hasattr(self, 'get_context'):
#             return {}
#         fields = {}
#         # parse msgstr
#         for line in entry.msgstr.split('\n'):
#             try:
#                 k, v = line.split(': ', 1)
#                 fields[k] = v
#             except ValueError:
#                 pass
#         return self.get_context(entry, fields)
# 
#     def _check(self, entry, context):
#         return self.check(entry, context)


import re
from KPC.classes import Error, BaseCheck
# -*- coding: utf-8 -*-


josa_data = [('가', '이', '이(가)'),
             ('를', '을', '을(를)'),
             ('는', '은', '은(는)'),
             ('와', '과', '과(와)'),
             ('로', '으로', '(으)로'),
             ('로서', '으로서', '(으)로서'),
             ('로써', '으로써', '(으)로써'),
             ('로부터', '으로부터', '(으)로부터'),
             ('라는', '이라는', '(이)라는')]
c_format = '%(?:[1-9][0-9]*\$)?[-+ #\'0]*(?:[1-9][0-9]*)?(?:\.[0-9]+)?' \
           '(?:(?:hh|h|j|l|L|ll|q|t|z|Z)?' \
           '[dioufeEgGaAcCspnmhjlLqtxXzZ1-9]|hh|ll)'
py_format = '%(?:\([A-Za-z]\w+\))?[#-0\ +]*(?:[0-9]+|\*)?(?:\.[0-9]+)?' \
            '[hlL]?[diouxXeEfFgGcrs]'

josa = '(?:' + '|'.join([p[0]+'|'+p[1] for p in josa_data]) + ')'
josa_c_re = re.compile('(?P<case>(?P<fmt>'+c_format+'[\'\"\u2019\u201D]?) ?'
                       '(?P<josa>'+josa+'))(?:\s|$)')
josa_py_re = re.compile('(?P<case>(?P<fmt>'+py_format+'[\'\"\u2019\u201D]?) ?'
                        '(?P<josa>'+josa+'))(?:\s|$)')


def josa_suggest(cho):
    for (a, b, s) in josa_data:
        if cho == a or cho == b:

# Path: KPC/classes.py
# class Error:
#     '''An individual error from a check against an entry. One check
#     usually returns list of errors or empty list if there's no error.
#     '''
#     SUCCESS = 0
#     DEPRECATED = 1
#     WARNING = 2
#     ERROR = 3
# 
#     def __init__(self, message):
#         self.pos = 0
#         self.level = Error.ERROR
#         self.message = message
# 
# class BaseCheck:
#     '''Base class to check an entry from PO files. Subclasses should
#     implement check() function. check() returns list of errors if any.
#     '''
#     def _get_context(self, entry):
#         if not hasattr(self, 'get_context'):
#             return {}
#         fields = {}
#         # parse msgstr
#         for line in entry.msgstr.split('\n'):
#             try:
#                 k, v = line.split(': ', 1)
#                 fields[k] = v
#             except ValueError:
#                 pass
#         return self.get_context(entry, fields)
# 
#     def _check(self, entry, context):
#         return self.check(entry, context)


# Path: KPC/checks/language/josa-alternative.py
import re
from KPC.classes import Error, BaseCheck

# -*- coding: utf-8 -*-


josa_data = [('가', '이', '이(가)'),
             ('를', '을', '을(를)'),
             ('는', '은', '은(는)'),
             ('와', '과', '과(와)'),
             ('로', '으로', '(으)로'),
             ('로서', '으로서', '(으)로서'),
             ('로써', '으로써', '(으)로써'),
             ('로부터', '으로부터', '(으)로부터'),
             ('라는', '이라는', '(이)라는')]
c_format = '%(?:[1-9][0-9]*\$)?[-+ #\'0]*(?:[1-9][0-9]*)?(?:\.[0-9]+)?' \
           '(?:(?:hh|h|j|l|L|ll|q|t|z|Z)?' \
           '[dioufeEgGaAcCspnmhjlLqtxXzZ1-9]|hh|ll)'
py_format = '%(?:\([A-Za-z]\w+\))?[#-0\ +]*(?:[0-9]+|\*)?(?:\.[0-9]+)?' \
            '[hlL]?[diouxXeEfFgGcrs]'

josa = '(?:' + '|'.join([p[0]+'|'+p[1] for p in josa_data]) + ')'
josa_c_re = re.compile('(?P<case>(?P<fmt>'+c_format+'[\'\"\u2019\u201D]?) ?'
                       '(?P<josa>'+josa+'))(?:\s|$)')
josa_py_re = re.compile('(?P<case>(?P<fmt>'+py_format+'[\'\"\u2019\u201D]?) ?'
                        '(?P<josa>'+josa+'))(?:\s|$)')


def josa_suggest(cho):
    for (a, b, s) in josa_data:
        if cho == a or cho == b:

            return s