# 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)


from KPC.classes import Error, BaseCheck
# -*- coding: utf-8 -*-
# KDE specific rule



class KDECheck(BaseCheck):
    name_error = Error('KDE 번역 규칙에 따라 번역자 이름을 써야 합니다')
    email_error = Error('KDE 번역 규칙에 따라 번역자 메일 주소를 써야 합니다')

    def check(self, entry, context):
        msgstr = entry.msgstr
        msgctxt = entry.msgctxt
        if msgctxt == 'NAME OF TRANSLATORS':
            # msgid "Your names"
            if '이름' in msgstr or '성함' in msgstr:
                return [self.name_error]
        elif msgctxt == 'EMAIL OF TRANSLATORS':
            # msgid "Your emails"
            if '메일' in msgstr or '편지' in msgstr:

# 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/convention/kde.py
from KPC.classes import Error, BaseCheck

# -*- coding: utf-8 -*-
# KDE specific rule



class KDECheck(BaseCheck):
    name_error = Error('KDE 번역 규칙에 따라 번역자 이름을 써야 합니다')
    email_error = Error('KDE 번역 규칙에 따라 번역자 메일 주소를 써야 합니다')

    def check(self, entry, context):
        msgstr = entry.msgstr
        msgctxt = entry.msgctxt
        if msgctxt == 'NAME OF TRANSLATORS':
            # msgid "Your names"
            if '이름' in msgstr or '성함' in msgstr:
                return [self.name_error]
        elif msgctxt == 'EMAIL OF TRANSLATORS':
            # msgid "Your emails"
            if '메일' in msgstr or '편지' in msgstr:

                return [self.email_error]