def doccli(argv): """doccli [-h?] [-D] [<filename>] Create and interactively edit an XHTML document. """ filename = None try: optlist, longopts, args = getopt.getopt(argv[1:], "?hD") except getopt.GetoptError: print doccli.__doc__ return for opt, optarg in optlist: if opt in ("-?", "-h"): print doccli.__doc__ return elif opt == "-D": from pycopia import autodebug if args: filename = args[0] io = CLI.ConsoleIO() ui = CLI.UserInterface(io) cmd = TopLevel(ui) cmd._environ["filename"] = filename if filename: doc = XHTML.get_document(filename) else: doc = XHTML.new_document() cmd._setup(doc, "doc> ") parser = CLI.CommandParser(cmd, historyfile=os.path.expandvars("$HOME/.hist_doccli")) parser.interact()
def test_Zfetch(self): doc = XHTML.get_document("http://www.pycopia.net/") self.assertEqual(doc.title.get_text(), "Python Application Frameworks") # write it out for inspection # Note that the document was parsed, and regenerated. fo = open("/tmp/pycopia_net.html", "w") try: doc.emit(fo) finally: fo.close() print "Fetched document found here: /tmp/pycopia_net.html"
def test_Zfetchmobile(self): doc = XHTML.get_document( "http://www.google.com/gwt/n?u=http://www.pynms.net", mimetype=WML, useragent=MOBILEAGENT2) print "Mobile doctype:", doc.DOCTYPE # write it out for inspection # Note that the document was parsed, and regenerated. fo = open("/tmp/test_WWW_mobile.html", "w") try: doc.emit(fo) finally: fo.close() print "Fetched document found here: /tmp/test_WWW_mobile.html"