# Path: robograph/datamodel/base/graph.py
# class Graph:
#     def __init__(self, name, nodes=None):
#     def root_node(self):
#     def nodes(self):
#     def edges(self):
#     def nxgraph(self):
#     def name(self):
#     def add_node(self, node):
#     def add_nodes(self, sequence_of_nodes):
#     def remove_node(self, node):
#     def remove_nodes(self, sequence_of_nodes):
#     def connect(self, node_from, node_to, output_label):
#     def has_isles(self):
#     def execute(self, result_label="result"):
#     def reset(self):
#     def __repr__(self):
#     def __len__(self):
# 
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
#     def output(self):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
#     def output(self):
#     def output(self):


from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, branching
# Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead



def replace_word(text):
    t = value.Value(value=text, name="text")
    s = branching.IfThenApply(condition=lambda x: "hello" in x,
                              function_true=lambda x: x.replace("hello", "ciao"),
                              function_false=lambda x: x.replace(" ", "_"),
                              name="if")
    p = printer.ConsolePrinter()

# Path: robograph/datamodel/base/graph.py
# class Graph:
#     def __init__(self, name, nodes=None):
#     def root_node(self):
#     def nodes(self):
#     def edges(self):
#     def nxgraph(self):
#     def name(self):
#     def add_node(self, node):
#     def add_nodes(self, sequence_of_nodes):
#     def remove_node(self, node):
#     def remove_nodes(self, sequence_of_nodes):
#     def connect(self, node_from, node_to, output_label):
#     def has_isles(self):
#     def execute(self, result_label="result"):
#     def reset(self):
#     def __repr__(self):
#     def __len__(self):
# 
# Path: robograph/datamodel/nodes/lib/printer.py
# class ConsolePrinter(node.Node):
# class LogPrinter(node.Node):
#     def output(self):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/value.py
# class Value(node.Node):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/branching.py
# class IfThenApply(node.Node):
# class IfThenReturn(node.Node):
#     def output(self):
#     def output(self):


# Path: robograph/sample_graphs/replace_word.py
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import printer, value, branching

# Given a text, replace occurrences of the word "hello" with "ciao" - if any.
# If no occurrence is found, replace all whitespaces with "_" instead



def replace_word(text):
    t = value.Value(value=text, name="text")
    s = branching.IfThenApply(condition=lambda x: "hello" in x,
                              function_true=lambda x: x.replace("hello", "ciao"),
                              function_false=lambda x: x.replace(" ", "_"),
                              name="if")
    p = printer.ConsolePrinter()

    g = graph.Graph('replace_word', [t, s, p])