diff options
author | Ka-Ping Yee <ping@zesty.ca> | 2001-03-01 19:31:25 (GMT) |
---|---|---|
committer | Ka-Ping Yee <ping@zesty.ca> | 2001-03-01 19:31:25 (GMT) |
commit | d977e35dd036ddab7aa785a5a9137bc4dd010a13 (patch) | |
tree | 30c2ff6827842571e72c40b9306237b48da9cd4d /Lib/pydoc.py | |
parent | 8c011580ffcd21e2dedfe0d332d61373dbfe127f (diff) | |
download | cpython-d977e35dd036ddab7aa785a5a9137bc4dd010a13.zip cpython-d977e35dd036ddab7aa785a5a9137bc4dd010a13.tar.gz cpython-d977e35dd036ddab7aa785a5a9137bc4dd010a13.tar.bz2 |
Also accept .so as an extension for module files.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index ee08e3b..8d498b7 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -127,14 +127,10 @@ def stripid(text): def modulename(path): """Return the Python module name for a given path, or None.""" filename = os.path.basename(path) - if lower(filename[-3:]) == '.py': - return filename[:-3] - elif lower(filename[-4:]) in ['.pyc', '.pyd', '.pyo']: - return filename[:-4] - elif lower(filename[-11:]) == 'module.so': - return filename[:-11] - elif lower(filename[-13:]) == 'module.so.1': - return filename[:-13] + for ending in ['.py', '.pyc', '.pyd', '.pyo', + 'module.so', 'module.so.1', '.so']: + if len(filename) > len(ending) and filename[-len(ending):] == ending: + return filename[:-len(ending)] class DocImportError(Exception): """Class for errors while trying to import something to document it.""" |