# Path: craft_ai/pandas/constants.py
# MISSING_VALUE = MissingValue()
# 
# OPTIONAL_VALUE = OptionalValue()
# 
# Path: craft_ai/constants.py
# REACT_CRAFT_AI_DECISION_TREE_VERSION = "0.0.23"
# 
# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)


import json
import re
import string
import importlib
import pandas as pd
from random import choice
from semver import VersionInfo
from .constants import (
    MISSING_VALUE,
    OPTIONAL_VALUE,
)
from ..constants import REACT_CRAFT_AI_DECISION_TREE_VERSION
from ..errors import CraftAiError



DUMMY_COLUMN_NAME = "CraftGeneratedDummy"
SELECTED_NODE_REGEX = "^0(-\\d*)*$"


def format_input(val):
    if val == MISSING_VALUE:
        return None
    if val == OPTIONAL_VALUE:
        return {}
    return val


def is_valid_property_value(key, value):
    # From https://stackoverflow.com/a/19773559
    return key != DUMMY_COLUMN_NAME and (
        (
            not hasattr(value, "__len__")
            or isinstance(value, str)

# Path: craft_ai/pandas/constants.py
# MISSING_VALUE = MissingValue()
# 
# OPTIONAL_VALUE = OptionalValue()
# 
# Path: craft_ai/constants.py
# REACT_CRAFT_AI_DECISION_TREE_VERSION = "0.0.23"
# 
# Path: craft_ai/errors.py
# class CraftAiError(Exception):
#     """Base class for exceptions in the craft ai client."""
# 
#     def __init__(self, message=None, metadata=None):
#         self.message = message
#         self.metadata = metadata
#         super(CraftAiError, self).__init__(message, metadata)
# 
#     def __str__(self):
#         return repr(self.message)


# Path: craft_ai/pandas/utils.py
import json
import re
import string
import importlib
import pandas as pd
from random import choice
from semver import VersionInfo
from .constants import (
    MISSING_VALUE,
    OPTIONAL_VALUE,
)
from ..constants import REACT_CRAFT_AI_DECISION_TREE_VERSION
from ..errors import CraftAiError




DUMMY_COLUMN_NAME = "CraftGeneratedDummy"
SELECTED_NODE_REGEX = "^0(-\\d*)*$"


def format_input(val):
    if val == MISSING_VALUE:
        return None
    if val == OPTIONAL_VALUE:
        return {}
    return val


def is_valid_property_value(key, value):
    # From https://stackoverflow.com/a/19773559
    return key != DUMMY_COLUMN_NAME and (
        (
            not hasattr(value, "__len__")
            or isinstance(value, str)

            or value == MISSING_VALUE