def __init__(self, src, fmt = ''):
        # source fields, exactly one will be set
        self.raw = None
        self.json = None
        # flags
        self.parsed = True
        self.valid = True
        self.none = False
        # default values for all fields
        self.inner = None
        self.cmc = 0
        self.colorless = 0
        self.sequence = []
        self.symbols = {sym : 0 for sym in utils.mana_syms}
        self.allsymbols = {sym : 0 for sym in utils.mana_symall}
        self.colors = ''

        if fmt == 'json':
            self.json = src
            text = utils.mana_translate(self.json.upper())
        else:
            self.raw = src
            text = self.raw

        if text == '':
            self.inner = ''
            self.none = True

        elif not (len(text) >= 2 and text[0] == '{' and text[-1] == '}'):
            self.parsed = False
            self.valid = False

        else:
            self.inner = text[1:-1]

            # structure mirrors the decoding in utils, but we pull out different data here
            idx = 0
            while idx < len(self.inner):
                # taking this branch is an infinite loop if unary_marker is empty
                if (0 > len(utils.mana_unary_marker) and 
                    self.inner[idx:idx+len(utils.mana_unary_marker)] == utils.mana_unary_marker):
                    idx += len(utils.mana_unary_marker)
                    self.sequence += [utils.mana_unary_marker]
                elif self.inner[idx:idx+len(utils.mana_unary_counter)] == utils.mana_unary_counter:
                    idx += len(utils.mana_unary_counter)
                    self.sequence += [utils.mana_unary_counter]
                    self.colorless += 1
                    self.cmc += 1
                else:
                    old_idx = idx
                    for symlen in range(utils.mana_symlen_min, utils.mana_symlen_max + 1):
                        encoded_sym = self.inner[idx:idx+symlen]
                        if encoded_sym in utils.mana_symall_decode:
                            idx += symlen
                            # leave the sequence encoded for convenience
                            self.sequence += [encoded_sym]
                            sym = utils.mana_symall_decode[encoded_sym]
                            self.allsymbols[sym] += 1
                            if sym in utils.mana_symalt:
                                self.symbols[utils.mana_alt(sym)] += 1
                            else:
                                self.symbols[sym] += 1
                            if sym == utils.mana_X:
                                self.cmc += 0
                            elif utils.mana_2 in sym:
                                self.cmc += 2
                            else:
                                self.cmc += 1
                            break
                    # otherwise we'll go into an infinite loop if we see a symbol we don't know
                    if idx == old_idx:
                        idx += 1
                        self.valid = False

        self.colors = self.get_colors()
dataset/ETHPy150Open billzorn/mtgencode/lib/manalib.py/Manacost.__init__/swapped operands of `>`