st = os.stat(path)
except os.error:
return False
- return st[0] & 0111 != 0
+ return st.st_mode & 0111 != 0
def test(HandlerClass = CGIHTTPRequestHandler,
"""
import os
-import stat
import sys
import py_compile
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:
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:
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?
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):
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):
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
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):
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."
s = _os_stat(pathname)
except OSError:
return None
- return long(s[8])
+ return long(s.st_mtime)
######################################################################
import sys
import os
-from stat import *
__all__ = ["getline","clearcache","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]
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
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):
st = os.stat(s)
except os.error:
return False
- return S_ISREG(st[ST_MODE])
+ return S_ISREG(st.st_mode)
def exists(s):
import os
import sys
-from stat import ST_NLINK
import re
import mimetools
import multifile
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 = []
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 = []
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?
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?
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)
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?
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?
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)
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?
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?
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?
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?
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?
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
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 ]
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
# 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
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)
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 = []
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)
st = stat(path)
except _os.error:
return False
- return S_ISDIR(st[ST_MODE])
+ return S_ISDIR(st.st_mode)
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')
"""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:
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