mirror of
https://github.com/vivisect/vivisect
synced 2026-06-08 18:04:23 +00:00
80de840881
A lot of cleanup things in prep for a python 3 transition. Getting rid of the old exception syntax, converting prints over to logging, cutting random scraps of code to be proper unit tests, cut away some older bits of code, etc. This still works in python2. It's just a lot of tidying up. There are no major functionality changes.
41 lines
769 B
Python
41 lines
769 B
Python
'''
|
|
A package for a basic command interpreter for the graph.
|
|
(and graph db...)
|
|
'''
|
|
|
|
import sys
|
|
import cmd
|
|
|
|
import visgraph.graphcore as vg_gcore
|
|
|
|
|
|
class GraphCli(cmd.Cmd):
|
|
|
|
def __init__(self, graph=None):
|
|
cmd.Cmd.__init__(self)
|
|
if graph is None:
|
|
graph = vg_gcore.Graph()
|
|
self.graph = graph
|
|
|
|
def do_addnode(self, line):
|
|
'''
|
|
Add a node with the given key=value properties on the CLI.
|
|
(the property nid is special and MUST be an integer)
|
|
'''
|
|
return self.graph.addNode()
|
|
|
|
def do_quit(self, line):
|
|
'''
|
|
Exit the visgraph cli....
|
|
'''
|
|
raise SystemExit()
|
|
|
|
|
|
def main():
|
|
cli = GraphCli()
|
|
cli.cmdloop()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|