diff options
-rw-r--r-- | Lib/CGIHTTPServer.py | 2 | ||||
-rw-r--r-- | Lib/compileall.py | 5 | ||||
-rw-r--r-- | Lib/dircache.py | 2 | ||||
-rw-r--r-- | Lib/dospath.py | 13 | ||||
-rw-r--r-- | Lib/filecmp.py | 10 | ||||
-rw-r--r-- | Lib/imputil.py | 4 | ||||
-rw-r--r-- | Lib/linecache.py | 5 | ||||
-rw-r--r-- | Lib/macpath.py | 13 | ||||
-rw-r--r-- | Lib/mhlib.py | 7 | ||||
-rw-r--r-- | Lib/ntpath.py | 13 | ||||
-rw-r--r-- | Lib/os2emxpath.py | 13 | ||||
-rw-r--r-- | Lib/posixpath.py | 27 | ||||
-rw-r--r-- | Lib/pstats.py | 2 | ||||
-rw-r--r-- | Lib/py_compile.py | 4 | ||||
-rwxr-xr-x | Lib/pydoc.py | 8 | ||||
-rw-r--r-- | Lib/statcache.py | 2 | ||||
-rwxr-xr-x | Lib/uu.py | 2 | ||||
-rw-r--r-- | Lib/zipfile.py | 6 |
18 files changed, 59 insertions, 79 deletions
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py index 56dee47..fbd82c9 100644 --- a/Lib/CGIHTTPServer.py +++ b/Lib/CGIHTTPServer.py @@ -308,7 +308,7 @@ def executable(path): st = os.stat(path) except os.error: return False - return st[0] & 0111 != 0 + return st.st_mode & 0111 != 0 def test(HandlerClass = CGIHTTPRequestHandler, diff --git a/Lib/compileall.py b/Lib/compileall.py index 2fbc2bc..8397c96 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -13,7 +13,6 @@ See module py_compile for details of the actual byte-compilation. """ import os -import stat import sys import py_compile @@ -56,8 +55,8 @@ def compile_dir(dir, maxlevels=10, ddir=None, head, tail = name[:-3], name[-3:] if tail == '.py': cfile = fullname + (__debug__ and 'c' or 'o') - ftime = os.stat(fullname)[stat.ST_MTIME] - try: ctime = os.stat(cfile)[stat.ST_MTIME] + ftime = os.stat(fullname).st_mtime + try: ctime = os.stat(cfile).st_mtime except os.error: ctime = 0 if (ctime > ftime) and not force: continue if not quiet: diff --git a/Lib/dircache.py b/Lib/dircache.py index be2f314..e18c7c3 100644 --- a/Lib/dircache.py +++ b/Lib/dircache.py @@ -23,7 +23,7 @@ def listdir(path): except KeyError: cached_mtime, list = -1, [] try: - mtime = os.stat(path)[8] + mtime = os.stat(path).st_mtime except os.error: return [] if mtime != cached_mtime: diff --git a/Lib/dospath.py b/Lib/dospath.py index 33d481c..f613a63 100644 --- a/Lib/dospath.py +++ b/Lib/dospath.py @@ -123,19 +123,16 @@ def commonprefix(m): def getsize(filename): """Return the size of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_SIZE] + return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_MTIME] + return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_ATIME] + return os.stat(filename).st_atime def islink(path): """Is a path a symbolic link? @@ -162,7 +159,7 @@ def isdir(path): st = os.stat(path) except os.error: return False - return stat.S_ISDIR(st[stat.ST_MODE]) + return stat.S_ISDIR(st.st_mode) def isfile(path): @@ -172,7 +169,7 @@ def isfile(path): st = os.stat(path) except os.error: return False - return stat.S_ISREG(st[stat.ST_MODE]) + return stat.S_ISREG(st.st_mode) def ismount(path): diff --git a/Lib/filecmp.py b/Lib/filecmp.py index f0e6d47..9aee1b3 100644 --- a/Lib/filecmp.py +++ b/Lib/filecmp.py @@ -64,9 +64,9 @@ def cmp(f1, f2, shallow=1, use_statcache=0): return outcome def _sig(st): - return (stat.S_IFMT(st[stat.ST_MODE]), - st[stat.ST_SIZE], - st[stat.ST_MTIME]) + return (stat.S_IFMT(st.st_mode), + st.st_size, + st.st_mtime) def _do_cmp(f1, f2): bufsize = BUFSIZE @@ -199,8 +199,8 @@ class dircmp: ok = 0 if ok: - a_type = stat.S_IFMT(a_stat[stat.ST_MODE]) - b_type = stat.S_IFMT(b_stat[stat.ST_MODE]) + a_type = stat.S_IFMT(a_stat.st_mode) + b_type = stat.S_IFMT(b_stat.st_mode) if a_type != b_type: self.common_funny.append(x) elif stat.S_ISDIR(a_type): diff --git a/Lib/imputil.py b/Lib/imputil.py index d83b16e..5d462f1 100644 --- a/Lib/imputil.py +++ b/Lib/imputil.py @@ -484,7 +484,7 @@ def _os_path_isdir(pathname): s = _os_stat(pathname) except OSError: return None - return (s[0] & 0170000) == 0040000 + return (s.st_mode & 0170000) == 0040000 def _timestamp(pathname): "Return the file modification time as a Long." @@ -492,7 +492,7 @@ def _timestamp(pathname): s = _os_stat(pathname) except OSError: return None - return long(s[8]) + return long(s.st_mtime) ###################################################################### diff --git a/Lib/linecache.py b/Lib/linecache.py index 7a0859d..56b686e 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -7,7 +7,6 @@ that name. import sys import os -from stat import * __all__ = ["getline","clearcache","checkcache"] @@ -52,7 +51,7 @@ def checkcache(): except os.error: del cache[filename] continue - if size != stat[ST_SIZE] or mtime != stat[ST_MTIME]: + if size != stat.st_size or mtime != stat.st_mtime: del cache[filename] @@ -96,6 +95,6 @@ def updatecache(filename): except IOError, msg: ## print '*** Cannot open', fullname, ':', msg return [] - size, mtime = stat[ST_SIZE], stat[ST_MTIME] + size, mtime = stat.st_size, stat.st_mtime cache[filename] = size, mtime, lines, fullname return lines diff --git a/Lib/macpath.py b/Lib/macpath.py index ad87cb1..8546892 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -100,25 +100,22 @@ def isdir(s): st = os.stat(s) except os.error: return 0 - return S_ISDIR(st[ST_MODE]) + return S_ISDIR(st.st_mode) # Get size, mtime, atime of files. def getsize(filename): """Return the size of a file, reported by os.stat().""" - st = os.stat(filename) - return st[ST_SIZE] + return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[ST_MTIME] + return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[ST_ATIME] + return os.stat(filename).st_atime def islink(s): @@ -138,7 +135,7 @@ def isfile(s): st = os.stat(s) except os.error: return False - return S_ISREG(st[ST_MODE]) + return S_ISREG(st.st_mode) def exists(s): diff --git a/Lib/mhlib.py b/Lib/mhlib.py index 912f001..feb554e 100644 --- a/Lib/mhlib.py +++ b/Lib/mhlib.py @@ -74,7 +74,6 @@ FOLDER_PROTECT = 0700 import os import sys -from stat import ST_NLINK import re import mimetools import multifile @@ -155,8 +154,7 @@ class MH: fullname = os.path.join(self.path, name) # Get the link count so we can avoid listing folders # that have no subfolders. - st = os.stat(fullname) - nlinks = st[ST_NLINK] + nlinks = os.stat(fullname).st_nlink if nlinks <= 2: return [] subfolders = [] @@ -183,8 +181,7 @@ class MH: fullname = os.path.join(self.path, name) # Get the link count so we can avoid listing folders # that have no subfolders. - st = os.stat(fullname) - nlinks = st[ST_NLINK] + nlinks = os.stat(fullname).st_nlink if nlinks <= 2: return [] subfolders = [] diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 7b758d0..d376065 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -216,18 +216,15 @@ def commonprefix(m): def getsize(filename): """Return the size of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_SIZE] + return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_MTIME] + return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_ATIME] + return os.stat(filename).st_atime # Is a path a symbolic link? @@ -260,7 +257,7 @@ def isdir(path): st = os.stat(path) except os.error: return False - return stat.S_ISDIR(st[stat.ST_MODE]) + return stat.S_ISDIR(st.st_mode) # Is a path a regular file? @@ -273,7 +270,7 @@ def isfile(path): st = os.stat(path) except os.error: return False - return stat.S_ISREG(st[stat.ST_MODE]) + return stat.S_ISREG(st.st_mode) # Is a path a mount point? Either a root (with or without drive letter) diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py index 62d5d40..a539a82 100644 --- a/Lib/os2emxpath.py +++ b/Lib/os2emxpath.py @@ -175,18 +175,15 @@ def commonprefix(m): def getsize(filename): """Return the size of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_SIZE] + return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_MTIME] + return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat()""" - st = os.stat(filename) - return st[stat.ST_ATIME] + return os.stat(filename).st_atime # Is a path a symbolic link? @@ -217,7 +214,7 @@ def isdir(path): st = os.stat(path) except os.error: return False - return stat.S_ISDIR(st[stat.ST_MODE]) + return stat.S_ISDIR(st.st_mode) # Is a path a regular file? @@ -230,7 +227,7 @@ def isfile(path): st = os.stat(path) except os.error: return False - return stat.S_ISREG(st[stat.ST_MODE]) + return stat.S_ISREG(st.st_mode) # Is a path a mount point? Either a root (with or without drive letter) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index a81f508..1f84a43 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -136,18 +136,15 @@ def commonprefix(m): def getsize(filename): """Return the size of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_SIZE] + return os.stat(filename).st_size def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_MTIME] + return os.stat(filename).st_mtime def getatime(filename): """Return the last access time of a file, reported by os.stat().""" - st = os.stat(filename) - return st[stat.ST_ATIME] + return os.stat(filename).st_atime # Is a path a symbolic link? @@ -159,7 +156,7 @@ def islink(path): st = os.lstat(path) except (os.error, AttributeError): return False - return stat.S_ISLNK(st[stat.ST_MODE]) + return stat.S_ISLNK(st.st_mode) # Does a path exist? @@ -184,7 +181,7 @@ def isdir(path): st = os.stat(path) except os.error: return False - return stat.S_ISDIR(st[stat.ST_MODE]) + return stat.S_ISDIR(st.st_mode) # Is a path a regular file? @@ -197,7 +194,7 @@ def isfile(path): st = os.stat(path) except os.error: return False - return stat.S_ISREG(st[stat.ST_MODE]) + return stat.S_ISREG(st.st_mode) # Are two filenames really pointing to the same file? @@ -224,8 +221,8 @@ def sameopenfile(fp1, fp2): def samestat(s1, s2): """Test whether two stat buffers reference the same file""" - return s1[stat.ST_INO] == s2[stat.ST_INO] and \ - s1[stat.ST_DEV] == s2[stat.ST_DEV] + return s1.st_ino == s2.st_ino and \ + s1.st_dev == s2.st_dev # Is a path a mount point? @@ -238,12 +235,12 @@ def ismount(path): s2 = os.stat(join(path, '..')) except os.error: return False # It doesn't exist -- so not a mount point :-) - dev1 = s1[stat.ST_DEV] - dev2 = s2[stat.ST_DEV] + dev1 = s1.st_dev + dev2 = s2.st_dev if dev1 != dev2: return True # path/.. on a different device as path - ino1 = s1[stat.ST_INO] - ino2 = s2[stat.ST_INO] + ino1 = s1.st_ino + ino2 = s2.st_ino if ino1 == ino2: return True # path/.. is the same i-node as path return False diff --git a/Lib/pstats.py b/Lib/pstats.py index c5d8c38..384db52 100644 --- a/Lib/pstats.py +++ b/Lib/pstats.py @@ -108,7 +108,7 @@ class Stats: f.close() try: file_stats = os.stat(arg) - arg = time.ctime(file_stats[8]) + " " + arg + arg = time.ctime(file_stats.st_mtime) + " " + arg except: # in case this is not unix pass self.files = [ arg ] diff --git a/Lib/py_compile.py b/Lib/py_compile.py index ce67584..d10c5cb 100644 --- a/Lib/py_compile.py +++ b/Lib/py_compile.py @@ -46,9 +46,9 @@ def compile(file, cfile=None, dfile=None): import os, marshal, __builtin__ f = open(file, 'U') try: - timestamp = long(os.fstat(f.fileno())[8]) + timestamp = long(os.fstat(f.fileno()).st_mtime) except AttributeError: - timestamp = long(os.stat(file)[8]) + timestamp = long(os.stat(file).st_mtime) codestring = f.read() # If parsing from a string, line breaks are \n (see parsetok.c:tok_nextc) # Replace will return original string if pattern is not found, so diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 8bb4c7b..962e32e 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -43,7 +43,7 @@ Mynd you, møøse bites Kan be pretty nasti...""" # the current directory is changed with os.chdir(), an incorrect # path will be displayed. -import sys, imp, os, stat, re, types, inspect +import sys, imp, os, re, types, inspect from repr import Repr from string import expandtabs, find, join, lower, split, strip, rfind, rstrip @@ -153,7 +153,7 @@ def ispackage(path): def synopsis(filename, cache={}): """Get the one-line summary out of a module file.""" - mtime = os.stat(filename)[stat.ST_MTIME] + mtime = os.stat(filename).st_mtime lastupdate, result = cache.get(filename, (0, None)) if lastupdate < mtime: info = inspect.getmoduleinfo(filename) @@ -1698,7 +1698,7 @@ class ModuleScanner(Scanner): def __init__(self): roots = map(lambda dir: (dir, ''), pathdirs()) Scanner.__init__(self, roots, self.submodules, self.isnewpackage) - self.inodes = map(lambda (dir, pkg): os.stat(dir)[1], roots) + self.inodes = map(lambda (dir, pkg): os.stat(dir).st_ino, roots) def submodules(self, (dir, package)): children = [] @@ -1712,7 +1712,7 @@ class ModuleScanner(Scanner): return children def isnewpackage(self, (dir, package)): - inode = os.path.exists(dir) and os.stat(dir)[1] + inode = os.path.exists(dir) and os.stat(dir).st_ino if not (os.path.islink(dir) and inode in self.inodes): self.inodes.append(inode) # detect circular symbolic links return ispackage(dir) diff --git a/Lib/statcache.py b/Lib/statcache.py index 551069b..d478393 100644 --- a/Lib/statcache.py +++ b/Lib/statcache.py @@ -79,4 +79,4 @@ def isdir(path): st = stat(path) except _os.error: return False - return S_ISDIR(st[ST_MODE]) + return S_ISDIR(st.st_mode) @@ -52,7 +52,7 @@ def encode(in_file, out_file, name=None, mode=None): name = os.path.basename(in_file) if mode is None: try: - mode = os.stat(in_file)[0] + mode = os.stat(in_file).st_mode except AttributeError: pass in_file = open(in_file, 'rb') diff --git a/Lib/zipfile.py b/Lib/zipfile.py index c0a0fe5..c21be84 100644 --- a/Lib/zipfile.py +++ b/Lib/zipfile.py @@ -373,7 +373,7 @@ class ZipFile: """Put the bytes from filename into the archive under the name arcname.""" st = os.stat(filename) - mtime = time.localtime(st[8]) + mtime = time.localtime(st.st_mtime) date_time = mtime[0:6] # Create ZipInfo instance to store file information if arcname is None: @@ -572,10 +572,10 @@ class PyZipFile(ZipFile): file_pyc = pathname + ".pyc" file_pyo = pathname + ".pyo" if os.path.isfile(file_pyo) and \ - os.stat(file_pyo)[8] >= os.stat(file_py)[8]: + os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime: fname = file_pyo # Use .pyo file elif not os.path.isfile(file_pyc) or \ - os.stat(file_pyc)[8] < os.stat(file_py)[8]: + os.stat(file_pyc).st_mtime < os.stat(file_py).st_mtime: import py_compile if self.debug: print "Compiling", file_py |