# Path: elem/score/score.py
# class Score(object):
#     def __init__(self, name, pattern, example=None):
#         self.name = name
#         self.pattern = pattern
#         self.regex = re.compile(pattern)
#         self.example = example
#         if self.example and not self.is_valid(self.example):
#             raise InvalidExample(self.name, self.pattern, self.example)
# 
#     def is_valid(self, score_string):
#         if not isinstance(score_string, str):
#             score_string = str(score_string)
#         matches = re.search(self.regex, score_string)
#         if not matches:
#             return False
#         return True
# 
#     def __str__(self):
#         return "{0},{1},{2}".format(self.name, self.pattern, self.example or '')
# 
#     def __iter__(self):
#         score_dict = dict()
#         score_dict[self.name] = dict(pattern=self.pattern, example=self.example or '')
#         return iter(score_dict)


from elem.score import Score

class ScoreManager(object):
    def __init__(self):
        self.scores = dict()

    def add_score(self, name, pattern, example=None):
        if name not in self.scores.keys():
            self.scores[name] = Score(name, pattern, example)

    def delete_score(self, name):
        self.scores.pop(name)

    def get_pattern(self, name):
        return self.scores[name].pattern

    def update_score(self, name, pattern):

# Path: elem/score/score.py
# class Score(object):
#     def __init__(self, name, pattern, example=None):
#         self.name = name
#         self.pattern = pattern
#         self.regex = re.compile(pattern)
#         self.example = example
#         if self.example and not self.is_valid(self.example):
#             raise InvalidExample(self.name, self.pattern, self.example)
# 
#     def is_valid(self, score_string):
#         if not isinstance(score_string, str):
#             score_string = str(score_string)
#         matches = re.search(self.regex, score_string)
#         if not matches:
#             return False
#         return True
# 
#     def __str__(self):
#         return "{0},{1},{2}".format(self.name, self.pattern, self.example or '')
# 
#     def __iter__(self):
#         score_dict = dict()
#         score_dict[self.name] = dict(pattern=self.pattern, example=self.example or '')
#         return iter(score_dict)


# Path: elem/score/score_manager.py
from elem.score import Score


class ScoreManager(object):
    def __init__(self):
        self.scores = dict()

    def add_score(self, name, pattern, example=None):
        if name not in self.scores.keys():
            self.scores[name] = Score(name, pattern, example)

    def delete_score(self, name):
        self.scores.pop(name)

    def get_pattern(self, name):
        return self.scores[name].pattern

    def update_score(self, name, pattern):

        self.scores[name] = Score(name, pattern)