From 0de65807e6bdc5254f5a7e99b2f39adeea6b883b Mon Sep 17 00:00:00 2001 From: Skip Montanaro Date: Thu, 15 Feb 2001 22:15:14 +0000 Subject: bunch more __all__ lists also modified check_all function to suppress all warnings since they aren't relevant to what this test is doing (allows quiet checking of regsub, for instance) --- Lib/pre.py | 4 +++- Lib/random.py | 6 ++++++ Lib/re.py | 2 ++ Lib/reconvert.py | 2 ++ Lib/regex_syntax.py | 6 ++++++ Lib/regsub.py | 1 + Lib/repr.py | 2 ++ Lib/rexec.py | 1 + Lib/rfc822.py | 1 + Lib/rlcompleter.py | 2 ++ Lib/sched.py | 2 ++ Lib/sgmllib.py | 1 + Lib/shelve.py | 1 + Lib/shlex.py | 2 ++ Lib/shutil.py | 2 ++ Lib/smtpd.py | 1 + Lib/smtplib.py | 5 +++++ Lib/sndhdr.py | 1 + Lib/socket.py | 5 +++++ Lib/sre.py | 4 ++++ Lib/sre_compile.py | 2 ++ Lib/sre_constants.py | 6 ++++++ Lib/sre_parse.py | 3 +++ Lib/stat.py | 6 ++++++ Lib/statcache.py | 3 +++ Lib/statvfs.py | 6 ++++++ Lib/string.py | 6 ++++++ Lib/test/test___all__.py | 29 +++++++++++++++++++++++++++++ 28 files changed, 111 insertions(+), 1 deletion(-) diff --git a/Lib/pre.py b/Lib/pre.py index 30f0491..a3188fe 100644 --- a/Lib/pre.py +++ b/Lib/pre.py @@ -87,7 +87,9 @@ This module also defines an exception 'error'. import sys from pcre import * -__all__ = ["match","search","sub","subn","split","findall","escape","compile"] +__all__ = ["match","search","sub","subn","split","findall","escape","compile", + "I","L","M","S","X","IGNORECASE","LOCALE","MULTILINE","DOTALL", + "VERBOSE","error"] # # First, the public part of the interface: diff --git a/Lib/random.py b/Lib/random.py index f470402..efaf7d6 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -76,6 +76,12 @@ used to "move backward in time": from math import log as _log, exp as _exp, pi as _pi, e as _e from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin +__all__ = ["Random","seed","random","uniform","randint","choice", + "randrange","shuffle","normalvariate","lognormvariate", + "cunifvariate","expovariate","vonmisesvariate","gammavariate", + "stdgamma","gauss","betavariate","paretovariate","weibullvariate", + "getstate","setstate","jumpahead","whseed"] + def _verify(name, expected): computed = eval(name) if abs(computed - expected) > 1e-7: diff --git a/Lib/re.py b/Lib/re.py index 6d75bb9..b125b20 100644 --- a/Lib/re.py +++ b/Lib/re.py @@ -26,7 +26,9 @@ engine = "sre" if engine == "sre": # New unicode-aware engine from sre import * + from sre import __all__ else: # Old 1.5.2 engine. This one supports 8-bit strings only, # and will be removed in 2.0 final. from pre import * + from pre import __all__ diff --git a/Lib/reconvert.py b/Lib/reconvert.py index 840c5d9..59708da 100755 --- a/Lib/reconvert.py +++ b/Lib/reconvert.py @@ -63,6 +63,8 @@ XXX To be done... import regex from regex_syntax import * # RE_* +__all__ = ["convert","quote"] + # Default translation table mastertable = { r'\<': r'\b', diff --git a/Lib/regex_syntax.py b/Lib/regex_syntax.py index b0a0dbf..421ffd9 100644 --- a/Lib/regex_syntax.py +++ b/Lib/regex_syntax.py @@ -51,3 +51,9 @@ RE_SYNTAX_GREP = (RE_BK_PLUS_QM | RE_NEWLINE_OR) RE_SYNTAX_EMACS = 0 # (Python's obsolete "regexp" module used a syntax similar to awk.) + +__all__ = locals().keys() +for _i in range(len(__all__)-1,-1,-1): + if __all__[_i][0] == "_": + del __all__[_i] +del _i diff --git a/Lib/regsub.py b/Lib/regsub.py index de833d5..a86819f 100644 --- a/Lib/regsub.py +++ b/Lib/regsub.py @@ -19,6 +19,7 @@ warnings.filterwarnings("ignore", "", DeprecationWarning, __name__) import regex +__all__ = ["sub","gsub","split","splitx","capwords"] # Replace first occurrence of pattern pat in string str by replacement # repl. If the pattern isn't found, the string is returned unchanged. diff --git a/Lib/repr.py b/Lib/repr.py index 9f7ed86..c2d3ed5 100644 --- a/Lib/repr.py +++ b/Lib/repr.py @@ -1,5 +1,7 @@ """Redo the `...` (representation) but with limits on most sizes.""" +__all__ = ["Repr","repr"] + class Repr: def __init__(self): self.maxlevel = 6 diff --git a/Lib/rexec.py b/Lib/rexec.py index 57ea599..6a7c207 100644 --- a/Lib/rexec.py +++ b/Lib/rexec.py @@ -23,6 +23,7 @@ import __builtin__ import os import ihooks +__all__ = ["RExec"] class FileBase: diff --git a/Lib/rfc822.py b/Lib/rfc822.py index 89de69a..101013d 100644 --- a/Lib/rfc822.py +++ b/Lib/rfc822.py @@ -59,6 +59,7 @@ There are also some utility functions here. import time +__all__ = ["Message","AddressList","parsedate","parsedate_tz","mktime_tz"] _blanklines = ('\r\n', '\n') # Optimization for islast() diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py index 8cd21ed..4f05ba3 100644 --- a/Lib/rlcompleter.py +++ b/Lib/rlcompleter.py @@ -43,6 +43,8 @@ import readline import __builtin__ import __main__ +__all__ = ["Completer"] + class Completer: def complete(self, text, state): diff --git a/Lib/sched.py b/Lib/sched.py index fc5bd56..ba5f33a 100644 --- a/Lib/sched.py +++ b/Lib/sched.py @@ -30,6 +30,8 @@ Parameterless functions or methods cannot be used, however. import bisect +__all__ = ["scheduler"] + class scheduler: def __init__(self, timefunc, delayfunc): """Initialize a new instance, passing the time and delay diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py index 501fe36..30acafd 100644 --- a/Lib/sgmllib.py +++ b/Lib/sgmllib.py @@ -11,6 +11,7 @@ import re import string +__all__ = ["SGMLParser"] # Regular expressions used for parsing diff --git a/Lib/shelve.py b/Lib/shelve.py index 952df16..fa2a136 100644 --- a/Lib/shelve.py +++ b/Lib/shelve.py @@ -40,6 +40,7 @@ try: except ImportError: from StringIO import StringIO +__all__ = ["Shelf","BsdDbShelf","DbfilenameShelf","open"] class Shelf: """Base class for shelf implementations. diff --git a/Lib/shlex.py b/Lib/shlex.py index d90a0b9..97b8f2e 100644 --- a/Lib/shlex.py +++ b/Lib/shlex.py @@ -7,6 +7,8 @@ import os.path import sys +__all__ = ["shlex"] + class shlex: "A lexical analyzer class for simple shell-like syntaxes." def __init__(self, instream=None, infile=None): diff --git a/Lib/shutil.py b/Lib/shutil.py index e053917..6e3a276 100644 --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -8,6 +8,8 @@ import os import sys import stat +__all__ = ["copyfileobj","copyfile","copymode","copystat","copy","copy2", + "copytree","rmtree"] def copyfileobj(fsrc, fdst, length=16*1024): """copy data from file-like object fsrc to file-like object fdst""" diff --git a/Lib/smtpd.py b/Lib/smtpd.py index 3d94b97..c04c499 100755 --- a/Lib/smtpd.py +++ b/Lib/smtpd.py @@ -75,6 +75,7 @@ import socket import asyncore import asynchat +__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"] program = sys.argv[0] __version__ = 'Python SMTP proxy version 0.2' diff --git a/Lib/smtplib.py b/Lib/smtplib.py index 1af4068..f1e4a27 100755 --- a/Lib/smtplib.py +++ b/Lib/smtplib.py @@ -44,6 +44,11 @@ import re import rfc822 import types +__all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException", + "SMTPSenderRefused","SMTPRecipientsRefused","SMTPDataError", + "SMTPConnectError","SMTPHeloError","quoteaddr","quotedata", + "SMTP"] + SMTP_PORT = 25 CRLF="\r\n" diff --git a/Lib/sndhdr.py b/Lib/sndhdr.py index 61cd5b3..29f0760 100644 --- a/Lib/sndhdr.py +++ b/Lib/sndhdr.py @@ -30,6 +30,7 @@ explicitly given directories. # The file structure is top-down except that the test program and its # subroutine come last. +__all__ = ["what","whathdr"] def what(filename): """Guess the type of a sound file""" diff --git a/Lib/socket.py b/Lib/socket.py index bff5514..c928700 100644 --- a/Lib/socket.py +++ b/Lib/socket.py @@ -42,6 +42,11 @@ from _socket import * import os, sys +__all__ = ["getfqdn"] +import _socket +__all__.extend(os._get_exports_list(_socket)) +del _socket + if (sys.platform.lower().startswith("win") or (hasattr(os, 'uname') and os.uname()[0] == "BeOS")): diff --git a/Lib/sre.py b/Lib/sre.py index 4533354..061d8e8 100644 --- a/Lib/sre.py +++ b/Lib/sre.py @@ -17,6 +17,10 @@ import sre_compile import sre_parse +__all__ = ["match","search","sub","subn","split","findall","compile", + "purge","template","escape","I","L","M","S","X","U","IGNORECASE", + "LOCALE","MULTILINE","DOTALL","VERBOSE","UNICODE","error"] + # flags I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index ab2a2cc..18dee88 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -12,6 +12,8 @@ import _sre from sre_constants import * +__all__ = ["compile"] + assert _sre.MAGIC == MAGIC, "SRE module mismatch" MAXCODE = 65535 diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py index 7aedab1..e14fa17 100644 --- a/Lib/sre_constants.py +++ b/Lib/sre_constants.py @@ -194,6 +194,12 @@ SRE_INFO_PREFIX = 1 # has prefix SRE_INFO_LITERAL = 2 # entire pattern is literal (given by prefix) SRE_INFO_CHARSET = 4 # pattern starts with character from given set +__all__ = locals().keys() +for _i in range(len(__all__)-1,-1,-1): + if __all__[_i][0] == "_": + del __all__[_i] +del _i + if __name__ == "__main__": def dump(f, d, prefix): items = d.items() diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py index 635605d..fc3c492 100644 --- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -14,6 +14,9 @@ import sys from sre_constants import * +__all__ = ["Pattern","SubPattern","Tokenizer","parse","parse_template", + "expand_template"] + SPECIAL_CHARS = ".\\[{()*+?^$|" REPEAT_CHARS = "*+?{" diff --git a/Lib/stat.py b/Lib/stat.py index 70750d8..f0ffabe 100644 --- a/Lib/stat.py +++ b/Lib/stat.py @@ -84,3 +84,9 @@ S_IRWXO = 00007 S_IROTH = 00004 S_IWOTH = 00002 S_IXOTH = 00001 + +__all__ = locals().keys() +for _i in range(len(__all__)-1,-1,-1): + if __all__[_i][0] == "_": + del __all__[_i] +del _i diff --git a/Lib/statcache.py b/Lib/statcache.py index 056ec40..3123418 100644 --- a/Lib/statcache.py +++ b/Lib/statcache.py @@ -6,6 +6,9 @@ There are functions to reset the cache or to selectively remove items. import os as _os from stat import * +__all__ = ["stat","reset","forget","forget_prefix","forget_dir", + "forget_except_prefix","isdir"] + # The cache. Keys are pathnames, values are os.stat outcomes. # Remember that multiple threads may be calling this! So, e.g., that # cache.has_key(path) returns 1 doesn't mean the cache will still contain diff --git a/Lib/statvfs.py b/Lib/statvfs.py index 06a323f..b3d8e97 100644 --- a/Lib/statvfs.py +++ b/Lib/statvfs.py @@ -13,3 +13,9 @@ F_FFREE = 6 # Total number of free file nodes F_FAVAIL = 7 # Free nodes available to non-superuser F_FLAG = 8 # Flags (see your local statvfs man page) F_NAMEMAX = 9 # Maximum file name length + +__all__ = locals().keys() +for _i in range(len(__all__)-1,-1,-1): + if __all__[_i][0] == "_": + del __all__[_i] +del _i diff --git a/Lib/string.py b/Lib/string.py index 913d980..45fe977 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -379,3 +379,9 @@ try: letters = lowercase + uppercase except ImportError: pass # Use the original versions + +__all__ = locals().keys() +for _i in range(len(__all__)-1,-1,-1): + if __all__[_i][0] == "_": + del __all__[_i] +del _i diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 875d99d..b2ea498 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -2,6 +2,9 @@ from test_support import verify, verbose import sys def check_all(modname): + import warnings + warnings.filterwarnings("ignore", "", DeprecationWarning, modname) + names = {} try: exec "import %s" % modname in names @@ -124,4 +127,30 @@ check_all("pty") check_all("py_compile") check_all("pyclbr") check_all("quopri") +check_all("random") +check_all("re") +check_all("reconvert") +check_all("regex_syntax") +check_all("regsub") +check_all("repr") +check_all("rexec") +check_all("rfc822") +check_all("rlcompleter") check_all("robotparser") +check_all("sched") +check_all("sgmllib") +check_all("shelve") +check_all("shlex") +check_all("shutil") +check_all("smtpd") +check_all("smtplib") +check_all("sndhdr") +check_all("socket") +check_all("sre") +check_all("sre_compile") +check_all("sre_constants") +check_all("sre_parse") +check_all("stat") +check_all("stat_cache") +check_all("statvfs") +check_all("string") -- cgit v0.12