# Path: cryptanalysis/diffchars.py
# class DifferentialCharacteristic(object):
#     def __init__(self, data, cipher, rounds, weight):
#     def getData(self):
#     def printText(self):
#     def getDOTString(self):
#     def printDOT(self):
#     def getTexString(self):


from cryptanalysis import diffchars
import re
    weight = "0"

    for row in output.split('\n'):
        if re.match(r'.*weight', row):
            weight = row.split(" ")[1]
        elif re.match(r'\d*\s.*\s.*', row):
            var_name = row.split(" ")[2]
            var_value = "0x" + row.split(" ")[1]
            characteristic[var_name] = var_value

    return diffchars.DifferentialCharacteristic(characteristic,
                                                cipher, rounds, weight)


def getCharSTPOutput(output, cipher, rounds):
    """
    Parse the output of STP and construct a characteristic.
    """
    characteristic = {}
    weight = "0"

    for row in output.split('\n'):
        if re.match(r'ASSERT.*weight', row):
            weight = re.search(r'(?<=ASSERT\( weight = ).*(?= \);)', row).group(0)
        elif re.match(r'ASSERT\(.*\)', row):
            tmp = re.search(r'ASSERT\( ([a-z0-9A-Z]+) = ([a-z0-9A-Z]+)', row)
            var_name = tmp.group(1)
            var_value = tmp.group(2)
            characteristic[var_name] = var_value


# Path: cryptanalysis/diffchars.py
# class DifferentialCharacteristic(object):
#     def __init__(self, data, cipher, rounds, weight):
#     def getData(self):
#     def printText(self):
#     def getDOTString(self):
#     def printDOT(self):
#     def getTexString(self):


# Path: parser/parsesolveroutput.py
from cryptanalysis import diffchars
import re

    weight = "0"

    for row in output.split('\n'):
        if re.match(r'.*weight', row):
            weight = row.split(" ")[1]
        elif re.match(r'\d*\s.*\s.*', row):
            var_name = row.split(" ")[2]
            var_value = "0x" + row.split(" ")[1]
            characteristic[var_name] = var_value

    return diffchars.DifferentialCharacteristic(characteristic,
                                                cipher, rounds, weight)


def getCharSTPOutput(output, cipher, rounds):
    """
    Parse the output of STP and construct a characteristic.
    """
    characteristic = {}
    weight = "0"

    for row in output.split('\n'):
        if re.match(r'ASSERT.*weight', row):
            weight = re.search(r'(?<=ASSERT\( weight = ).*(?= \);)', row).group(0)
        elif re.match(r'ASSERT\(.*\)', row):
            tmp = re.search(r'ASSERT\( ([a-z0-9A-Z]+) = ([a-z0-9A-Z]+)', row)
            var_name = tmp.group(1)
            var_value = tmp.group(2)
            characteristic[var_name] = var_value


    return diffchars.DifferentialCharacteristic(characteristic,