]> granicus.if.org Git - python/commitdiff
added __all__ lists to a number of Python modules
authorSkip Montanaro <skip@pobox.com>
Sat, 20 Jan 2001 19:54:20 +0000 (19:54 +0000)
committerSkip Montanaro <skip@pobox.com>
Sat, 20 Jan 2001 19:54:20 +0000 (19:54 +0000)
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.

39 files changed:
Lib/BaseHTTPServer.py
Lib/Bastion.py
Lib/CGIHTTPServer.py
Lib/ConfigParser.py
Lib/Cookie.py
Lib/MimeWriter.py
Lib/Queue.py
Lib/SimpleHTTPServer.py
Lib/SocketServer.py
Lib/StringIO.py
Lib/UserDict.py
Lib/UserList.py
Lib/UserString.py
Lib/aifc.py
Lib/anydbm.py
Lib/atexit.py
Lib/audiodev.py
Lib/base64.py
Lib/bdb.py
Lib/binhex.py
Lib/bisect.py
Lib/calendar.py
Lib/cgi.py
Lib/chunk.py
Lib/cmd.py
Lib/code.py
Lib/codecs.py
Lib/codeop.py
Lib/colorsys.py
Lib/commands.py
Lib/compileall.py
Lib/copy.py
Lib/copy_reg.py
Lib/dbhash.py
Lib/dircache.py
Lib/dis.py
Lib/robotparser.py
Lib/test/output/test___all__ [new file with mode: 0644]
Lib/test/test___all__.py [new file with mode: 0644]

index f075e581dccead832e8ef98d43b5958facc2c610..2f17938feb245b2ea0c1d4457adb09a31c847a4d 100644 (file)
@@ -63,6 +63,7 @@ XXX To do:
 
 __version__ = "0.2"
 
+__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
 
 import sys
 import time
index 868b0b6403f2c8f68701cb2868ecd8a4380dbcbd..99990a2d7df662987e78597948b520778e628ff7 100644 (file)
@@ -26,6 +26,7 @@ bastion is created.
 
 """
 
+__all__ = ["BastionClass", "Bastion"]
 
 from types import MethodType
 
index ba1e76bb3eb21ec7fed2174677b2f050829c2d04..e2bef264ad36e87663b578910dc566e63dbc58bd 100644 (file)
@@ -19,6 +19,7 @@ SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
 
 __version__ = "0.4"
 
+__all__ = ["CGIHTTPRequestHandler"]
 
 import os
 import sys
index f1e77e8d7d190f5e768e18525ef404422bf9083a..6d1e6f4b21b0c3e6a52a8a259ee9df83ecadad9d 100644 (file)
@@ -89,6 +89,11 @@ import sys
 import string
 import re
 
+__all__ = ["NoSectionError","DuplicateSectionError","NoOptionError",
+           "InterpolationError","InterpolationDepthError","ParsingError",
+           "MissingSectionHeaderError","ConfigParser",
+           "MAX_INTERPOLATION_DEPTH"]
+
 DEFAULTSECT = "DEFAULT"
 
 MAX_INTERPOLATION_DEPTH = 10
index 4ff0cbb066ff77f71c63b31bcebcfb195ab3e5c4..565e6f3fb498ba04338e22793d6b75d323bfa452 100644 (file)
@@ -228,6 +228,8 @@ try:
 except ImportError:
     raise ImportError, "Cookie.py requires 're' from Python 1.5 or later"
 
+__all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie",
+           "SmartCookie","Cookie"]
 
 #
 # Define an exception visible to External modules
index 9f0465614fd24856bb37e56567f63e43053f5ed0..6aab1cd5f1864d373b9c9ffb4e858c31e994f9e8 100644 (file)
@@ -10,6 +10,7 @@ MimeWriter - the only thing here.
 import string
 import mimetools
 
+__all__ = ["MimeWriter"]
 
 class MimeWriter:
 
index 0e6bbf055a469a4e2013c60219e36bd7ac5e5d2b..050a9660405ca308f7b4561b9b184c0c4cff2a4c 100644 (file)
@@ -1,5 +1,7 @@
 """A multi-producer, multi-consumer queue."""
 
+__all__ = ["Queue","Empty","Full"]
+
 class Empty(Exception):
     "Exception raised by Queue.get(block=0)/get_nowait()."
     pass
index 37e3b38dfabdee90e3dc7a52395458389dcf4eb7..7bb12626732396a3b984b921340e12cc178a7541 100644 (file)
@@ -8,6 +8,7 @@ and HEAD requests in a fairly straightforward manner.
 
 __version__ = "0.6"
 
+__all__ = ["SimpleHTTPRequestHandler"]
 
 import os
 import string
index e1967fe20350dbb61e440b7df5812293fba3ee02..ec0159a0457abcc671255170bf87689a7ba4cbeb 100644 (file)
@@ -127,6 +127,13 @@ import socket
 import sys
 import os
 
+__all__ = ["TCPServer","UDPServer","ForkingUDPServer","ForkingTCPServer",
+           "ThreadingUDPServer","ThreadingTCPServer","BaseRequestHandler",
+           "StreamRequestHandler","DatagramRequestHandler"]
+if hasattr(socket, "AF_UNIX"):
+    __all__.extend(["UnixStreamServer","UnixDatagramServer",
+                    "ThreadingUnixStreamServer",
+                    "ThreadingUnixDatagramServer"])
 
 class BaseServer:
 
index 5fac5904e65bbe4222cd3db0c05307266dec44df..bc5e9e24327a5100d9e2bcde5bd7f0b424584cdc 100644 (file)
@@ -34,6 +34,8 @@ try:
 except ImportError:
     EINVAL = 22
 
+__all__ = ["StringIO"]
+
 EMPTYSTRING = ''
 
 class StringIO:
index b642db73b57e480c55dbd4af7474d0983d77e126..38f0d2631bd00d3985c1ef170d92cfc467d67ac2 100644 (file)
@@ -1,5 +1,7 @@
 """A more or less complete user-defined wrapper around dictionary objects."""
 
+__all__ = ["UserDict"]
+
 class UserDict:
     def __init__(self, dict=None):
         self.data = {}
index ee2658939ff11e57f2a6ba6a8609c3341924280f..6867332b70e78b1cc29bd47255a66b619ec70a6f 100644 (file)
@@ -1,5 +1,7 @@
 """A more or less complete user-defined wrapper around list objects."""
 
+__all__ = ["UserList"]
+
 class UserList:
     def __init__(self, initlist=None):
         self.data = []
index 2d02b9b7d8db784244e2e1a076d62a5950eba3e2..163faa507bb5418ae9873c040a228c497226e326 100755 (executable)
@@ -8,6 +8,8 @@ This module requires Python 1.6 or later.
 from types import StringType, UnicodeType
 import sys
 
+__all__ = ["UserString","MutableString"]
+
 class UserString:
     def __init__(self, seq):
         if isinstance(seq, StringType) or isinstance(seq, UnicodeType):
index 42d5c671a47e7eaace3b59ab731bc4a0b707169e..0821cffe6e35200fc3b59b0b9d3064b153f62be6 100644 (file)
@@ -137,6 +137,8 @@ writeframesraw.
 import struct
 import __builtin__
 
+__all__ = ["Error","open","openfp"]
+
 class Error(Exception):
     pass
 
index ba6fa7b54aa0a5154302fa188b0d80a4381fdfdf..9352fbff561fdb970749b723efc1e38dcfcd7b9c 100644 (file)
@@ -42,6 +42,8 @@ only if it doesn't exist; and 'n' always creates a new database.
 
 """
 
+__all__ = ["error","open"]
+
 try:
     class error(Exception):
         pass
index b687cb40237266790f5115378a579dced2c85625..bcf7e548a033c2fcccfda9358fd1b906c5ade68c 100644 (file)
@@ -5,6 +5,8 @@ upon normal program termination.
 One public function, register, is defined.
 """
 
+__all__ = ["register"]
+
 _exithandlers = []
 def _run_exitfuncs():
     """run any registered exit functions
index 5dfd1ab129df432b04105147f05448886e376c24..234514597ca0b163128f8ccc707f14175bb26201 100644 (file)
@@ -1,5 +1,7 @@
 """Classes for manipulating audio devices (currently only for Sun and SGI)"""
 
+__all__ = ["error","AudioDev"]
+
 class error(Exception):
     pass
 
index ae67f68eccb38d597966a01d7fa936d02e4f3f14..290fa83a047a50408fd1b8568354f1b4c863b50c 100755 (executable)
@@ -6,6 +6,8 @@
 
 import binascii
 
+__all__ = ["encode","decode","encodestring","decodestring"]
+
 MAXLINESIZE = 76 # Excluding the CRLF
 MAXBINSIZE = (MAXLINESIZE/4)*3
 
index 6bf0ff4682c7f554bb648c2399c54220d05b039a..a0bf9b7119e05ca760bdb44c78e70e55c4151860 100644 (file)
@@ -4,6 +4,8 @@ import sys
 import os
 import types
 
+__all__ = ["BdbQuit","Bdb","Breakpoint"]
+
 BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
 
 
index ac2437b9624feacc9b5be746bea58c064b4495fc..8189563944a7786d5d11cdc633baf022a7448cbf 100644 (file)
@@ -27,6 +27,8 @@ import struct
 import string
 import binascii
 
+__all__ = ["binhex","hexbin","Error"]
+
 class Error(Exception):
     pass
 
index 343bd5da81b64200293e763b189adf2d56396d13..f521babc0e47334a952db6fab4d83433c5678a7d 100644 (file)
@@ -1,5 +1,6 @@
 """Bisection algorithms."""
 
+__all__ = ["bisect_right","insort_right","bisect_left","insort_left"]
 
 def insort_right(a, x, lo=0, hi=None):
     """Insert item x in list a, and keep it sorted assuming a is sorted.
index 1d15081133e28c1d87b00558541eb6a27a17091b..2efb1c496b42ce139ba05e395428b79bd62c0494 100644 (file)
@@ -10,6 +10,10 @@ set the first day of the week (0=Monday, 6=Sunday)."""
 # Import functions and variables from time module
 from time import localtime, mktime
 
+__all__ = ["error","setfirstweekday","firstweekday","isleap",
+           "leapdays","weekday","monthrange","monthcalendar",
+           "prmonth","month","prcal","calendar","timegm"]
+
 # Exception raised for bad input (with string parameter for details)
 error = ValueError
 
index 6d590517351f8abb7aabe715a52a0ced86f0b9a0..0e808a5acb97524871eca75212ef5a3f32c76d36 100755 (executable)
@@ -34,6 +34,8 @@ import rfc822
 import UserDict
 from StringIO import StringIO
 
+__all__ = ["MiniFieldStorage","FieldStorage","FormContentDict",
+           "SvFormContentDict","InterpFormContentDict","FormContent"]
 
 # Logging support
 # ===============
index 0a93cd3137703888e23242b9e5a16225d12ff235..a38691fc1e298e5185bdb9aa8f23baabd11618a7 100644 (file)
@@ -48,6 +48,8 @@ specifies whether or not chunks are aligned on 2-byte boundaries.  The
 default is 1, i.e. aligned.
 """
 
+__all__ = ["Chunk"]
+           
 class Chunk:
     def __init__(self, file, align = 1, bigendian = 1, inclheader = 0):
         import struct
index 7671573953257c047be8f1bc28c7ed44a6d716f3..f2894a94130f8d74c4b84704fd19bf50ff9252e7 100644 (file)
@@ -37,6 +37,8 @@ they automatically support Emacs-like command history and editing features.
 
 import string
 
+__all__ = ["Cmd"]
+
 PROMPT = '(Cmd) '
 IDENTCHARS = string.letters + string.digits + '_'
 
index 846cd0464234e9c1afff42d920d6d6a161c82da2..f9d8225d1d581496e8c27692e80af87f47667fdf 100644 (file)
@@ -10,6 +10,9 @@ import string
 import traceback
 from codeop import compile_command
 
+__all__ = ["InteractiveInterpreter","InteractiveConsole","interact",
+           "compile_command"]
+
 def softspace(file, newvalue):
     oldvalue = 0
     try:
index 003aa013e493037fb23de9be9fd418051343059c..21652b6146cb2f2417395c03f9417dfc53ed8038 100644 (file)
@@ -17,6 +17,9 @@ except ImportError,why:
     raise SystemError,\
           'Failed to load the builtin codecs: %s' % why
 
+__all__ = ["register","lookup","open","EncodedFile","BOM","BOM_BE",
+           "BOM_LE","BOM32_BE","BOM32_LE","BOM64_BE","BOM64_LE"]
+
 ### Constants
 
 #
index 080e00b87ebc1674c7df83e06a84370ac1026613..46926b58c4c246caf95a31665c1759a2e70ec0a1 100644 (file)
@@ -4,6 +4,8 @@ import sys
 import string
 import traceback
 
+__all__ = ["compile_command"]
+
 def compile_command(source, filename="<input>", symbol="single"):
     r"""Compile a command and determine whether it is incomplete.
 
index 4a62f9df987b2600f0a6eb5e52d14d4bb20fecb7..c2cdf57c9705459388573a7519e333f6187620da 100644 (file)
@@ -17,6 +17,8 @@ HSV: Hue, Saturation, Value
 # References:
 # XXX Where's the literature?
 
+__all__ = ["rgb_to_yiq","yiq_to_rgb","rgb_to_hls","hls_to_rgb",
+           "rgb_to_hsv","hsv_to_rgb"]
 
 # Some floating point constants
 
index a21460dce0aebeeaf6f5e6c2b2c97e471a54364d..cfbb541cfd61ac27993b7755f3e2126d81b136b7 100644 (file)
@@ -19,6 +19,8 @@ Encapsulates the basic operation:
  [Note:  it would be nice to add functions to interpret the exit status.]
 """
 
+__all__ = ["getstatusoutput","getoutput","getstatus"]
+
 # Module 'commands'
 #
 # Various tools for executing commands and looking at their output and status.
index e56c8b284e835c72417fe5579820242fefc08d5a..93ec7adc73d62c7673e83739d97b204e4295008a 100644 (file)
@@ -17,6 +17,8 @@ import stat
 import sys
 import py_compile
 
+__all__ = ["compile_dir","compile_path"]
+
 def compile_dir(dir, maxlevels=10, ddir=None, force=0):
     """Byte-compile all modules in the given directory tree.
 
index cdd2fdf8d38e88f543a34ee5aca55d224c78763f..123162cba1cee128ad25898f4e95b418a06974e8 100644 (file)
@@ -61,6 +61,8 @@ try:
 except ImportError:
     PyStringMap = None
 
+__all__ = ["Error","error","copy","deepcopy"]
+
 def copy(x):
     """Shallow copy operation on arbitrary Python objects.
 
index 6a8881d0a14af0a0bcbc219657bb3069d6c4e0ae..e4f0b3cfdac0e83b44a20809de9ce9c1be21cc24 100644 (file)
@@ -6,6 +6,8 @@ C, not for instances of user-defined classes.
 
 from types import ClassType as _ClassType
 
+__all__ = ["pickle","constructor"]
+
 dispatch_table = {}
 safe_constructors = {}
 
index ff51630bb338eac23ac4ee3a4f240be6e6563a83..4abd4f03f1e932689a416b323ce9dfd60d2b1c6a 100644 (file)
@@ -2,6 +2,8 @@
 
 import bsddb
 
+__all__ = ["error","open"]
+
 error = bsddb.error                     # Exported for anydbm
 
 def open(file, flag, mode=0666):
index 08b127a1afbc0e66602e45c288a2083fb4496b14..a999743a8d109b2a3c953064ebabd8a04a28de8a 100644 (file)
@@ -6,6 +6,8 @@ The annotate() routine appends slashes to directories."""
 
 import os
 
+__all__ = ["listdir","opendir","annotate"]
+
 cache = {}
 
 def listdir(path):
index 6ecefd34a4e90cc1a5a532217085c84857d21ef8..f01bf4fe103fcd1c8442bb4887370d962756f2c0 100644 (file)
@@ -4,6 +4,10 @@ import sys
 import string
 import types
 
+__all__ = ["dis","disassemble","distb","disco","opname","cmp_op",
+           "hasconst","hasname","hasjrel","hasjabs","haslocal",
+           "hascompare"]
+
 def dis(x=None):
     """Disassemble classes, methods, functions, or code.
 
index e0ff72bb34cf7411b9d632c8239fc1438cc128e5..782d623b275b42c0854489cf4bed96ec2c21691e 100644 (file)
@@ -11,6 +11,8 @@
 """
 import re,string,urlparse,urllib
 
+__all__ = ["RobotFileParser"]
+
 debug = 0
 
 def _debug(msg):
diff --git a/Lib/test/output/test___all__ b/Lib/test/output/test___all__
new file mode 100644 (file)
index 0000000..afdff38
--- /dev/null
@@ -0,0 +1 @@
+test___all__
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
new file mode 100644 (file)
index 0000000..f5e3630
--- /dev/null
@@ -0,0 +1,55 @@
+
+from test_support import verify, verbose, TestFailed
+import sys
+
+def check_all(_modname):
+    exec "import %s" % _modname
+    verify(hasattr(sys.modules[_modname],"__all__"),
+           "%s has no __all__ attribute" % _modname)
+    exec "del %s" % _modname
+    exec "from %s import *" % _modname
+    
+    _keys = locals().keys()
+    _keys.remove("_modname")
+    _keys.sort()
+    all = list(sys.modules[_modname].__all__) # in case it's a tuple
+    all.sort()
+    verify(_keys==all,"%s != %s" % (_keys,all))
+
+check_all("BaseHTTPServer")
+check_all("Bastion")
+check_all("CGIHTTPServer")
+check_all("ConfigParser")
+check_all("Cookie")
+check_all("MimeWriter")
+check_all("Queue")
+check_all("SimpleHTTPServer")
+check_all("SocketServer")
+check_all("StringIO")
+check_all("UserDict")
+check_all("UserList")
+check_all("UserString")
+check_all("aifc")
+check_all("anydbm")
+check_all("atexit")
+check_all("audiodev")
+check_all("base64")
+check_all("bdb")
+check_all("binhex")
+check_all("bisect")
+check_all("calendar")
+check_all("cgi")
+check_all("chunk")
+check_all("cmd")
+check_all("code")
+check_all("codecs")
+check_all("codeop")
+check_all("colorsys")
+check_all("commands")
+check_all("compileall")
+check_all("copy")
+check_all("copy_reg")
+check_all("dbhash")
+check_all("dircache")
+check_all("dis")
+check_all("robotparser")