# 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 HeaderCheck(BaseCheck):
#     '''Base class to check the header entries. Subclasses should
#     implement check_header() function.
#     '''
#     def check(self, entry, context):
#         # header messages only
#         if entry.msgid != '':
#             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.check_header(entry, fields)


from KPC.classes import Error, HeaderCheck
# -*- coding: utf-8 -*-
# 헤더 코멘트 검사



class HeaderCommentCheck(HeaderCheck):
    def check_header(self, entry, fields):
        errors = []
        comment = entry.translator_comment
        # PO-Revision-Date의 연도에 맞게 코멘트의 연도가 업데이트되었는지 확인
        try:
            name = fields['Last-Translator'].split(' <')[0].strip()
            year = fields['PO-Revision-Date'][:4]
        except IndexError:
            # FIXME: PO-Revision-Date 또는 Last-Translator가 포맷에 맞지 않는
            # 경우, 또 다른 에러 출력?
            pass
        for line in comment.split('\n'):
            if name in line and year in line:
                break

# 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 HeaderCheck(BaseCheck):
#     '''Base class to check the header entries. Subclasses should
#     implement check_header() function.
#     '''
#     def check(self, entry, context):
#         # header messages only
#         if entry.msgid != '':
#             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.check_header(entry, fields)


# Path: KPC/checks/convention/header-comment.py
from KPC.classes import Error, HeaderCheck

# -*- coding: utf-8 -*-
# 헤더 코멘트 검사



class HeaderCommentCheck(HeaderCheck):
    def check_header(self, entry, fields):
        errors = []
        comment = entry.translator_comment
        # PO-Revision-Date의 연도에 맞게 코멘트의 연도가 업데이트되었는지 확인
        try:
            name = fields['Last-Translator'].split(' <')[0].strip()
            year = fields['PO-Revision-Date'][:4]
        except IndexError:
            # FIXME: PO-Revision-Date 또는 Last-Translator가 포맷에 맞지 않는
            # 경우, 또 다른 에러 출력?
            pass
        for line in comment.split('\n'):
            if name in line and year in line:
                break

        else: