# 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/files.py
# class File(node.Node):
# class TextFile(File):
# class TextFileReader(TextFile):
# class BinaryFileReader(File):
# class TextFileWriter(TextFile):
# class BinaryFileWriter(File):
#     def output(self):
#     def output(self):
#     def output(self):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
#     def output(self):


from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import files, apply
# Read from an input file a list of strings, remove duplicates, sort remaining
# items and then write them back to a different file



def sort_and_unique(input_file_path, output_file_path):
    file_reader = files.TextFileReader(filepath=input_file_path,
                                       encoding='UTF-8',
                                       name="file_reader")
    to_string_list = apply.Apply(function=lambda c: c.split('\n'),
                                 name="to_string_list")

    def remove_duplicates_from(collection):
        coll_type = type(collection)
        items = set(collection)
        return coll_type(items)

    uniquer = apply.Apply(function=remove_duplicates_from,
                          name='uniquer')
    sorter = apply.Apply(function=lambda unsorted: sorted(unsorted),
                         name="sorter")
    to_string = apply.Apply(function=lambda token_list: '\n'.join(token_list),
                            name='to_string')
    file_writer = files.TextFileWriter(filepath=output_file_path,
                                       encoding='UTF-8',
                                       name='file_writer')


# 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/files.py
# class File(node.Node):
# class TextFile(File):
# class TextFileReader(TextFile):
# class BinaryFileReader(File):
# class TextFileWriter(TextFile):
# class BinaryFileWriter(File):
#     def output(self):
#     def output(self):
#     def output(self):
#     def output(self):
# 
# Path: robograph/datamodel/nodes/lib/apply.py
# class Apply(node.Node):
#     def output(self):


# Path: sample_graphs/sort_and_unique.py
from robograph.datamodel.base import graph
from robograph.datamodel.nodes.lib import files, apply

# Read from an input file a list of strings, remove duplicates, sort remaining
# items and then write them back to a different file



def sort_and_unique(input_file_path, output_file_path):
    file_reader = files.TextFileReader(filepath=input_file_path,
                                       encoding='UTF-8',
                                       name="file_reader")
    to_string_list = apply.Apply(function=lambda c: c.split('\n'),
                                 name="to_string_list")

    def remove_duplicates_from(collection):
        coll_type = type(collection)
        items = set(collection)
        return coll_type(items)

    uniquer = apply.Apply(function=remove_duplicates_from,
                          name='uniquer')
    sorter = apply.Apply(function=lambda unsorted: sorted(unsorted),
                         name="sorter")
    to_string = apply.Apply(function=lambda token_list: '\n'.join(token_list),
                            name='to_string')
    file_writer = files.TextFileWriter(filepath=output_file_path,
                                       encoding='UTF-8',
                                       name='file_writer')


    g = graph.Graph('sort_and_unique', [file_reader, to_string_list, sorter,