# Path: robograph/sample_graphs/sum_and_product.py
# def sum_and_product(list_of_numbers):
#     v = value.Value(value=list_of_numbers)
#     s = apply.Apply(function=sum)
#     m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
#     b = buffers.Buffer()
#     p = printer.ConsolePrinter()
# 
#     g = graph.Graph('sum_and_product', [v, s, m, p, b])
# 
#     g.connect(p, b, 'message')
#     g.connect(b, s, 'sum value')
#     g.connect(b, m, 'product value')
#     g.connect(s, v, 'argument')
#     g.connect(m, v, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/replace_word.py
# 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])
# 
#     g.connect(p, s, 'message')
#     g.connect(s, t, 'data')
# 
#     return g
# 
# Path: robograph/sample_graphs/execution_stop.py
# def execution_stop(number):
# 
#     def stop_here(value):
#         if value >= 0:
#             raise exceptions.StopGraphExecutionSignal('arg is positive')
#         raise exceptions.StopGraphExecutionSignal('arg is negative')
# 
#     v = value.Value(value=number)
#     a = apply.Apply(function=stop_here)
# 
#     g = graph.Graph('execution_stop', [a, v])
# 
#     g.connect(a, v, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/delayed_sum_and_product.py
# def delayed_sum_and_product(list_of_numbers, delay):
# 
#     val = value.Value(value=list_of_numbers)
#     summer = apply.Apply(function=sum)
#     multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
#     delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
#     printout = printer.ConsolePrinter()
# 
#     g = graph.Graph('sum_and_product', [val, summer, multiplier,
#                                         printout, delayed_value_buffer,
#                                         delayed_value_buffer])
# 
#     g.connect(printout, delayed_value_buffer, 'message')
#     g.connect(delayed_value_buffer, summer, 'sum value')
#     g.connect(delayed_value_buffer, multiplier, 'product value')
#     g.connect(summer, val, 'argument')
#     g.connect(multiplier, val, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/drawing.py
# def plot():
# def plot_to_file(outputfile):


from robograph.sample_graphs import sum_and_product, sort_and_unique, replace_word, \
    scrape_image, http_fun, execution_stop, delayed_sum_and_product, drawing

g4 = scrape_image.scraper_image('https://httpbin.org/image/png',
                                'sample_graphs/testscraped.png')
g4.execute()




g5 = http_fun.test_post_graph('https://httpbin.org/post', dict(x=1, y=2))
g5.execute()

g6 = http_fun.test_get_graph('https://httpbin.org/get', dict(pippo=1, pluto="ciao"))
g6.execute()

g7 = http_fun.test_put_graph('https://httpbin.org/put', dict(pippo=1, pluto="ciao"))
g7.execute()


g8 = http_fun.test_delete_graph('https://httpbin.org/delete')
g8.execute()



g9 = execution_stop.execution_stop(-7)
g9.execute()

g10 = delayed_sum_and_product.delayed_sum_and_product([8, 0, 2], 7)
g10.execute()
'''


# Path: robograph/sample_graphs/sum_and_product.py
# def sum_and_product(list_of_numbers):
#     v = value.Value(value=list_of_numbers)
#     s = apply.Apply(function=sum)
#     m = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
#     b = buffers.Buffer()
#     p = printer.ConsolePrinter()
# 
#     g = graph.Graph('sum_and_product', [v, s, m, p, b])
# 
#     g.connect(p, b, 'message')
#     g.connect(b, s, 'sum value')
#     g.connect(b, m, 'product value')
#     g.connect(s, v, 'argument')
#     g.connect(m, v, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/replace_word.py
# 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])
# 
#     g.connect(p, s, 'message')
#     g.connect(s, t, 'data')
# 
#     return g
# 
# Path: robograph/sample_graphs/execution_stop.py
# def execution_stop(number):
# 
#     def stop_here(value):
#         if value >= 0:
#             raise exceptions.StopGraphExecutionSignal('arg is positive')
#         raise exceptions.StopGraphExecutionSignal('arg is negative')
# 
#     v = value.Value(value=number)
#     a = apply.Apply(function=stop_here)
# 
#     g = graph.Graph('execution_stop', [a, v])
# 
#     g.connect(a, v, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/delayed_sum_and_product.py
# def delayed_sum_and_product(list_of_numbers, delay):
# 
#     val = value.Value(value=list_of_numbers)
#     summer = apply.Apply(function=sum)
#     multiplier = apply.Apply(function=lambda c: reduce(lambda x, y: x * y, c))
#     delayed_value_buffer = buffers.DelayedBuffer(seconds=delay)
#     printout = printer.ConsolePrinter()
# 
#     g = graph.Graph('sum_and_product', [val, summer, multiplier,
#                                         printout, delayed_value_buffer,
#                                         delayed_value_buffer])
# 
#     g.connect(printout, delayed_value_buffer, 'message')
#     g.connect(delayed_value_buffer, summer, 'sum value')
#     g.connect(delayed_value_buffer, multiplier, 'product value')
#     g.connect(summer, val, 'argument')
#     g.connect(multiplier, val, 'argument')
# 
#     return g
# 
# Path: robograph/sample_graphs/drawing.py
# def plot():
# def plot_to_file(outputfile):


# Path: testrun.py
from robograph.sample_graphs import sum_and_product, sort_and_unique, replace_word, \
    scrape_image, http_fun, execution_stop, delayed_sum_and_product, drawing


g4 = scrape_image.scraper_image('https://httpbin.org/image/png',
                                'sample_graphs/testscraped.png')
g4.execute()




g5 = http_fun.test_post_graph('https://httpbin.org/post', dict(x=1, y=2))
g5.execute()

g6 = http_fun.test_get_graph('https://httpbin.org/get', dict(pippo=1, pluto="ciao"))
g6.execute()

g7 = http_fun.test_put_graph('https://httpbin.org/put', dict(pippo=1, pluto="ciao"))
g7.execute()


g8 = http_fun.test_delete_graph('https://httpbin.org/delete')
g8.execute()



g9 = execution_stop.execution_stop(-7)
g9.execute()

g10 = delayed_sum_and_product.delayed_sum_and_product([8, 0, 2], 7)
g10.execute()
'''


g11 = drawing.plot()