# Path: regraph/exceptions.py
# class AttributeSetError(ReGraphException):
#     """Exceptions class for errors in attribute sets."""


import copy
import re
import numpy as np
import math
import sys
from greenery.lego import parse
from regraph.exceptions import AttributeSetError


try:
    re._pattern_type = re.Pattern
except:
    pass


def _hashify(d):
    """Hashify a dictionary to a list of tuples."""
    result = []
    for key, value in d.items():
        if type(value) is dict:
            result.append((key, _hashify(value)))
        else:
            result.append((key, value))
    return tuple(result)


def _regex_to_string(a):
    if isinstance(a, str):
        return a
    elif isinstance(a, re._pattern_type):
        return a.pattern
    elif isinstance(a, RegexSet):
        if a.pattern is not None:
            return a.pattern
        else:
            return None
    else:

# Path: regraph/exceptions.py
# class AttributeSetError(ReGraphException):
#     """Exceptions class for errors in attribute sets."""


# Path: regraph/attribute_sets.py
import copy
import re
import numpy as np
import math
import sys
from greenery.lego import parse
from regraph.exceptions import AttributeSetError



try:
    re._pattern_type = re.Pattern
except:
    pass


def _hashify(d):
    """Hashify a dictionary to a list of tuples."""
    result = []
    for key, value in d.items():
        if type(value) is dict:
            result.append((key, _hashify(value)))
        else:
            result.append((key, value))
    return tuple(result)


def _regex_to_string(a):
    if isinstance(a, str):
        return a
    elif isinstance(a, re._pattern_type):
        return a.pattern
    elif isinstance(a, RegexSet):
        if a.pattern is not None:
            return a.pattern
        else:
            return None
    else:

        raise AttributeSetError("Cannot convert regex to string!")