Commit d60022d2 authored by Skip Montanaro's avatar Skip Montanaro

added several more __all__ lists

parent f7f89947
...@@ -30,6 +30,8 @@ seekable stream object. ...@@ -30,6 +30,8 @@ seekable stream object.
import sys import sys
import string import string
__all__ = ["MultiFile","Error"]
class Error(Exception): class Error(Exception):
pass pass
......
...@@ -12,6 +12,8 @@ Of course, no multi-threading is implied -- hence the funny interface ...@@ -12,6 +12,8 @@ Of course, no multi-threading is implied -- hence the funny interface
for lock, where a function is called once the lock is aquired. for lock, where a function is called once the lock is aquired.
""" """
__all__ = ["mutex"]
class mutex: class mutex:
def __init__(self): def __init__(self):
"""Create a new mutex -- initially unlocked.""" """Create a new mutex -- initially unlocked."""
......
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
import os, shlex import os, shlex
__all__ = ["netrc"]
class netrc: class netrc:
def __init__(self, file=None): def __init__(self, file=None):
if not file: if not file:
......
...@@ -33,7 +33,10 @@ import re ...@@ -33,7 +33,10 @@ import re
import socket import socket
import string import string
__all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError",
"NNTPPermanentError","NNTPProtocolError","NNTPDataError",
"error_reply","error_temp","error_perm","error_proto",
"error_data",]
# Exceptions raised when an error or invalid response is received # Exceptions raised when an error or invalid response is received
class NNTPError(Exception): class NNTPError(Exception):
......
...@@ -8,6 +8,10 @@ module as os.path. ...@@ -8,6 +8,10 @@ module as os.path.
import os import os
import stat import stat
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","islink","exists","isdir","isfile","ismount",
"walk","expanduser","expandvars","normpath","abspath","splitunc"]
# Normalize the case of a pathname and map slashes to backslashes. # Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done # Other normalizations (such as optimizing '../' away) are not done
......
"""Convert a NT pathname to a file URL and vice versa.""" """Convert a NT pathname to a file URL and vice versa."""
__all__ = ["url2pathname"]
def url2pathname(url): def url2pathname(url):
r"""Convert a URL to a DOS path. r"""Convert a URL to a DOS path.
......
...@@ -19,12 +19,22 @@ and opendir), and leave all pathname manipulation to os.path ...@@ -19,12 +19,22 @@ and opendir), and leave all pathname manipulation to os.path
(e.g., split and join). (e.g., split and join).
""" """
#'
import sys import sys
_names = sys.builtin_module_names _names = sys.builtin_module_names
altsep = None altsep = None
__all__ = []
def _get_exports_list(module):
try:
return list(module.__all__)
except AttributeError:
return [n for n in dir(module) if n[0] != '_']
if 'posix' in _names: if 'posix' in _names:
name = 'posix' name = 'posix'
linesep = '\n' linesep = '\n'
...@@ -38,6 +48,11 @@ if 'posix' in _names: ...@@ -38,6 +48,11 @@ if 'posix' in _names:
import posixpath import posixpath
path = posixpath path = posixpath
del posixpath del posixpath
import posix
__all__.extend(_get_exports_list(posix))
del posix
elif 'nt' in _names: elif 'nt' in _names:
name = 'nt' name = 'nt'
linesep = '\r\n' linesep = '\r\n'
...@@ -52,6 +67,11 @@ elif 'nt' in _names: ...@@ -52,6 +67,11 @@ elif 'nt' in _names:
import ntpath import ntpath
path = ntpath path = ntpath
del ntpath del ntpath
import nt
__all__.extend(_get_exports_list(nt))
del nt
elif 'dos' in _names: elif 'dos' in _names:
name = 'dos' name = 'dos'
linesep = '\r\n' linesep = '\r\n'
...@@ -65,6 +85,11 @@ elif 'dos' in _names: ...@@ -65,6 +85,11 @@ elif 'dos' in _names:
import dospath import dospath
path = dospath path = dospath
del dospath del dospath
import dos
__all__.extend(_get_exports_list(dos))
del dos
elif 'os2' in _names: elif 'os2' in _names:
name = 'os2' name = 'os2'
linesep = '\r\n' linesep = '\r\n'
...@@ -78,6 +103,11 @@ elif 'os2' in _names: ...@@ -78,6 +103,11 @@ elif 'os2' in _names:
import ntpath import ntpath
path = ntpath path = ntpath
del ntpath del ntpath
import os2
__all__.extend(_get_exports_list(os2))
del os2
elif 'mac' in _names: elif 'mac' in _names:
name = 'mac' name = 'mac'
linesep = '\r' linesep = '\r'
...@@ -91,6 +121,11 @@ elif 'mac' in _names: ...@@ -91,6 +121,11 @@ elif 'mac' in _names:
import macpath import macpath
path = macpath path = macpath
del macpath del macpath
import mac
__all__.extend(_get_exports_list(mac))
del mac
elif 'ce' in _names: elif 'ce' in _names:
name = 'ce' name = 'ce'
linesep = '\r\n' linesep = '\r\n'
...@@ -106,13 +141,22 @@ elif 'ce' in _names: ...@@ -106,13 +141,22 @@ elif 'ce' in _names:
import ntpath import ntpath
path = ntpath path = ntpath
del ntpath del ntpath
import ce
__all__.extend(_get_exports_list(ce))
del ce
else: else:
raise ImportError, 'no os specific module found' raise ImportError, 'no os specific module found'
__all__.append("path")
del _names del _names
sys.modules['os.path'] = path sys.modules['os.path'] = path
#'
# Super directory utilities. # Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his) # (Inspired by Eric Raymond; the doc strings are mostly his)
...@@ -180,6 +224,8 @@ def renames(old, new): ...@@ -180,6 +224,8 @@ def renames(old, new):
except error: except error:
pass pass
__all__.extend(["makedirs", "removedirs", "renames"])
# Make sure os.environ exists, at least # Make sure os.environ exists, at least
try: try:
environ environ
...@@ -234,6 +280,8 @@ def execvpe(file, args, env): ...@@ -234,6 +280,8 @@ def execvpe(file, args, env):
args may be a list or tuple of strings. """ args may be a list or tuple of strings. """
_execvpe(file, args, env) _execvpe(file, args, env)
__all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
_notfound = None _notfound = None
def _execvpe(file, args, env=None): def _execvpe(file, args, env=None):
if env is not None: if env is not None:
...@@ -319,6 +367,7 @@ def getenv(key, default=None): ...@@ -319,6 +367,7 @@ def getenv(key, default=None):
The optional second argument can specify an alternate default.""" The optional second argument can specify an alternate default."""
return environ.get(key, default) return environ.get(key, default)
__all__.append("getenv")
def _exists(name): def _exists(name):
try: try:
...@@ -454,6 +503,10 @@ otherwise return -SIG, where SIG is the signal that killed it. """ ...@@ -454,6 +503,10 @@ otherwise return -SIG, where SIG is the signal that killed it. """
return spawnvpe(mode, file, args[:-1], env) return spawnvpe(mode, file, args[:-1], env)
__all__.extend(["spawnlp","spawnlpe","spawnv", "spawnve","spawnvp",
"spawnvpe","spawnl","spawnle",])
# Supply popen2 etc. (for Unix) # Supply popen2 etc. (for Unix)
if _exists("fork"): if _exists("fork"):
if not _exists("popen2"): if not _exists("popen2"):
...@@ -461,15 +514,18 @@ if _exists("fork"): ...@@ -461,15 +514,18 @@ if _exists("fork"):
import popen2 import popen2
stdout, stdin = popen2.popen2(cmd, bufsize) stdout, stdin = popen2.popen2(cmd, bufsize)
return stdin, stdout return stdin, stdout
__all__.append("popen2")
if not _exists("popen3"): if not _exists("popen3"):
def popen3(cmd, mode="t", bufsize=-1): def popen3(cmd, mode="t", bufsize=-1):
import popen2 import popen2
stdout, stdin, stderr = popen2.popen3(cmd, bufsize) stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
return stdin, stdout, stderr return stdin, stdout, stderr
__all__.append("popen3")
if not _exists("popen4"): if not _exists("popen4"):
def popen4(cmd, mode="t", bufsize=-1): def popen4(cmd, mode="t", bufsize=-1):
import popen2 import popen2
stdout, stdin = popen2.popen4(cmd, bufsize) stdout, stdin = popen2.popen4(cmd, bufsize)
return stdin, stdout return stdin, stdout
__all__.append("popen4")
...@@ -87,4 +87,11 @@ check_all("mhlib") ...@@ -87,4 +87,11 @@ check_all("mhlib")
check_all("mimetools") check_all("mimetools")
check_all("mimetypes") check_all("mimetypes")
check_all("mimify") check_all("mimify")
check_all("multifile")
check_all("mutex")
check_all("netrc")
check_all("nntplib")
check_all("ntpath")
check_all("nturl2path")
check_all("os")
check_all("robotparser") check_all("robotparser")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment