Source

#! /usr/bin/env python"""Command-line interface for a dot file viewer. dotviewer.py filename.dot dotviewer.py filename.plainIn the first form, show the graph contained in a .dot file.In the second form, the graph was already compiled to a .plain file."""importsysdefmain(args=sys.argv[1:]):importgetoptoptions,args=getopt.getopt(args,'s:h',['server=','help'])server_addr=Noneforoption,valueinoptions:ifoptionin('-h','--help'):print>>sys.stderr,__doc__sys.exit(2)ifoptionin('-s','--server'):# deprecatedserver_addr=valueifnotargsandserver_addrisNone:print>>sys.stderr,__doc__sys.exit(2)forfilenameinargs:importgraphclientgraphclient.display_dot_file(filename)ifserver_addrisnotNone:importgraphservergraphserver.listen_server(server_addr)if__name__=='__main__':main()