Package visgraph :: Module cli
[hide private]
[frames] | no frames]

Source Code for Module visgraph.cli

 1  ''' 
 2  A package for a basic command interpreter for the graph. 
 3  (and graph db...) 
 4  ''' 
 5   
 6  import sys 
 7  import cmd 
 8   
 9  import visgraph.dbcore as vg_dbcore 
10  import visgraph.pathcore as vg_pcore 
11  import visgraph.graphcore as vg_gcore 
12   
13 -class GraphCli(cmd.Cmd):
14
15 - def __init__(self, graph=None):
16 cmd.Cmd.__init__(self) 17 if graph == None: 18 graph = vg_gcore.Graph() 19 self.graph = graph
20
21 - def do_addnode(self, line):
22 ''' 23 Add a node with the given key=value properties on the CLI. 24 (the property nid is special and MUST be an integer) 25 ''' 26 nid = self.graph.addNode() 27 print 'Node %d added!' % nid
28
29 - def do_quit(self, line):
30 ''' 31 Exit the visgraph cli.... 32 ''' 33 raise SystemExit()
34 35 #class GraphDBCli( 36
37 -def main():
38 cli = GraphCli() 39 cli.cmdloop()
40 41 if __name__ == '__main__': 42 sys.exit(main()) 43