# 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)
# 
# class CheckList(BaseCheck):
#     '''Container class to perform all child checks
#     '''
#     def __init__(self, children=[]):
#         self.children = children.copy()
# 
#     def check(self, entry, context):
#         r = []
#         for c in self.children:
#             k = c.check(entry, context)
#             if k:
#                 r += k
#         return r


from KPC.classes import Error, HeaderCheck, CheckList
# -*- coding: utf-8 -*-



class NoPoliticsCheck(HeaderCheck):
    keywords = ['dokdo']
    errmsg = '정치적 문구를 쓰는 곳이 아닙니다: %s'

    def check_header(self, entry, fields):
        comment_lines = entry.translator_comment.split('\n')
        r = []
        for k in self.keywords:
            try:
                if k in fields['Last-Translator'].lower():
                    r.append(Error(self.errmsg % fields['Last-Translator']))
                if k in fields['Language-Team'].lower():
                    r.append(Error(self.errmsg % fields['Language-Team']))
                for l in comment_lines:
                    if k in l.lower():

# 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)
# 
# class CheckList(BaseCheck):
#     '''Container class to perform all child checks
#     '''
#     def __init__(self, children=[]):
#         self.children = children.copy()
# 
#     def check(self, entry, context):
#         r = []
#         for c in self.children:
#             k = c.check(entry, context)
#             if k:
#                 r += k
#         return r


# Path: KPC/checks/convention/team-common.py
from KPC.classes import Error, HeaderCheck, CheckList

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



class NoPoliticsCheck(HeaderCheck):
    keywords = ['dokdo']
    errmsg = '정치적 문구를 쓰는 곳이 아닙니다: %s'

    def check_header(self, entry, fields):
        comment_lines = entry.translator_comment.split('\n')
        r = []
        for k in self.keywords:
            try:
                if k in fields['Last-Translator'].lower():
                    r.append(Error(self.errmsg % fields['Last-Translator']))
                if k in fields['Language-Team'].lower():
                    r.append(Error(self.errmsg % fields['Language-Team']))
                for l in comment_lines:
                    if k in l.lower():

                        r.append(Error(self.errmsg % l))