From 8ec8f0c0c6c68d9b13c3bc3416c3234eddd48379 Mon Sep 17 00:00:00 2001 From: jhugunin Date: Fri, 3 Jan 2003 23:19:47 +0000 Subject: [PATCH] making jython-2.1 available for scripting --- lib/jython/LICENSE.txt | 144 ++ lib/jython/Lib/BaseHTTPServer.py | 482 ++++++ lib/jython/Lib/CGIHTTPServer.py | 305 ++++ lib/jython/Lib/ConfigParser.py | 480 ++++++ lib/jython/Lib/Cookie.py | 734 +++++++++ lib/jython/Lib/LICENSE | 232 +++ lib/jython/Lib/MimeWriter.py | 128 ++ lib/jython/Lib/Queue.py | 132 ++ lib/jython/Lib/SimpleHTTPServer.py | 198 +++ lib/jython/Lib/SocketServer.py | 566 +++++++ lib/jython/Lib/StringIO.py | 208 +++ lib/jython/Lib/UserDict.py | 42 + lib/jython/Lib/UserList.py | 85 + lib/jython/Lib/UserString.py | 173 +++ lib/jython/Lib/__future__.py | 69 + lib/jython/Lib/anydbm.py | 86 + lib/jython/Lib/atexit.py | 54 + lib/jython/Lib/base64.py | 81 + lib/jython/Lib/bdb.py | 565 +++++++ lib/jython/Lib/binhex.py | 531 +++++++ lib/jython/Lib/bisect.py | 78 + lib/jython/Lib/calendar.py | 209 +++ lib/jython/Lib/cgi.py | 1000 ++++++++++++ lib/jython/Lib/cmd.py | 198 +++ lib/jython/Lib/code.py | 308 ++++ lib/jython/Lib/codecs.py | 570 +++++++ lib/jython/Lib/colorsys.py | 123 ++ lib/jython/Lib/commands.py | 84 + lib/jython/Lib/compileall.py | 130 ++ lib/jython/Lib/copy.py | 330 ++++ lib/jython/Lib/copy_reg.py | 35 + lib/jython/Lib/dbexts.py | 690 ++++++++ lib/jython/Lib/difflib.py | 781 ++++++++++ lib/jython/Lib/dircache.py | 44 + lib/jython/Lib/doctest.py | 1118 +++++++++++++ lib/jython/Lib/dospath.py | 332 ++++ lib/jython/Lib/dumbdbm.py | 148 ++ lib/jython/Lib/encodings/__init__.py | 86 + lib/jython/Lib/encodings/aliases.py | 82 + lib/jython/Lib/encodings/ascii.py | 35 + lib/jython/Lib/encodings/charmap.py | 51 + lib/jython/Lib/encodings/cp037.py | 282 ++++ lib/jython/Lib/encodings/cp1006.py | 140 ++ lib/jython/Lib/encodings/cp1026.py | 282 ++++ lib/jython/Lib/encodings/cp1250.py | 125 ++ lib/jython/Lib/encodings/cp1251.py | 159 ++ lib/jython/Lib/encodings/cp1252.py | 78 + lib/jython/Lib/encodings/cp1253.py | 153 ++ lib/jython/Lib/encodings/cp1254.py | 84 + lib/jython/Lib/encodings/cp1255.py | 145 ++ lib/jython/Lib/encodings/cp1256.py | 131 ++ lib/jython/Lib/encodings/cp1257.py | 133 ++ lib/jython/Lib/encodings/cp1258.py | 92 ++ lib/jython/Lib/encodings/cp424.py | 282 ++++ lib/jython/Lib/encodings/cp437.py | 174 +++ lib/jython/Lib/encodings/cp500.py | 282 ++++ lib/jython/Lib/encodings/cp737.py | 174 +++ lib/jython/Lib/encodings/cp775.py | 174 +++ lib/jython/Lib/encodings/cp850.py | 174 +++ lib/jython/Lib/encodings/cp852.py | 174 +++ lib/jython/Lib/encodings/cp855.py | 174 +++ lib/jython/Lib/encodings/cp856.py | 174 +++ lib/jython/Lib/encodings/cp857.py | 173 +++ lib/jython/Lib/encodings/cp860.py | 174 +++ lib/jython/Lib/encodings/cp861.py | 174 +++ lib/jython/Lib/encodings/cp862.py | 174 +++ lib/jython/Lib/encodings/cp863.py | 174 +++ lib/jython/Lib/encodings/cp864.py | 172 ++ lib/jython/Lib/encodings/cp865.py | 174 +++ lib/jython/Lib/encodings/cp866.py | 174 +++ lib/jython/Lib/encodings/cp869.py | 174 +++ lib/jython/Lib/encodings/cp874.py | 173 +++ lib/jython/Lib/encodings/cp875.py | 283 ++++ lib/jython/Lib/encodings/iso8859_1.py | 46 + lib/jython/Lib/encodings/iso8859_10.py | 92 ++ lib/jython/Lib/encodings/iso8859_13.py | 102 ++ lib/jython/Lib/encodings/iso8859_14.py | 77 + lib/jython/Lib/encodings/iso8859_15.py | 54 + lib/jython/Lib/encodings/iso8859_2.py | 103 ++ lib/jython/Lib/encodings/iso8859_3.py | 81 + lib/jython/Lib/encodings/iso8859_4.py | 96 ++ lib/jython/Lib/encodings/iso8859_5.py | 140 ++ lib/jython/Lib/encodings/iso8859_6.py | 139 ++ lib/jython/Lib/encodings/iso8859_7.py | 126 ++ lib/jython/Lib/encodings/iso8859_8.py | 114 ++ lib/jython/Lib/encodings/iso8859_9.py | 52 + lib/jython/Lib/encodings/koi8_r.py | 174 +++ lib/jython/Lib/encodings/latin_1.py | 35 + lib/jython/Lib/encodings/mac_cyrillic.py | 169 ++ lib/jython/Lib/encodings/mac_greek.py | 172 ++ lib/jython/Lib/encodings/mac_iceland.py | 168 ++ lib/jython/Lib/encodings/mac_latin2.py | 172 ++ lib/jython/Lib/encodings/mac_roman.py | 169 ++ lib/jython/Lib/encodings/mac_turkish.py | 169 ++ lib/jython/Lib/encodings/mbcs.py | 36 + .../Lib/encodings/raw_unicode_escape.py | 30 + lib/jython/Lib/encodings/undefined.py | 34 + lib/jython/Lib/encodings/unicode_escape.py | 30 + lib/jython/Lib/encodings/unicode_internal.py | 30 + lib/jython/Lib/encodings/utf_16.py | 31 + lib/jython/Lib/encodings/utf_16_be.py | 31 + lib/jython/Lib/encodings/utf_16_le.py | 31 + lib/jython/Lib/encodings/utf_8.py | 31 + lib/jython/Lib/fileinput.py | 300 ++++ lib/jython/Lib/fnmatch.py | 87 ++ lib/jython/Lib/formatter.py | 422 +++++ lib/jython/Lib/fpformat.py | 142 ++ lib/jython/Lib/ftplib.py | 727 +++++++++ lib/jython/Lib/getopt.py | 143 ++ lib/jython/Lib/glob.py | 57 + lib/jython/Lib/gopherlib.py | 206 +++ lib/jython/Lib/gzip.py | 359 +++++ lib/jython/Lib/htmlentitydefs.py | 257 +++ lib/jython/Lib/htmllib.py | 426 +++++ lib/jython/Lib/httplib.py | 842 ++++++++++ lib/jython/Lib/imaplib.py | 1125 ++++++++++++++ lib/jython/Lib/imghdr.py | 154 ++ lib/jython/Lib/isql.py | 145 ++ lib/jython/Lib/javaos.py | 467 ++++++ lib/jython/Lib/javapath.py | 331 ++++ lib/jython/Lib/jreload.py | 119 ++ lib/jython/Lib/jxxload_help/DiscardHelp.java | 59 + .../Lib/jxxload_help/JavaLoaderFactory.java | 9 + lib/jython/Lib/jxxload_help/Makefile | 3 + .../Lib/jxxload_help/PackageManager.java | 58 + lib/jython/Lib/jxxload_help/PathVFS.java | 98 ++ .../Lib/jxxload_help/PathVFSJavaLoader.java | 54 + lib/jython/Lib/keyword.py | 96 ++ lib/jython/Lib/linecache.py | 94 ++ lib/jython/Lib/macpath.py | 227 +++ lib/jython/Lib/macurl2path.py | 95 ++ lib/jython/Lib/mailbox.py | 304 ++++ lib/jython/Lib/mailcap.py | 255 +++ lib/jython/Lib/marshal.py | 315 ++++ lib/jython/Lib/mhlib.py | 1003 ++++++++++++ lib/jython/Lib/mimetools.py | 226 +++ lib/jython/Lib/mimetypes.py | 242 +++ lib/jython/Lib/mimify.py | 464 ++++++ lib/jython/Lib/multifile.py | 162 ++ lib/jython/Lib/mutex.py | 51 + lib/jython/Lib/nntplib.py | 557 +++++++ lib/jython/Lib/ntpath.py | 424 +++++ lib/jython/Lib/nturl2path.py | 66 + lib/jython/Lib/pawt/__init__.py | 35 + lib/jython/Lib/pawt/colors.py | 144 ++ lib/jython/Lib/pawt/swing.py | 42 + lib/jython/Lib/pdb.py | 948 +++++++++++ lib/jython/Lib/pickle.py | 986 ++++++++++++ lib/jython/Lib/pipes.py | 298 ++++ lib/jython/Lib/popen2.py | 198 +++ lib/jython/Lib/poplib.py | 322 ++++ lib/jython/Lib/posixfile.py | 229 +++ lib/jython/Lib/posixpath.py | 381 +++++ lib/jython/Lib/pprint.py | 251 +++ lib/jython/Lib/profile.py | 580 +++++++ lib/jython/Lib/pstats.py | 655 ++++++++ lib/jython/Lib/pyclbr.py | 338 ++++ lib/jython/Lib/quopri.py | 152 ++ lib/jython/Lib/random.py | 663 ++++++++ lib/jython/Lib/re.py | 11 + lib/jython/Lib/reconvert.py | 188 +++ lib/jython/Lib/repr.py | 95 ++ lib/jython/Lib/rfc822.py | 965 ++++++++++++ lib/jython/Lib/sched.py | 106 ++ lib/jython/Lib/sgmllib.py | 533 +++++++ lib/jython/Lib/shelve.py | 158 ++ lib/jython/Lib/shutil.py | 138 ++ lib/jython/Lib/site.py | 285 ++++ lib/jython/Lib/smtplib.py | 543 +++++++ lib/jython/Lib/sndhdr.py | 228 +++ lib/jython/Lib/socket.py | 361 +++++ lib/jython/Lib/sre.py | 261 ++++ lib/jython/Lib/sre_compile.py | 386 +++++ lib/jython/Lib/sre_constants.py | 256 +++ lib/jython/Lib/sre_parse.py | 732 +++++++++ lib/jython/Lib/stat.py | 86 + lib/jython/Lib/string.py | 421 +++++ lib/jython/Lib/symbol.py | 93 ++ lib/jython/Lib/telnetlib.py | 504 ++++++ lib/jython/Lib/tempfile.py | 205 +++ lib/jython/Lib/test/pystone.py | 252 +++ lib/jython/Lib/threading.py | 633 ++++++++ lib/jython/Lib/token.py | 139 ++ lib/jython/Lib/tokenize.py | 240 +++ lib/jython/Lib/traceback.py | 301 ++++ lib/jython/Lib/tzparse.py | 98 ++ lib/jython/Lib/unittest.py | 711 +++++++++ lib/jython/Lib/urllib.py | 1383 +++++++++++++++++ lib/jython/Lib/urlparse.py | 261 ++++ lib/jython/Lib/user.py | 43 + lib/jython/Lib/warnings.py | 251 +++ lib/jython/Lib/weakref.py | 183 +++ lib/jython/Lib/whichdb.py | 88 ++ lib/jython/Lib/whrandom.py | 140 ++ lib/jython/Lib/xdrlib.py | 281 ++++ lib/jython/Lib/xml/__init__.py | 42 + lib/jython/Lib/xml/dom/Attr.py | 134 ++ lib/jython/Lib/xml/dom/CDATASection.py | 23 + lib/jython/Lib/xml/dom/CharacterData.py | 136 ++ lib/jython/Lib/xml/dom/Comment.py | 22 + lib/jython/Lib/xml/dom/DOMImplementation.py | 69 + lib/jython/Lib/xml/dom/Document.py | 329 ++++ lib/jython/Lib/xml/dom/DocumentFragment.py | 45 + lib/jython/Lib/xml/dom/DocumentType.py | 109 ++ lib/jython/Lib/xml/dom/Element.py | 267 ++++ lib/jython/Lib/xml/dom/Entity.py | 84 + lib/jython/Lib/xml/dom/EntityReference.py | 47 + lib/jython/Lib/xml/dom/Event.py | 130 ++ lib/jython/Lib/xml/dom/FtNode.py | 447 ++++++ lib/jython/Lib/xml/dom/MessageSource.py | 55 + lib/jython/Lib/xml/dom/NamedNodeMap.py | 149 ++ lib/jython/Lib/xml/dom/NodeFilter.py | 38 + lib/jython/Lib/xml/dom/NodeIterator.py | 129 ++ lib/jython/Lib/xml/dom/NodeList.py | 60 + lib/jython/Lib/xml/dom/Notation.py | 71 + .../Lib/xml/dom/ProcessingInstruction.py | 71 + lib/jython/Lib/xml/dom/Range.py | 1099 +++++++++++++ lib/jython/Lib/xml/dom/Text.py | 43 + lib/jython/Lib/xml/dom/TreeWalker.py | 183 +++ lib/jython/Lib/xml/dom/__init__.py | 197 +++ lib/jython/Lib/xml/dom/domreg.py | 76 + lib/jython/Lib/xml/dom/ext/Printer.py | 384 +++++ lib/jython/Lib/xml/dom/ext/Visitor.py | 73 + .../Lib/xml/dom/ext/XHtml2HtmlPrinter.py | 48 + lib/jython/Lib/xml/dom/ext/XHtmlPrinter.py | 55 + lib/jython/Lib/xml/dom/ext/__init__.py | 289 ++++ lib/jython/Lib/xml/dom/ext/c14n.py | 251 +++ lib/jython/Lib/xml/dom/ext/reader/Sax.py | 171 ++ lib/jython/Lib/xml/dom/ext/reader/Sax2.py | 347 +++++ lib/jython/Lib/xml/dom/ext/reader/Sax2Lib.py | 282 ++++ lib/jython/Lib/xml/dom/ext/reader/__init__.py | 76 + lib/jython/Lib/xml/dom/html/GenerateHtml.py | 270 ++++ .../Lib/xml/dom/html/HTMLAnchorElement.py | 147 ++ .../Lib/xml/dom/html/HTMLAppletElement.py | 128 ++ .../Lib/xml/dom/html/HTMLAreaElement.py | 110 ++ lib/jython/Lib/xml/dom/html/HTMLBRElement.py | 48 + .../Lib/xml/dom/html/HTMLBaseElement.py | 56 + .../Lib/xml/dom/html/HTMLBaseFontElement.py | 64 + .../Lib/xml/dom/html/HTMLBodyElement.py | 88 ++ .../Lib/xml/dom/html/HTMLButtonElement.py | 99 ++ lib/jython/Lib/xml/dom/html/HTMLCollection.py | 78 + .../Lib/xml/dom/html/HTMLDListElement.py | 51 + .../Lib/xml/dom/html/HTMLDOMImplementation.py | 37 + .../Lib/xml/dom/html/HTMLDirectoryElement.py | 51 + lib/jython/Lib/xml/dom/html/HTMLDivElement.py | 56 + lib/jython/Lib/xml/dom/html/HTMLDocument.py | 355 +++++ lib/jython/Lib/xml/dom/html/HTMLElement.py | 121 ++ .../Lib/xml/dom/html/HTMLFieldSetElement.py | 46 + .../Lib/xml/dom/html/HTMLFontElement.py | 64 + .../Lib/xml/dom/html/HTMLFormElement.py | 120 ++ .../Lib/xml/dom/html/HTMLFrameElement.py | 117 ++ .../Lib/xml/dom/html/HTMLFrameSetElement.py | 56 + lib/jython/Lib/xml/dom/html/HTMLHRElement.py | 75 + .../Lib/xml/dom/html/HTMLHeadElement.py | 48 + .../Lib/xml/dom/html/HTMLHeadingElement.py | 48 + .../Lib/xml/dom/html/HTMLHtmlElement.py | 48 + .../Lib/xml/dom/html/HTMLIFrameElement.py | 130 ++ .../Lib/xml/dom/html/HTMLImageElement.py | 147 ++ .../Lib/xml/dom/html/HTMLInputElement.py | 225 +++ .../Lib/xml/dom/html/HTMLIsIndexElement.py | 57 + lib/jython/Lib/xml/dom/html/HTMLLIElement.py | 59 + .../Lib/xml/dom/html/HTMLLabelElement.py | 65 + .../Lib/xml/dom/html/HTMLLegendElement.py | 65 + .../Lib/xml/dom/html/HTMLLinkElement.py | 115 ++ lib/jython/Lib/xml/dom/html/HTMLMapElement.py | 48 + .../Lib/xml/dom/html/HTMLMenuElement.py | 51 + .../Lib/xml/dom/html/HTMLMetaElement.py | 72 + lib/jython/Lib/xml/dom/html/HTMLModElement.py | 56 + .../Lib/xml/dom/html/HTMLOListElement.py | 70 + .../Lib/xml/dom/html/HTMLObjectElement.py | 195 +++ .../Lib/xml/dom/html/HTMLOptGroupElement.py | 59 + .../Lib/xml/dom/html/HTMLOptionElement.py | 124 ++ .../Lib/xml/dom/html/HTMLParagraphElement.py | 48 + .../Lib/xml/dom/html/HTMLParamElement.py | 72 + lib/jython/Lib/xml/dom/html/HTMLPreElement.py | 51 + .../Lib/xml/dom/html/HTMLQuoteElement.py | 48 + .../Lib/xml/dom/html/HTMLScriptElement.py | 115 ++ .../Lib/xml/dom/html/HTMLSelectElement.py | 161 ++ .../Lib/xml/dom/html/HTMLStyleElement.py | 67 + .../xml/dom/html/HTMLTableCaptionElement.py | 48 + .../Lib/xml/dom/html/HTMLTableCellElement.py | 164 ++ .../Lib/xml/dom/html/HTMLTableColElement.py | 91 ++ .../Lib/xml/dom/html/HTMLTableElement.py | 281 ++++ .../Lib/xml/dom/html/HTMLTableRowElement.py | 126 ++ .../xml/dom/html/HTMLTableSectionElement.py | 98 ++ .../Lib/xml/dom/html/HTMLTextAreaElement.py | 183 +++ .../Lib/xml/dom/html/HTMLTitleElement.py | 64 + .../Lib/xml/dom/html/HTMLUListElement.py | 59 + lib/jython/Lib/xml/dom/html/__init__.py | 472 ++++++ lib/jython/Lib/xml/dom/javadom.py | 696 +++++++++ lib/jython/Lib/xml/dom/minidom.py | 916 +++++++++++ lib/jython/Lib/xml/dom/minitraversal.py | 34 + lib/jython/Lib/xml/dom/pulldom.py | 319 ++++ lib/jython/Lib/xml/ns.py | 179 +++ lib/jython/Lib/xml/parsers/__init__.py | 1 + .../Lib/xml/parsers/xmlproc/__init__.py | 1 + .../Lib/xml/parsers/xmlproc/_outputters.py | 59 + lib/jython/Lib/xml/parsers/xmlproc/catalog.py | 312 ++++ .../Lib/xml/parsers/xmlproc/charconv.py | 203 +++ .../Lib/xml/parsers/xmlproc/dtdparser.py | 733 +++++++++ lib/jython/Lib/xml/parsers/xmlproc/errors.py | 276 ++++ .../Lib/xml/parsers/xmlproc/namespace.py | 169 ++ lib/jython/Lib/xml/parsers/xmlproc/utils.py | 197 +++ .../Lib/xml/parsers/xmlproc/xcatalog.py | 66 + lib/jython/Lib/xml/parsers/xmlproc/xmlapp.py | 227 +++ lib/jython/Lib/xml/parsers/xmlproc/xmldtd.py | 870 +++++++++++ lib/jython/Lib/xml/parsers/xmlproc/xmlproc.py | 592 +++++++ .../Lib/xml/parsers/xmlproc/xmlutils.py | 763 +++++++++ lib/jython/Lib/xml/parsers/xmlproc/xmlval.py | 310 ++++ lib/jython/Lib/xml/sax/__init__.py | 47 + lib/jython/Lib/xml/sax/_exceptions.py | 126 ++ lib/jython/Lib/xml/sax/drivers2/__init__.py | 1 + .../Lib/xml/sax/drivers2/drv_xmlproc.py | 392 +++++ lib/jython/Lib/xml/sax/expatreader.py | 240 +++ lib/jython/Lib/xml/sax/handler.py | 321 ++++ lib/jython/Lib/xml/sax/sax2exts.py | 34 + lib/jython/Lib/xml/sax/saxexts.py | 168 ++ lib/jython/Lib/xml/sax/saxlib.py | 430 +++++ lib/jython/Lib/xml/sax/saxutils.py | 661 ++++++++ lib/jython/Lib/xml/sax/writer.py | 534 +++++++ lib/jython/Lib/xml/sax/xmlreader.py | 376 +++++ lib/jython/Lib/xml/utils/__init__.py | 1 + lib/jython/Lib/xml/utils/iso8601.py | 188 +++ lib/jython/Lib/xml/utils/qp_xml.py | 242 +++ lib/jython/Lib/xmllib.py | 929 +++++++++++ lib/jython/Lib/zipfile.py | 574 +++++++ lib/jython/Lib/zlib.py | 112 ++ lib/jython/README.txt | 17 + lib/jython/jython.jar | Bin 0 -> 719950 bytes 329 files changed, 73432 insertions(+) create mode 100644 lib/jython/LICENSE.txt create mode 100644 lib/jython/Lib/BaseHTTPServer.py create mode 100644 lib/jython/Lib/CGIHTTPServer.py create mode 100644 lib/jython/Lib/ConfigParser.py create mode 100644 lib/jython/Lib/Cookie.py create mode 100644 lib/jython/Lib/LICENSE create mode 100644 lib/jython/Lib/MimeWriter.py create mode 100644 lib/jython/Lib/Queue.py create mode 100644 lib/jython/Lib/SimpleHTTPServer.py create mode 100644 lib/jython/Lib/SocketServer.py create mode 100644 lib/jython/Lib/StringIO.py create mode 100644 lib/jython/Lib/UserDict.py create mode 100644 lib/jython/Lib/UserList.py create mode 100644 lib/jython/Lib/UserString.py create mode 100644 lib/jython/Lib/__future__.py create mode 100644 lib/jython/Lib/anydbm.py create mode 100644 lib/jython/Lib/atexit.py create mode 100644 lib/jython/Lib/base64.py create mode 100644 lib/jython/Lib/bdb.py create mode 100644 lib/jython/Lib/binhex.py create mode 100644 lib/jython/Lib/bisect.py create mode 100644 lib/jython/Lib/calendar.py create mode 100644 lib/jython/Lib/cgi.py create mode 100644 lib/jython/Lib/cmd.py create mode 100644 lib/jython/Lib/code.py create mode 100644 lib/jython/Lib/codecs.py create mode 100644 lib/jython/Lib/colorsys.py create mode 100644 lib/jython/Lib/commands.py create mode 100644 lib/jython/Lib/compileall.py create mode 100644 lib/jython/Lib/copy.py create mode 100644 lib/jython/Lib/copy_reg.py create mode 100644 lib/jython/Lib/dbexts.py create mode 100644 lib/jython/Lib/difflib.py create mode 100644 lib/jython/Lib/dircache.py create mode 100644 lib/jython/Lib/doctest.py create mode 100644 lib/jython/Lib/dospath.py create mode 100644 lib/jython/Lib/dumbdbm.py create mode 100644 lib/jython/Lib/encodings/__init__.py create mode 100644 lib/jython/Lib/encodings/aliases.py create mode 100644 lib/jython/Lib/encodings/ascii.py create mode 100644 lib/jython/Lib/encodings/charmap.py create mode 100644 lib/jython/Lib/encodings/cp037.py create mode 100644 lib/jython/Lib/encodings/cp1006.py create mode 100644 lib/jython/Lib/encodings/cp1026.py create mode 100644 lib/jython/Lib/encodings/cp1250.py create mode 100644 lib/jython/Lib/encodings/cp1251.py create mode 100644 lib/jython/Lib/encodings/cp1252.py create mode 100644 lib/jython/Lib/encodings/cp1253.py create mode 100644 lib/jython/Lib/encodings/cp1254.py create mode 100644 lib/jython/Lib/encodings/cp1255.py create mode 100644 lib/jython/Lib/encodings/cp1256.py create mode 100644 lib/jython/Lib/encodings/cp1257.py create mode 100644 lib/jython/Lib/encodings/cp1258.py create mode 100644 lib/jython/Lib/encodings/cp424.py create mode 100644 lib/jython/Lib/encodings/cp437.py create mode 100644 lib/jython/Lib/encodings/cp500.py create mode 100644 lib/jython/Lib/encodings/cp737.py create mode 100644 lib/jython/Lib/encodings/cp775.py create mode 100644 lib/jython/Lib/encodings/cp850.py create mode 100644 lib/jython/Lib/encodings/cp852.py create mode 100644 lib/jython/Lib/encodings/cp855.py create mode 100644 lib/jython/Lib/encodings/cp856.py create mode 100644 lib/jython/Lib/encodings/cp857.py create mode 100644 lib/jython/Lib/encodings/cp860.py create mode 100644 lib/jython/Lib/encodings/cp861.py create mode 100644 lib/jython/Lib/encodings/cp862.py create mode 100644 lib/jython/Lib/encodings/cp863.py create mode 100644 lib/jython/Lib/encodings/cp864.py create mode 100644 lib/jython/Lib/encodings/cp865.py create mode 100644 lib/jython/Lib/encodings/cp866.py create mode 100644 lib/jython/Lib/encodings/cp869.py create mode 100644 lib/jython/Lib/encodings/cp874.py create mode 100644 lib/jython/Lib/encodings/cp875.py create mode 100644 lib/jython/Lib/encodings/iso8859_1.py create mode 100644 lib/jython/Lib/encodings/iso8859_10.py create mode 100644 lib/jython/Lib/encodings/iso8859_13.py create mode 100644 lib/jython/Lib/encodings/iso8859_14.py create mode 100644 lib/jython/Lib/encodings/iso8859_15.py create mode 100644 lib/jython/Lib/encodings/iso8859_2.py create mode 100644 lib/jython/Lib/encodings/iso8859_3.py create mode 100644 lib/jython/Lib/encodings/iso8859_4.py create mode 100644 lib/jython/Lib/encodings/iso8859_5.py create mode 100644 lib/jython/Lib/encodings/iso8859_6.py create mode 100644 lib/jython/Lib/encodings/iso8859_7.py create mode 100644 lib/jython/Lib/encodings/iso8859_8.py create mode 100644 lib/jython/Lib/encodings/iso8859_9.py create mode 100644 lib/jython/Lib/encodings/koi8_r.py create mode 100644 lib/jython/Lib/encodings/latin_1.py create mode 100644 lib/jython/Lib/encodings/mac_cyrillic.py create mode 100644 lib/jython/Lib/encodings/mac_greek.py create mode 100644 lib/jython/Lib/encodings/mac_iceland.py create mode 100644 lib/jython/Lib/encodings/mac_latin2.py create mode 100644 lib/jython/Lib/encodings/mac_roman.py create mode 100644 lib/jython/Lib/encodings/mac_turkish.py create mode 100644 lib/jython/Lib/encodings/mbcs.py create mode 100644 lib/jython/Lib/encodings/raw_unicode_escape.py create mode 100644 lib/jython/Lib/encodings/undefined.py create mode 100644 lib/jython/Lib/encodings/unicode_escape.py create mode 100644 lib/jython/Lib/encodings/unicode_internal.py create mode 100644 lib/jython/Lib/encodings/utf_16.py create mode 100644 lib/jython/Lib/encodings/utf_16_be.py create mode 100644 lib/jython/Lib/encodings/utf_16_le.py create mode 100644 lib/jython/Lib/encodings/utf_8.py create mode 100644 lib/jython/Lib/fileinput.py create mode 100644 lib/jython/Lib/fnmatch.py create mode 100644 lib/jython/Lib/formatter.py create mode 100644 lib/jython/Lib/fpformat.py create mode 100644 lib/jython/Lib/ftplib.py create mode 100644 lib/jython/Lib/getopt.py create mode 100644 lib/jython/Lib/glob.py create mode 100644 lib/jython/Lib/gopherlib.py create mode 100644 lib/jython/Lib/gzip.py create mode 100644 lib/jython/Lib/htmlentitydefs.py create mode 100644 lib/jython/Lib/htmllib.py create mode 100644 lib/jython/Lib/httplib.py create mode 100644 lib/jython/Lib/imaplib.py create mode 100644 lib/jython/Lib/imghdr.py create mode 100644 lib/jython/Lib/isql.py create mode 100644 lib/jython/Lib/javaos.py create mode 100644 lib/jython/Lib/javapath.py create mode 100644 lib/jython/Lib/jreload.py create mode 100644 lib/jython/Lib/jxxload_help/DiscardHelp.java create mode 100644 lib/jython/Lib/jxxload_help/JavaLoaderFactory.java create mode 100644 lib/jython/Lib/jxxload_help/Makefile create mode 100644 lib/jython/Lib/jxxload_help/PackageManager.java create mode 100644 lib/jython/Lib/jxxload_help/PathVFS.java create mode 100644 lib/jython/Lib/jxxload_help/PathVFSJavaLoader.java create mode 100644 lib/jython/Lib/keyword.py create mode 100644 lib/jython/Lib/linecache.py create mode 100644 lib/jython/Lib/macpath.py create mode 100644 lib/jython/Lib/macurl2path.py create mode 100644 lib/jython/Lib/mailbox.py create mode 100644 lib/jython/Lib/mailcap.py create mode 100644 lib/jython/Lib/marshal.py create mode 100644 lib/jython/Lib/mhlib.py create mode 100644 lib/jython/Lib/mimetools.py create mode 100644 lib/jython/Lib/mimetypes.py create mode 100644 lib/jython/Lib/mimify.py create mode 100644 lib/jython/Lib/multifile.py create mode 100644 lib/jython/Lib/mutex.py create mode 100644 lib/jython/Lib/nntplib.py create mode 100644 lib/jython/Lib/ntpath.py create mode 100644 lib/jython/Lib/nturl2path.py create mode 100644 lib/jython/Lib/pawt/__init__.py create mode 100644 lib/jython/Lib/pawt/colors.py create mode 100644 lib/jython/Lib/pawt/swing.py create mode 100644 lib/jython/Lib/pdb.py create mode 100644 lib/jython/Lib/pickle.py create mode 100644 lib/jython/Lib/pipes.py create mode 100644 lib/jython/Lib/popen2.py create mode 100644 lib/jython/Lib/poplib.py create mode 100644 lib/jython/Lib/posixfile.py create mode 100644 lib/jython/Lib/posixpath.py create mode 100644 lib/jython/Lib/pprint.py create mode 100644 lib/jython/Lib/profile.py create mode 100644 lib/jython/Lib/pstats.py create mode 100644 lib/jython/Lib/pyclbr.py create mode 100644 lib/jython/Lib/quopri.py create mode 100644 lib/jython/Lib/random.py create mode 100644 lib/jython/Lib/re.py create mode 100644 lib/jython/Lib/reconvert.py create mode 100644 lib/jython/Lib/repr.py create mode 100644 lib/jython/Lib/rfc822.py create mode 100644 lib/jython/Lib/sched.py create mode 100644 lib/jython/Lib/sgmllib.py create mode 100644 lib/jython/Lib/shelve.py create mode 100644 lib/jython/Lib/shutil.py create mode 100644 lib/jython/Lib/site.py create mode 100644 lib/jython/Lib/smtplib.py create mode 100644 lib/jython/Lib/sndhdr.py create mode 100644 lib/jython/Lib/socket.py create mode 100644 lib/jython/Lib/sre.py create mode 100644 lib/jython/Lib/sre_compile.py create mode 100644 lib/jython/Lib/sre_constants.py create mode 100644 lib/jython/Lib/sre_parse.py create mode 100644 lib/jython/Lib/stat.py create mode 100644 lib/jython/Lib/string.py create mode 100644 lib/jython/Lib/symbol.py create mode 100644 lib/jython/Lib/telnetlib.py create mode 100644 lib/jython/Lib/tempfile.py create mode 100644 lib/jython/Lib/test/pystone.py create mode 100644 lib/jython/Lib/threading.py create mode 100644 lib/jython/Lib/token.py create mode 100644 lib/jython/Lib/tokenize.py create mode 100644 lib/jython/Lib/traceback.py create mode 100644 lib/jython/Lib/tzparse.py create mode 100644 lib/jython/Lib/unittest.py create mode 100644 lib/jython/Lib/urllib.py create mode 100644 lib/jython/Lib/urlparse.py create mode 100644 lib/jython/Lib/user.py create mode 100644 lib/jython/Lib/warnings.py create mode 100644 lib/jython/Lib/weakref.py create mode 100644 lib/jython/Lib/whichdb.py create mode 100644 lib/jython/Lib/whrandom.py create mode 100644 lib/jython/Lib/xdrlib.py create mode 100644 lib/jython/Lib/xml/__init__.py create mode 100644 lib/jython/Lib/xml/dom/Attr.py create mode 100644 lib/jython/Lib/xml/dom/CDATASection.py create mode 100644 lib/jython/Lib/xml/dom/CharacterData.py create mode 100644 lib/jython/Lib/xml/dom/Comment.py create mode 100644 lib/jython/Lib/xml/dom/DOMImplementation.py create mode 100644 lib/jython/Lib/xml/dom/Document.py create mode 100644 lib/jython/Lib/xml/dom/DocumentFragment.py create mode 100644 lib/jython/Lib/xml/dom/DocumentType.py create mode 100644 lib/jython/Lib/xml/dom/Element.py create mode 100644 lib/jython/Lib/xml/dom/Entity.py create mode 100644 lib/jython/Lib/xml/dom/EntityReference.py create mode 100644 lib/jython/Lib/xml/dom/Event.py create mode 100644 lib/jython/Lib/xml/dom/FtNode.py create mode 100644 lib/jython/Lib/xml/dom/MessageSource.py create mode 100644 lib/jython/Lib/xml/dom/NamedNodeMap.py create mode 100644 lib/jython/Lib/xml/dom/NodeFilter.py create mode 100644 lib/jython/Lib/xml/dom/NodeIterator.py create mode 100644 lib/jython/Lib/xml/dom/NodeList.py create mode 100644 lib/jython/Lib/xml/dom/Notation.py create mode 100644 lib/jython/Lib/xml/dom/ProcessingInstruction.py create mode 100644 lib/jython/Lib/xml/dom/Range.py create mode 100644 lib/jython/Lib/xml/dom/Text.py create mode 100644 lib/jython/Lib/xml/dom/TreeWalker.py create mode 100644 lib/jython/Lib/xml/dom/__init__.py create mode 100644 lib/jython/Lib/xml/dom/domreg.py create mode 100644 lib/jython/Lib/xml/dom/ext/Printer.py create mode 100644 lib/jython/Lib/xml/dom/ext/Visitor.py create mode 100644 lib/jython/Lib/xml/dom/ext/XHtml2HtmlPrinter.py create mode 100644 lib/jython/Lib/xml/dom/ext/XHtmlPrinter.py create mode 100644 lib/jython/Lib/xml/dom/ext/__init__.py create mode 100644 lib/jython/Lib/xml/dom/ext/c14n.py create mode 100644 lib/jython/Lib/xml/dom/ext/reader/Sax.py create mode 100644 lib/jython/Lib/xml/dom/ext/reader/Sax2.py create mode 100644 lib/jython/Lib/xml/dom/ext/reader/Sax2Lib.py create mode 100644 lib/jython/Lib/xml/dom/ext/reader/__init__.py create mode 100644 lib/jython/Lib/xml/dom/html/GenerateHtml.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLAnchorElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLAppletElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLAreaElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLBRElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLBaseElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLBaseFontElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLBodyElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLButtonElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLCollection.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLDListElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLDOMImplementation.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLDirectoryElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLDivElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLDocument.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLFieldSetElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLFontElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLFormElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLFrameElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLFrameSetElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLHRElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLHeadElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLHeadingElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLHtmlElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLIFrameElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLImageElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLInputElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLIsIndexElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLLIElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLLabelElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLLegendElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLLinkElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLMapElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLMenuElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLMetaElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLModElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLOListElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLObjectElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLOptGroupElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLOptionElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLParagraphElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLParamElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLPreElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLQuoteElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLScriptElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLSelectElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLStyleElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableCaptionElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableCellElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableColElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableRowElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTableSectionElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTextAreaElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLTitleElement.py create mode 100644 lib/jython/Lib/xml/dom/html/HTMLUListElement.py create mode 100644 lib/jython/Lib/xml/dom/html/__init__.py create mode 100644 lib/jython/Lib/xml/dom/javadom.py create mode 100644 lib/jython/Lib/xml/dom/minidom.py create mode 100644 lib/jython/Lib/xml/dom/minitraversal.py create mode 100644 lib/jython/Lib/xml/dom/pulldom.py create mode 100644 lib/jython/Lib/xml/ns.py create mode 100644 lib/jython/Lib/xml/parsers/__init__.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/__init__.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/_outputters.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/catalog.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/charconv.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/dtdparser.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/errors.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/namespace.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/utils.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xcatalog.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xmlapp.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xmldtd.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xmlproc.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xmlutils.py create mode 100644 lib/jython/Lib/xml/parsers/xmlproc/xmlval.py create mode 100644 lib/jython/Lib/xml/sax/__init__.py create mode 100644 lib/jython/Lib/xml/sax/_exceptions.py create mode 100644 lib/jython/Lib/xml/sax/drivers2/__init__.py create mode 100644 lib/jython/Lib/xml/sax/drivers2/drv_xmlproc.py create mode 100644 lib/jython/Lib/xml/sax/expatreader.py create mode 100644 lib/jython/Lib/xml/sax/handler.py create mode 100644 lib/jython/Lib/xml/sax/sax2exts.py create mode 100644 lib/jython/Lib/xml/sax/saxexts.py create mode 100644 lib/jython/Lib/xml/sax/saxlib.py create mode 100644 lib/jython/Lib/xml/sax/saxutils.py create mode 100644 lib/jython/Lib/xml/sax/writer.py create mode 100644 lib/jython/Lib/xml/sax/xmlreader.py create mode 100644 lib/jython/Lib/xml/utils/__init__.py create mode 100644 lib/jython/Lib/xml/utils/iso8601.py create mode 100644 lib/jython/Lib/xml/utils/qp_xml.py create mode 100644 lib/jython/Lib/xmllib.py create mode 100644 lib/jython/Lib/zipfile.py create mode 100644 lib/jython/Lib/zlib.py create mode 100644 lib/jython/README.txt create mode 100644 lib/jython/jython.jar diff --git a/lib/jython/LICENSE.txt b/lib/jython/LICENSE.txt new file mode 100644 index 000000000..5287f75e6 --- /dev/null +++ b/lib/jython/LICENSE.txt @@ -0,0 +1,144 @@ +HISTORY OF THE SOFTWARE +======================= + +JPython was created in late 1997 by Jim Hugunin. Jim was also the +primary developer while he was at CNRI. In February 1999 Barry Warsaw +took over as primary developer and released JPython version 1.1. +In October 2000 Barry helped move the software to SourceForge +where it was renamed to Jython. Jython 2.0 is developed by a group +of volunteers. + + +The standard library is covered by the BeOpen / CNRI license. See the +Lib/LICENSE file for details. + +The oro regular expresion matcher is covered by the apache license. +See the org/apache/LICENSE file for details. + +The zxJDBC package was written by Brian Zimmer and originally licensed +under the GNU Public License. The package is now covered by the Jython +Software License. + +Jython changes Software License. +================================ + +Copyright (c) 2000, Jython Developers +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + - Neither the name of the Jython Developers nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + +JPython Software License. +========================= + +______________________________________________________________________ + +IMPORTANT: PLEASE READ THE FOLLOWING AGREEMENT CAREFULLY. + +BY CLICKING ON THE "ACCEPT" BUTTON WHERE INDICATED, OR BY INSTALLING, +COPYING OR OTHERWISE USING THE SOFTWARE, YOU ARE DEEMED TO HAVE AGREED TO +THE TERMS AND CONDITIONS OF THIS AGREEMENT. + +______________________________________________________________________ + +JPython version 1.1.x + + 1. This LICENSE AGREEMENT is between the Corporation for National Research + Initiatives, having an office at 1895 Preston White Drive, Reston, VA + 20191 ("CNRI"), and the Individual or Organization ("Licensee") + accessing and using JPython version 1.1.x in source or binary form and + its associated documentation as provided herein ("Software"). + + 2. Subject to the terms and conditions of this License Agreement, CNRI + hereby grants Licensee a non-exclusive, non-transferable, royalty-free, + world-wide license to reproduce, analyze, test, perform and/or display + publicly, prepare derivative works, distribute, and otherwise use the + Software alone or in any derivative version, provided, however, that + CNRI's License Agreement and CNRI's notice of copyright, i.e., + "Copyright ©1996-1999 Corporation for National Research Initiatives; + All Rights Reserved" are both retained in the Software, alone or in any + derivative version prepared by Licensee. + + Alternatively, in lieu of CNRI's License Agreement, Licensee may + substitute the following text (omitting the quotes), provided, however, + that such text is displayed prominently in the Software alone or in any + derivative version prepared by Licensee: "JPython (Version 1.1.x) is + made available subject to the terms and conditions in CNRI's License + Agreement. This Agreement may be located on the Internet using the + following unique, persistent identifier (known as a handle): + 1895.22/1006. The License may also be obtained from a proxy server on + the Web using the following URL: http://hdl.handle.net/1895.22/1006." + + 3. In the event Licensee prepares a derivative work that is based on or + incorporates the Software or any part thereof, and wants to make the + derivative work available to the public as provided herein, then + Licensee hereby agrees to indicate in any such work, in a prominently + visible way, the nature of the modifications made to CNRI's Software. + + 4. Licensee may not use CNRI trademarks or trade name, including JPython + or CNRI, in a trademark sense to endorse or promote products or + services of Licensee, or any third party. Licensee may use the mark + JPython in connection with Licensee's derivative versions that are + based on or incorporate the Software, but only in the form + "JPython-based ___________________," or equivalent. + + 5. CNRI is making the Software available to Licensee on an "AS IS" basis. + CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY + OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND DISCLAIMS ANY + REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY + PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT INFRINGE + ANY THIRD PARTY RIGHTS. + + 6. CNRI SHALL NOT BE LIABLE TO LICENSEE OR OTHER USERS OF THE SOFTWARE FOR + ANY INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF + USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY DERIVATIVE + THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. SOME STATES DO NOT + ALLOW THE LIMITATION OR EXCLUSION OF LIABILITY SO THE ABOVE DISCLAIMER + MAY NOT APPLY TO LICENSEE. + + 7. This License Agreement may be terminated by CNRI (i) immediately upon + written notice from CNRI of any material breach by the Licensee, if the + nature of the breach is such that it cannot be promptly remedied; or + (ii) sixty (60) days following notice from CNRI to Licensee of a + material remediable breach, if Licensee has not remedied such breach + within that sixty-day period. + + 8. This License Agreement shall be governed by and interpreted in all + respects by the law of the State of Virginia, excluding conflict of law + provisions. Nothing in this Agreement shall be deemed to create any + relationship of agency, partnership, or joint venture between CNRI and + Licensee. + + 9. By clicking on the "ACCEPT" button where indicated, or by installing, + copying or otherwise using the Software, Licensee agrees to be bound by + the terms and conditions of this License Agreement. + + [ACCEPT BUTTON] + diff --git a/lib/jython/Lib/BaseHTTPServer.py b/lib/jython/Lib/BaseHTTPServer.py new file mode 100644 index 000000000..5f3a8d7cf --- /dev/null +++ b/lib/jython/Lib/BaseHTTPServer.py @@ -0,0 +1,482 @@ +"""HTTP server base class. + +Note: the class in this module doesn't implement any HTTP request; see +SimpleHTTPServer for simple implementations of GET, HEAD and POST +(including CGI scripts). + +Contents: + +- BaseHTTPRequestHandler: HTTP request handler base class +- test: test function + +XXX To do: + +- send server version +- log requests even later (to capture byte count) +- log user-agent header and other interesting goodies +- send error log to separate file +- are request names really case sensitive? + +""" + + +# See also: +# +# HTTP Working Group T. Berners-Lee +# INTERNET-DRAFT R. T. Fielding +# H. Frystyk Nielsen +# Expires September 8, 1995 March 8, 1995 +# +# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt + + +# Log files +# --------- +# +# Here's a quote from the NCSA httpd docs about log file format. +# +# | The logfile format is as follows. Each line consists of: +# | +# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb +# | +# | host: Either the DNS name or the IP number of the remote client +# | rfc931: Any information returned by identd for this person, +# | - otherwise. +# | authuser: If user sent a userid for authentication, the user name, +# | - otherwise. +# | DD: Day +# | Mon: Month (calendar name) +# | YYYY: Year +# | hh: hour (24-hour format, the machine's timezone) +# | mm: minutes +# | ss: seconds +# | request: The first line of the HTTP request as sent by the client. +# | ddd: the status code returned by the server, - if not available. +# | bbbb: the total number of bytes sent, +# | *not including the HTTP/1.0 header*, - if not available +# | +# | You can determine the name of the file accessed through request. +# +# (Actually, the latter is only true if you know the server configuration +# at the time the request was made!) + + +__version__ = "0.2" + +__all__ = ["HTTPServer", "BaseHTTPRequestHandler"] + +import sys +import time +import socket # For gethostbyaddr() +import mimetools +import SocketServer + +# Default error message +DEFAULT_ERROR_MESSAGE = """\ + +Error response + + +

Error response

+

Error code %(code)d. +

Message: %(message)s. +

Error code explanation: %(code)s = %(explain)s. + +""" + + +class HTTPServer(SocketServer.TCPServer): + + allow_reuse_address = 1 # Seems to make sense in testing environment + + def server_bind(self): + """Override server_bind to store the server name.""" + SocketServer.TCPServer.server_bind(self) + host, port = self.socket.getsockname() + self.server_name = socket.getfqdn(host) + self.server_port = port + + +class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler): + + """HTTP request handler base class. + + The following explanation of HTTP serves to guide you through the + code as well as to expose any misunderstandings I may have about + HTTP (so you don't need to read the code to figure out I'm wrong + :-). + + HTTP (HyperText Transfer Protocol) is an extensible protocol on + top of a reliable stream transport (e.g. TCP/IP). The protocol + recognizes three parts to a request: + + 1. One line identifying the request type and path + 2. An optional set of RFC-822-style headers + 3. An optional data part + + The headers and data are separated by a blank line. + + The first line of the request has the form + + + + where is a (case-sensitive) keyword such as GET or POST, + is a string containing path information for the request, + and should be the string "HTTP/1.0". is encoded + using the URL encoding scheme (using %xx to signify the ASCII + character with hex code xx). + + The protocol is vague about whether lines are separated by LF + characters or by CRLF pairs -- for compatibility with the widest + range of clients, both should be accepted. Similarly, whitespace + in the request line should be treated sensibly (allowing multiple + spaces between components and allowing trailing whitespace). + + Similarly, for output, lines ought to be separated by CRLF pairs + but most clients grok LF characters just fine. + + If the first line of the request has the form + + + + (i.e. is left out) then this is assumed to be an HTTP + 0.9 request; this form has no optional headers and data part and + the reply consists of just the data. + + The reply form of the HTTP 1.0 protocol again has three parts: + + 1. One line giving the response code + 2. An optional set of RFC-822-style headers + 3. The data + + Again, the headers and data are separated by a blank line. + + The response code line has the form + + + + where is the protocol version (always "HTTP/1.0"), + is a 3-digit response code indicating success or + failure of the request, and is an optional + human-readable string explaining what the response code means. + + This server parses the request and the headers, and then calls a + function specific to the request type (). Specifically, + a request SPAM will be handled by a method do_SPAM(). If no + such method exists the server sends an error response to the + client. If it exists, it is called with no arguments: + + do_SPAM() + + Note that the request name is case sensitive (i.e. SPAM and spam + are different requests). + + The various request details are stored in instance variables: + + - client_address is the client IP address in the form (host, + port); + + - command, path and version are the broken-down request line; + + - headers is an instance of mimetools.Message (or a derived + class) containing the header information; + + - rfile is a file object open for reading positioned at the + start of the optional input data part; + + - wfile is a file object open for writing. + + IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING! + + The first thing to be written must be the response line. Then + follow 0 or more header lines, then a blank line, and then the + actual data (if any). The meaning of the header lines depends on + the command executed by the server; in most cases, when data is + returned, there should be at least one header line of the form + + Content-type: / + + where and should be registered MIME types, + e.g. "text/html" or "text/plain". + + """ + + # The Python system version, truncated to its first component. + sys_version = "Python/" + sys.version.split()[0] + + # The server software version. You may want to override this. + # The format is multiple whitespace-separated strings, + # where each string is of the form name[/version]. + server_version = "BaseHTTP/" + __version__ + + def parse_request(self): + """Parse a request (internal). + + The request should be stored in self.raw_request; the results + are in self.command, self.path, self.request_version and + self.headers. + + Return value is 1 for success, 0 for failure; on failure, an + error is sent back. + + """ + self.request_version = version = "HTTP/0.9" # Default + requestline = self.raw_requestline + if requestline[-2:] == '\r\n': + requestline = requestline[:-2] + elif requestline[-1:] == '\n': + requestline = requestline[:-1] + self.requestline = requestline + words = requestline.split() + if len(words) == 3: + [command, path, version] = words + if version[:5] != 'HTTP/': + self.send_error(400, "Bad request version (%s)" % `version`) + return 0 + elif len(words) == 2: + [command, path] = words + if command != 'GET': + self.send_error(400, + "Bad HTTP/0.9 request type (%s)" % `command`) + return 0 + else: + self.send_error(400, "Bad request syntax (%s)" % `requestline`) + return 0 + self.command, self.path, self.request_version = command, path, version + self.headers = self.MessageClass(self.rfile, 0) + return 1 + + def handle(self): + """Handle a single HTTP request. + + You normally don't need to override this method; see the class + __doc__ string for information on how to handle specific HTTP + commands such as GET and POST. + + """ + + self.raw_requestline = self.rfile.readline() + if not self.parse_request(): # An error code has been sent, just exit + return + mname = 'do_' + self.command + if not hasattr(self, mname): + self.send_error(501, "Unsupported method (%s)" % `self.command`) + return + method = getattr(self, mname) + method() + + def send_error(self, code, message=None): + """Send and log an error reply. + + Arguments are the error code, and a detailed message. + The detailed message defaults to the short entry matching the + response code. + + This sends an error response (so it must be called before any + output has been generated), logs the error, and finally sends + a piece of HTML explaining the error to the user. + + """ + + try: + short, long = self.responses[code] + except KeyError: + short, long = '???', '???' + if not message: + message = short + explain = long + self.log_error("code %d, message %s", code, message) + self.send_response(code, message) + self.end_headers() + self.wfile.write(self.error_message_format % + {'code': code, + 'message': message, + 'explain': explain}) + + error_message_format = DEFAULT_ERROR_MESSAGE + + def send_response(self, code, message=None): + """Send the response header and log the response code. + + Also send two standard headers with the server software + version and the current date. + + """ + self.log_request(code) + if message is None: + if self.responses.has_key(code): + message = self.responses[code][0] + else: + message = '' + if self.request_version != 'HTTP/0.9': + self.wfile.write("%s %s %s\r\n" % + (self.protocol_version, str(code), message)) + self.send_header('Server', self.version_string()) + self.send_header('Date', self.date_time_string()) + + def send_header(self, keyword, value): + """Send a MIME header.""" + if self.request_version != 'HTTP/0.9': + self.wfile.write("%s: %s\r\n" % (keyword, value)) + + def end_headers(self): + """Send the blank line ending the MIME headers.""" + if self.request_version != 'HTTP/0.9': + self.wfile.write("\r\n") + + def log_request(self, code='-', size='-'): + """Log an accepted request. + + This is called by send_reponse(). + + """ + + self.log_message('"%s" %s %s', + self.requestline, str(code), str(size)) + + def log_error(self, *args): + """Log an error. + + This is called when a request cannot be fulfilled. By + default it passes the message on to log_message(). + + Arguments are the same as for log_message(). + + XXX This should go to the separate error log. + + """ + + apply(self.log_message, args) + + def log_message(self, format, *args): + """Log an arbitrary message. + + This is used by all other logging functions. Override + it if you have specific logging wishes. + + The first argument, FORMAT, is a format string for the + message to be logged. If the format string contains + any % escapes requiring parameters, they should be + specified as subsequent arguments (it's just like + printf!). + + The client host and current date/time are prefixed to + every message. + + """ + + sys.stderr.write("%s - - [%s] %s\n" % + (self.address_string(), + self.log_date_time_string(), + format%args)) + + def version_string(self): + """Return the server software version string.""" + return self.server_version + ' ' + self.sys_version + + def date_time_string(self): + """Return the current date and time formatted for a message header.""" + now = time.time() + year, month, day, hh, mm, ss, wd, y, z = time.gmtime(now) + s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % ( + self.weekdayname[wd], + day, self.monthname[month], year, + hh, mm, ss) + return s + + def log_date_time_string(self): + """Return the current time formatted for logging.""" + now = time.time() + year, month, day, hh, mm, ss, x, y, z = time.localtime(now) + s = "%02d/%3s/%04d %02d:%02d:%02d" % ( + day, self.monthname[month], year, hh, mm, ss) + return s + + weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] + + monthname = [None, + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + + def address_string(self): + """Return the client address formatted for logging. + + This version looks up the full hostname using gethostbyaddr(), + and tries to find a name that contains at least one dot. + + """ + + host, port = self.client_address + return socket.getfqdn(host) + + # Essentially static class variables + + # The version of the HTTP protocol we support. + # Don't override unless you know what you're doing (hint: incoming + # requests are required to have exactly this version string). + protocol_version = "HTTP/1.0" + + # The Message-like class used to parse headers + MessageClass = mimetools.Message + + # Table mapping response codes to messages; entries have the + # form {code: (shortmessage, longmessage)}. + # See http://www.w3.org/hypertext/WWW/Protocols/HTTP/HTRESP.html + responses = { + 200: ('OK', 'Request fulfilled, document follows'), + 201: ('Created', 'Document created, URL follows'), + 202: ('Accepted', + 'Request accepted, processing continues off-line'), + 203: ('Partial information', 'Request fulfilled from cache'), + 204: ('No response', 'Request fulfilled, nothing follows'), + + 301: ('Moved', 'Object moved permanently -- see URI list'), + 302: ('Found', 'Object moved temporarily -- see URI list'), + 303: ('Method', 'Object moved -- see Method and URL list'), + 304: ('Not modified', + 'Document has not changed singe given time'), + + 400: ('Bad request', + 'Bad request syntax or unsupported method'), + 401: ('Unauthorized', + 'No permission -- see authorization schemes'), + 402: ('Payment required', + 'No payment -- see charging schemes'), + 403: ('Forbidden', + 'Request forbidden -- authorization will not help'), + 404: ('Not found', 'Nothing matches the given URI'), + + 500: ('Internal error', 'Server got itself in trouble'), + 501: ('Not implemented', + 'Server does not support this operation'), + 502: ('Service temporarily overloaded', + 'The server cannot process the request due to a high load'), + 503: ('Gateway timeout', + 'The gateway server did not receive a timely response'), + + } + + +def test(HandlerClass = BaseHTTPRequestHandler, + ServerClass = HTTPServer): + """Test the HTTP request handler class. + + This runs an HTTP server on port 8000 (or the first command line + argument). + + """ + + if sys.argv[1:]: + port = int(sys.argv[1]) + else: + port = 8000 + server_address = ('', port) + + httpd = ServerClass(server_address, HandlerClass) + + print "Serving HTTP on port", port, "..." + httpd.serve_forever() + + +if __name__ == '__main__': + test() diff --git a/lib/jython/Lib/CGIHTTPServer.py b/lib/jython/Lib/CGIHTTPServer.py new file mode 100644 index 000000000..cc196fc69 --- /dev/null +++ b/lib/jython/Lib/CGIHTTPServer.py @@ -0,0 +1,305 @@ +"""CGI-savvy HTTP Server. + +This module builds on SimpleHTTPServer by implementing GET and POST +requests to cgi-bin scripts. + +If the os.fork() function is not present (e.g. on Windows), +os.popen2() is used as a fallback, with slightly altered semantics; if +that function is not present either (e.g. on Macintosh), only Python +scripts are supported, and they are executed by the current process. + +In all cases, the implementation is intentionally naive -- all +requests are executed sychronously. + +SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL +-- it may execute arbitrary Python code or external programs. + +""" + + +__version__ = "0.4" + +__all__ = ["CGIHTTPRequestHandler"] + +import os +import sys +import urllib +import BaseHTTPServer +import SimpleHTTPServer + + +class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): + + """Complete HTTP server with GET, HEAD and POST commands. + + GET and HEAD also support running CGI scripts. + + The POST command is *only* implemented for CGI scripts. + + """ + + # Determine platform specifics + have_fork = hasattr(os, 'fork') + have_popen2 = hasattr(os, 'popen2') + + # Make rfile unbuffered -- we need to read one line and then pass + # the rest to a subprocess, so we can't use buffered input. + rbufsize = 0 + + def do_POST(self): + """Serve a POST request. + + This is only implemented for CGI scripts. + + """ + + if self.is_cgi(): + self.run_cgi() + else: + self.send_error(501, "Can only POST to CGI scripts") + + def send_head(self): + """Version of send_head that support CGI scripts""" + if self.is_cgi(): + return self.run_cgi() + else: + return SimpleHTTPServer.SimpleHTTPRequestHandler.send_head(self) + + def is_cgi(self): + """Test whether self.path corresponds to a CGI script. + + Return a tuple (dir, rest) if self.path requires running a + CGI script, None if not. Note that rest begins with a + slash if it is not empty. + + The default implementation tests whether the path + begins with one of the strings in the list + self.cgi_directories (and the next character is a '/' + or the end of the string). + + """ + + path = self.path + + for x in self.cgi_directories: + i = len(x) + if path[:i] == x and (not path[i:] or path[i] == '/'): + self.cgi_info = path[:i], path[i+1:] + return 1 + return 0 + + cgi_directories = ['/cgi-bin', '/htbin'] + + def is_executable(self, path): + """Test whether argument path is an executable file.""" + return executable(path) + + def is_python(self, path): + """Test whether argument path is a Python script.""" + head, tail = os.path.splitext(path) + return tail.lower() in (".py", ".pyw") + + def run_cgi(self): + """Execute a CGI script.""" + dir, rest = self.cgi_info + i = rest.rfind('?') + if i >= 0: + rest, query = rest[:i], rest[i+1:] + else: + query = '' + i = rest.find('/') + if i >= 0: + script, rest = rest[:i], rest[i:] + else: + script, rest = rest, '' + scriptname = dir + '/' + script + scriptfile = self.translate_path(scriptname) + if not os.path.exists(scriptfile): + self.send_error(404, "No such CGI script (%s)" % `scriptname`) + return + if not os.path.isfile(scriptfile): + self.send_error(403, "CGI script is not a plain file (%s)" % + `scriptname`) + return + ispy = self.is_python(scriptname) + if not ispy: + if not (self.have_fork or self.have_popen2): + self.send_error(403, "CGI script is not a Python script (%s)" % + `scriptname`) + return + if not self.is_executable(scriptfile): + self.send_error(403, "CGI script is not executable (%s)" % + `scriptname`) + return + + # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html + # XXX Much of the following could be prepared ahead of time! + env = {} + env['SERVER_SOFTWARE'] = self.version_string() + env['SERVER_NAME'] = self.server.server_name + env['GATEWAY_INTERFACE'] = 'CGI/1.1' + env['SERVER_PROTOCOL'] = self.protocol_version + env['SERVER_PORT'] = str(self.server.server_port) + env['REQUEST_METHOD'] = self.command + uqrest = urllib.unquote(rest) + env['PATH_INFO'] = uqrest + env['PATH_TRANSLATED'] = self.translate_path(uqrest) + env['SCRIPT_NAME'] = scriptname + if query: + env['QUERY_STRING'] = query + host = self.address_string() + if host != self.client_address[0]: + env['REMOTE_HOST'] = host + env['REMOTE_ADDR'] = self.client_address[0] + # XXX AUTH_TYPE + # XXX REMOTE_USER + # XXX REMOTE_IDENT + if self.headers.typeheader is None: + env['CONTENT_TYPE'] = self.headers.type + else: + env['CONTENT_TYPE'] = self.headers.typeheader + length = self.headers.getheader('content-length') + if length: + env['CONTENT_LENGTH'] = length + accept = [] + for line in self.headers.getallmatchingheaders('accept'): + if line[:1] in "\t\n\r ": + accept.append(line.strip()) + else: + accept = accept + line[7:].split(',') + env['HTTP_ACCEPT'] = ','.join(accept) + ua = self.headers.getheader('user-agent') + if ua: + env['HTTP_USER_AGENT'] = ua + co = filter(None, self.headers.getheaders('cookie')) + if co: + env['HTTP_COOKIE'] = ', '.join(co) + # XXX Other HTTP_* headers + if not self.have_fork: + # Since we're setting the env in the parent, provide empty + # values to override previously set values + for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH', + 'HTTP_USER_AGENT', 'HTTP_COOKIE'): + env.setdefault(k, "") + + self.send_response(200, "Script output follows") + + decoded_query = query.replace('+', ' ') + + if self.have_fork: + # Unix -- fork as we should + args = [script] + if '=' not in decoded_query: + args.append(decoded_query) + nobody = nobody_uid() + self.wfile.flush() # Always flush before forking + pid = os.fork() + if pid != 0: + # Parent + pid, sts = os.waitpid(pid, 0) + if sts: + self.log_error("CGI script exit status %#x", sts) + return + # Child + try: + try: + os.setuid(nobody) + except os.error: + pass + os.dup2(self.rfile.fileno(), 0) + os.dup2(self.wfile.fileno(), 1) + os.execve(scriptfile, args, env) + except: + self.server.handle_error(self.request, self.client_address) + os._exit(127) + + elif self.have_popen2: + # Windows -- use popen2 to create a subprocess + import shutil + os.environ.update(env) + cmdline = scriptfile + if self.is_python(scriptfile): + interp = sys.executable + if interp.lower().endswith("w.exe"): + # On Windows, use python.exe, not python.exe + interp = interp[:-5] = interp[-4:] + cmdline = "%s %s" % (interp, cmdline) + if '=' not in query and '"' not in query: + cmdline = '%s "%s"' % (cmdline, query) + self.log_error("command: %s", cmdline) + try: + nbytes = int(length) + except: + nbytes = 0 + fi, fo = os.popen2(cmdline) + if self.command.lower() == "post" and nbytes > 0: + data = self.rfile.read(nbytes) + fi.write(data) + fi.close() + shutil.copyfileobj(fo, self.wfile) + sts = fo.close() + if sts: + self.log_error("CGI script exit status %#x", sts) + else: + self.log_error("CGI script exited OK") + + else: + # Other O.S. -- execute script in this process + os.environ.update(env) + save_argv = sys.argv + save_stdin = sys.stdin + save_stdout = sys.stdout + save_stderr = sys.stderr + try: + try: + sys.argv = [scriptfile] + if '=' not in decoded_query: + sys.argv.append(decoded_query) + sys.stdout = self.wfile + sys.stdin = self.rfile + execfile(scriptfile, {"__name__": "__main__"}) + finally: + sys.argv = save_argv + sys.stdin = save_stdin + sys.stdout = save_stdout + sys.stderr = save_stderr + except SystemExit, sts: + self.log_error("CGI script exit status %s", str(sts)) + else: + self.log_error("CGI script exited OK") + + +nobody = None + +def nobody_uid(): + """Internal routine to get nobody's uid""" + global nobody + if nobody: + return nobody + try: + import pwd + except ImportError: + return -1 + try: + nobody = pwd.getpwnam('nobody')[2] + except KeyError: + nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) + return nobody + + +def executable(path): + """Test for executable file.""" + try: + st = os.stat(path) + except os.error: + return 0 + return st[0] & 0111 != 0 + + +def test(HandlerClass = CGIHTTPRequestHandler, + ServerClass = BaseHTTPServer.HTTPServer): + SimpleHTTPServer.test(HandlerClass, ServerClass) + + +if __name__ == '__main__': + test() diff --git a/lib/jython/Lib/ConfigParser.py b/lib/jython/Lib/ConfigParser.py new file mode 100644 index 000000000..96186f297 --- /dev/null +++ b/lib/jython/Lib/ConfigParser.py @@ -0,0 +1,480 @@ +"""Configuration file parser. + +A setup file consists of sections, lead by a "[section]" header, +and followed by "name: value" entries, with continuations and such in +the style of RFC 822. + +The option values can contain format strings which refer to other values in +the same section, or values in a special [DEFAULT] section. + +For example: + + something: %(dir)s/whatever + +would resolve the "%(dir)s" to the value of dir. All reference +expansions are done late, on demand. + +Intrinsic defaults can be specified by passing them into the +ConfigParser constructor as a dictionary. + +class: + +ConfigParser -- responsible for for parsing a list of + configuration files, and managing the parsed database. + + methods: + + __init__(defaults=None) + create the parser and specify a dictionary of intrinsic defaults. The + keys must be strings, the values must be appropriate for %()s string + interpolation. Note that `__name__' is always an intrinsic default; + it's value is the section's name. + + sections() + return all the configuration section names, sans DEFAULT + + has_section(section) + return whether the given section exists + + has_option(section, option) + return whether the given option exists in the given section + + options(section) + return list of configuration options for the named section + + has_option(section, option) + return whether the given section has the given option + + read(filenames) + read and parse the list of named configuration files, given by + name. A single filename is also allowed. Non-existing files + are ignored. + + readfp(fp, filename=None) + read and parse one configuration file, given as a file object. + The filename defaults to fp.name; it is only used in error + messages (if fp has no `name' attribute, the string `' is used). + + get(section, option, raw=0, vars=None) + return a string value for the named option. All % interpolations are + expanded in the return values, based on the defaults passed into the + constructor and the DEFAULT section. Additional substitutions may be + provided using the `vars' argument, which must be a dictionary whose + contents override any pre-existing defaults. + + getint(section, options) + like get(), but convert value to an integer + + getfloat(section, options) + like get(), but convert value to a float + + getboolean(section, options) + like get(), but convert value to a boolean (currently defined as 0 or + 1, only) + + remove_section(section) + remove the given file section and all its options + + remove_option(section, option) + remove the given option from the given section + + set(section, option, value) + set the given option + + write(fp) + write the configuration state in .ini format +""" + +import sys +import string +import re + +__all__ = ["NoSectionError","DuplicateSectionError","NoOptionError", + "InterpolationError","InterpolationDepthError","ParsingError", + "MissingSectionHeaderError","ConfigParser", + "MAX_INTERPOLATION_DEPTH"] + +DEFAULTSECT = "DEFAULT" + +MAX_INTERPOLATION_DEPTH = 10 + + + +# exception classes +class Error(Exception): + def __init__(self, msg=''): + self._msg = msg + Exception.__init__(self, msg) + def __repr__(self): + return self._msg + __str__ = __repr__ + +class NoSectionError(Error): + def __init__(self, section): + Error.__init__(self, 'No section: %s' % section) + self.section = section + +class DuplicateSectionError(Error): + def __init__(self, section): + Error.__init__(self, "Section %s already exists" % section) + self.section = section + +class NoOptionError(Error): + def __init__(self, option, section): + Error.__init__(self, "No option `%s' in section: %s" % + (option, section)) + self.option = option + self.section = section + +class InterpolationError(Error): + def __init__(self, reference, option, section, rawval): + Error.__init__(self, + "Bad value substitution:\n" + "\tsection: [%s]\n" + "\toption : %s\n" + "\tkey : %s\n" + "\trawval : %s\n" + % (section, option, reference, rawval)) + self.reference = reference + self.option = option + self.section = section + +class InterpolationDepthError(Error): + def __init__(self, option, section, rawval): + Error.__init__(self, + "Value interpolation too deeply recursive:\n" + "\tsection: [%s]\n" + "\toption : %s\n" + "\trawval : %s\n" + % (section, option, rawval)) + self.option = option + self.section = section + +class ParsingError(Error): + def __init__(self, filename): + Error.__init__(self, 'File contains parsing errors: %s' % filename) + self.filename = filename + self.errors = [] + + def append(self, lineno, line): + self.errors.append((lineno, line)) + self._msg = self._msg + '\n\t[line %2d]: %s' % (lineno, line) + +class MissingSectionHeaderError(ParsingError): + def __init__(self, filename, lineno, line): + Error.__init__( + self, + 'File contains no section headers.\nfile: %s, line: %d\n%s' % + (filename, lineno, line)) + self.filename = filename + self.lineno = lineno + self.line = line + + + +class ConfigParser: + def __init__(self, defaults=None): + self.__sections = {} + if defaults is None: + self.__defaults = {} + else: + self.__defaults = defaults + + def defaults(self): + return self.__defaults + + def sections(self): + """Return a list of section names, excluding [DEFAULT]""" + # self.__sections will never have [DEFAULT] in it + return self.__sections.keys() + + def add_section(self, section): + """Create a new section in the configuration. + + Raise DuplicateSectionError if a section by the specified name + already exists. + """ + if self.__sections.has_key(section): + raise DuplicateSectionError(section) + self.__sections[section] = {} + + def has_section(self, section): + """Indicate whether the named section is present in the configuration. + + The DEFAULT section is not acknowledged. + """ + return section in self.sections() + + def options(self, section): + """Return a list of option names for the given section name.""" + try: + opts = self.__sections[section].copy() + except KeyError: + raise NoSectionError(section) + opts.update(self.__defaults) + if opts.has_key('__name__'): + del opts['__name__'] + return opts.keys() + + def has_option(self, section, option): + """Return whether the given section has the given option.""" + return option in self.options(section) + + def read(self, filenames): + """Read and parse a filename or a list of filenames. + + Files that cannot be opened are silently ignored; this is + designed so that you can specify a list of potential + configuration file locations (e.g. current directory, user's + home directory, systemwide directory), and all existing + configuration files in the list will be read. A single + filename may also be given. + """ + if type(filenames) in [type(''), type(u'')]: + filenames = [filenames] + for filename in filenames: + try: + fp = open(filename) + except IOError: + continue + self.__read(fp, filename) + fp.close() + + def readfp(self, fp, filename=None): + """Like read() but the argument must be a file-like object. + + The `fp' argument must have a `readline' method. Optional + second argument is the `filename', which if not given, is + taken from fp.name. If fp has no `name' attribute, `' is + used. + + """ + if filename is None: + try: + filename = fp.name + except AttributeError: + filename = '' + self.__read(fp, filename) + + def get(self, section, option, raw=0, vars=None): + """Get an option value for a given section. + + All % interpolations are expanded in the return values, based on the + defaults passed into the constructor, unless the optional argument + `raw' is true. Additional substitutions may be provided using the + `vars' argument, which must be a dictionary whose contents overrides + any pre-existing defaults. + + The section DEFAULT is special. + """ + try: + sectdict = self.__sections[section].copy() + except KeyError: + if section == DEFAULTSECT: + sectdict = {} + else: + raise NoSectionError(section) + d = self.__defaults.copy() + d.update(sectdict) + # Update with the entry specific variables + if vars: + d.update(vars) + option = self.optionxform(option) + try: + rawval = d[option] + except KeyError: + raise NoOptionError(option, section) + + if raw: + return rawval + + # do the string interpolation + value = rawval # Make it a pretty variable name + depth = 0 + while depth < 10: # Loop through this until it's done + depth = depth + 1 + if value.find("%(") >= 0: + try: + value = value % d + except KeyError, key: + raise InterpolationError(key, option, section, rawval) + else: + break + if value.find("%(") >= 0: + raise InterpolationDepthError(option, section, rawval) + return value + + def __get(self, section, conv, option): + return conv(self.get(section, option)) + + def getint(self, section, option): + return self.__get(section, string.atoi, option) + + def getfloat(self, section, option): + return self.__get(section, string.atof, option) + + def getboolean(self, section, option): + v = self.get(section, option) + val = int(v) + if val not in (0, 1): + raise ValueError, 'Not a boolean: %s' % v + return val + + def optionxform(self, optionstr): + return optionstr.lower() + + def has_option(self, section, option): + """Check for the existence of a given option in a given section.""" + if not section or section == "DEFAULT": + return self.__defaults.has_key(option) + elif not self.has_section(section): + return 0 + else: + option = self.optionxform(option) + return self.__sections[section].has_key(option) + + def set(self, section, option, value): + """Set an option.""" + if not section or section == "DEFAULT": + sectdict = self.__defaults + else: + try: + sectdict = self.__sections[section] + except KeyError: + raise NoSectionError(section) + option = self.optionxform(option) + sectdict[option] = value + + def write(self, fp): + """Write an .ini-format representation of the configuration state.""" + if self.__defaults: + fp.write("[DEFAULT]\n") + for (key, value) in self.__defaults.items(): + fp.write("%s = %s\n" % (key, value)) + fp.write("\n") + for section in self.sections(): + fp.write("[" + section + "]\n") + sectdict = self.__sections[section] + for (key, value) in sectdict.items(): + if key == "__name__": + continue + fp.write("%s = %s\n" % (key, value)) + fp.write("\n") + + def remove_option(self, section, option): + """Remove an option.""" + if not section or section == "DEFAULT": + sectdict = self.__defaults + else: + try: + sectdict = self.__sections[section] + except KeyError: + raise NoSectionError(section) + option = self.optionxform(option) + existed = sectdict.has_key(option) + if existed: + del sectdict[option] + return existed + + def remove_section(self, section): + """Remove a file section.""" + if self.__sections.has_key(section): + del self.__sections[section] + return 1 + else: + return 0 + + # + # Regular expressions for parsing section headers and options. Note a + # slight semantic change from the previous version, because of the use + # of \w, _ is allowed in section header names. + SECTCRE = re.compile( + r'\[' # [ + r'(?P

[^]]+)' # very permissive! + r'\]' # ] + ) + OPTCRE = re.compile( + r'(?P