def __init__(self, src, fmt = ''):
        # source fields
        self.raw = None
        self.json = None
        # flags
        self.valid = True
        # default values for all fields
        self.text = src
        self.costs = []
        
        if fmt == 'json':
            self.json = src
            manastrs = re.findall(utils.mana_json_regex, src)
        else:
            self.raw = src
            manastrs = re.findall(utils.mana_regex, src)
            
        for manastr in manastrs:
            cost = Manacost(manastr, fmt)
            if not cost.valid:
                self.valid = False
            self.costs += [cost]
            self.text = self.text.replace(manastr, utils.reserved_mana_marker, 1)

        if (utils.mana_open_delimiter in self.text 
            or utils.mana_close_delimiter in self.text
            or utils.mana_json_open_delimiter in self.text 
            or utils.mana_json_close_delimiter in self.text):
            self.valid = False
dataset/ETHPy150Open billzorn/mtgencode/lib/manalib.py/Manatext.__init__/original