Nuke hard tabs.

This commit is contained in:
Tim Peters 2001-07-02 04:59:35 +00:00
parent d1c296537f
commit 683ecc7374
3 changed files with 241 additions and 243 deletions

View file

@ -42,4 +42,3 @@ class _Environ:
return value
else:
return failobj

View file

@ -46,9 +46,9 @@ _allowMOSFSNames= _false
def _split(p):
"""
split filing system name (including special field) and drive specifier from rest
of path. This is needed by many riscospath functions.
"""
split filing system name (including special field) and drive specifier from rest
of path. This is needed by many riscospath functions.
"""
dash= _allowMOSFSNames and p[:1]=='-'
if dash:
q= string.find(p, '-', 1)+1
@ -75,31 +75,31 @@ of path. This is needed by many riscospath functions.
def normcase(p):
"""
Normalize the case of a pathname. This converts to lowercase as the native RISC
OS filesystems are case-insensitive. However, not all filesystems have to be,
and there's no simple way to find out what type an FS is argh.
"""
Normalize the case of a pathname. This converts to lowercase as the native RISC
OS filesystems are case-insensitive. However, not all filesystems have to be,
and there's no simple way to find out what type an FS is argh.
"""
return string.lower(p)
def isabs(p):
"""
Return whether a path is absolute. Under RISC OS, a file system specifier does
not make a path absolute, but a drive name or number does, and so does using the
symbol for root, URD, library, CSD or PSD. This means it is perfectly possible
to have an "absolute" URL dependent on the current working directory, and
equally you can have a "relative" URL that's on a completely different device to
the current one argh.
"""
Return whether a path is absolute. Under RISC OS, a file system specifier does
not make a path absolute, but a drive name or number does, and so does using the
symbol for root, URD, library, CSD or PSD. This means it is perfectly possible
to have an "absolute" URL dependent on the current working directory, and
equally you can have a "relative" URL that's on a completely different device to
the current one argh.
"""
(fs, drive, path)= _split(p)
return drive!='' or path[:1] in _roots
def join(a, *p):
"""
Join path elements with the directory separator, replacing the entire path when
an absolute or FS-changing path part is found.
"""
Join path elements with the directory separator, replacing the entire path when
an absolute or FS-changing path part is found.
"""
j= a
for b in p:
(fs, drive, path)= _split(b)
@ -112,9 +112,9 @@ an absolute or FS-changing path part is found.
def split(p):
"""
Split a path in head (everything up to the last '.') and tail (the rest). FS
name must still be dealt with separately since special field may contain '.'.
"""
Split a path in head (everything up to the last '.') and tail (the rest). FS
name must still be dealt with separately since special field may contain '.'.
"""
(fs, drive, path)= _split(p)
q= string.rfind(path, '.')
if q!=-1:
@ -124,9 +124,9 @@ name must still be dealt with separately since special field may contain '.'.
def splitext(p):
"""
Split a path in root and extension. This assumes the 'using slash for dot and
dot for slash with foreign files' convention common in RISC OS is in force.
"""
Split a path in root and extension. This assumes the 'using slash for dot and
dot for slash with foreign files' convention common in RISC OS is in force.
"""
(tail, head)= split(p)
if '/' in head:
q= len(head)-string.rfind(head, '/')
@ -136,33 +136,33 @@ dot for slash with foreign files' convention common in RISC OS is in force.
def splitdrive(p):
"""
Split a pathname into a drive specification (including FS name) and the rest of
the path. The terminating dot of the drive name is included in the drive
specification.
"""
Split a pathname into a drive specification (including FS name) and the rest of
the path. The terminating dot of the drive name is included in the drive
specification.
"""
(fs, drive, path)= _split(p)
return (fs+drive, p)
def basename(p):
"""
Return the tail (basename) part of a path.
"""
Return the tail (basename) part of a path.
"""
return split(p)[1]
def dirname(p):
"""
Return the head (dirname) part of a path.
"""
Return the head (dirname) part of a path.
"""
return split(p)[0]
def commonprefix(ps):
"""
Return the longest prefix of all list elements. Purely string-based; does not
separate any path parts. Why am I in os.path?
"""
Return the longest prefix of all list elements. Purely string-based; does not
separate any path parts. Why am I in os.path?
"""
if len(ps)==0:
return ''
prefix= ps[0]
@ -181,16 +181,16 @@ separate any path parts. Why am I in os.path?
def getsize(p):
"""
Return the size of a file, reported by os.stat().
"""
Return the size of a file, reported by os.stat().
"""
st= os.stat(p)
return st[stat.ST_SIZE]
def getmtime(p):
"""
Return the last modification time of a file, reported by os.stat().
"""
Return the last modification time of a file, reported by os.stat().
"""
st = os.stat(p)
return st[stat.ST_MTIME]
@ -201,8 +201,8 @@ getatime= getmtime
def exists(p):
"""
Test whether a path exists.
"""
Test whether a path exists.
"""
try:
return swi.swi('OS_File', '5s;i', p)!=0
except swi.error:
@ -211,8 +211,8 @@ Test whether a path exists.
def isdir(p):
"""
Is a path a directory? Includes image files.
"""
Is a path a directory? Includes image files.
"""
try:
return swi.swi('OS_File', '5s;i', p) in [2, 3]
except swi.error:
@ -221,8 +221,8 @@ Is a path a directory? Includes image files.
def isfile(p):
"""
Test whether a path is a file, including image files.
"""
Test whether a path is a file, including image files.
"""
try:
return swi.swi('OS_File', '5s;i', p) in [1, 3]
except swi.error:
@ -231,8 +231,8 @@ Test whether a path is a file, including image files.
def islink(p):
"""
RISC OS has no links or mounts.
"""
RISC OS has no links or mounts.
"""
return _false
ismount= islink
@ -247,8 +247,8 @@ ismount= islink
def samefile(fa, fb):
"""
Test whether two pathnames reference the same actual file.
"""
Test whether two pathnames reference the same actual file.
"""
l= 512
b= swi.block(l)
swi.swi('OS_FSControl', 'isb..i', 37, fa, b, l)
@ -260,8 +260,8 @@ Test whether two pathnames reference the same actual file.
def sameopenfile(a, b):
"""
Test whether two open file objects reference the same file.
"""
Test whether two open file objects reference the same file.
"""
return os.fstat(a)[stat.ST_INO]==os.fstat(b)[stat.ST_INO]
@ -302,8 +302,8 @@ def expanduser(p):
def expandvars(p):
"""
Expand environment variables using OS_GSTrans.
"""
Expand environment variables using OS_GSTrans.
"""
l= 512
b= swi.block(l)
return b.tostring(0, swi.swi('OS_GSTrans', 'sbi;..i', p, b, l))
@ -319,8 +319,8 @@ def abspath(p):
def normpath(p):
"""
Normalize path, eliminating up-directory ^s.
"""
Normalize path, eliminating up-directory ^s.
"""
(fs, drive, path)= _split(p)
rhs= ''
ups= 0
@ -347,10 +347,10 @@ Normalize path, eliminating up-directory ^s.
def walk(top, func, arg):
"""
walk(top,func,args) calls func(arg, d, files) for each directory "d" in the tree
rooted at "top" (including "top" itself). "files" is a list of all the files and
subdirs in directory "d".
"""
walk(top,func,args) calls func(arg, d, files) for each directory "d" in the tree
rooted at "top" (including "top" itself). "files" is a list of all the files and
subdirs in directory "d".
"""
try:
names= os.listdir(top)
except os.error:
@ -360,4 +360,3 @@ subdirs in directory "d".
name= join(top, name)
if isdir(name) and not islink(name):
walk(name, func, arg)