from __future__ import print_function, unicode_literals

def main(graphs):
	from random import choice, sample

	from distributed.ttypes import Edge, Node

	ids = sample(xrange(1, 26), 10)

	raw_input("Create?")

	for node_id in ids:
		graphs.createNode( Node(node_id, 0, "", 0.0) )

	for _ in xrange(50):
		graphs.createEdge( Edge(choice(ids), choice(ids), 0.0, False, "") )

	raw_input("Update?")

	for node_id in sample(ids, 5):
		graphs.updateNode(node_id, 1, "*", 1.0)

	for _ in xrange(10):
		graphs.updateEdge(choice(ids), choice(ids), 1.0, True, "*")

	raw_input("Delete?")

	for node_id in sample(ids, 5):
		graphs.deleteNode(node_id)

	for _ in xrange(10):
		graphs.deleteEdge(choice(ids), choice(ids))

	raw_input("Read?")

	for node_id in sample(ids, 5):
		print( graphs.readNode(node_id) )

	for _ in xrange(10):
		edge = graphs.readEdge(choice(ids), choice(ids))

	raw_input("List?")

	for _ in xrange(50):
		if edge.node1:
			print(edge)

	for _ in xrange(10):
		nodes = graphs.listNodesEdge(choice(ids), choice(ids))

		if nodes:
			print(nodes)

	for node_id in sample(ids, 5):
		edges = graphs.listEdgesNode(node_id)

		if edges:
			print(edges)

	for node_id in sample(ids, 5):
		neighbors = graphs.listNeighborNodes(node_id)

		if neighbors:
			print(neighbors)

if __name__ == '__main__':
	from thrift.transport.TSocket		 import TSocket
	from thrift.transport.TTransport	 import TBufferedTransport
	from thrift.protocol.TBinaryProtocol import TBinaryProtocol

	from distributed.Graph import Client

	transport	= TSocket('localhost', 13579)
	transport	= TBufferedTransport(transport)
	protocol	= TBinaryProtocol(transport)
	client		= Client(protocol)

	transport.open()
	try: main(client)
	except (EOFError, KeyboardInterrupt): pass
	finally: transport.close()

@@ -186,31 +186,8 @@
 0)%0A%0A
-%09raw_input(%22Create?%22)%0A%0A
 %09for
@@ -203,16 +203,16 @@
 in ids:%0A
+
 %09%09graphs
@@ -350,31 +350,8 @@
  )%0A%0A
-%09raw_input(%22Update?%22)%0A%0A
 %09for
@@ -510,31 +510,8 @@
 %22)%0A%0A
-%09raw_input(%22Delete?%22)%0A%0A
 %09for
@@ -641,29 +641,8 @@
 ))%0A%0A
-%09raw_input(%22Read?%22)%0A%0A
 %09for
@@ -728,16 +728,16 @@
 ge(10):%0A
+
 %09%09edge =
@@ -784,29 +784,8 @@
 ))%0A%0A
-%09raw_input(%22List?%22)%0A%0A
 %09for
@@ -1576,13 +1576,8 @@
 ()%0A%09
-try: 
 main
@@ -1590,75 +1590,128 @@
 t)%0A%09
-except (EOFError, KeyboardInterrupt): pass%0A%09finally: transport.close(
+transport.close()%0A%0A%09# from server import GraphDatabaseHandler%0A%0A%09# with GraphDatabaseHandler() as handler:%0A%09# %09main(handler
 )%0A

Revert "Added user input before each set of operations."