]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
change posix to os
authorGuido van Rossum <guido@python.org>
Mon, 30 Mar 1992 11:13:59 +0000 (11:13 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 30 Mar 1992 11:13:59 +0000 (11:13 +0000)
Tools/scripts/linktree.py
Tools/scripts/lll.py
Tools/scripts/mkreal.py
Tools/scripts/which.py
Tools/scripts/xxci.py

index 5a665075babe516e81126afd7d631c8aa2fae6f4..cfe7547e488b6935b1fd7bda9bb810a5659f6cb8 100755 (executable)
@@ -10,7 +10,7 @@
 #
 # usage: mklinks oldtree newtree
 
-import sys, posix, path
+import sys, os
 
 LINK = '.LINK' # Name of special symlink at the top.
 
@@ -27,18 +27,18 @@ def main():
        else:
                link = LINK
                link_may_fail = 0
-       if not path.isdir(oldtree):
+       if not os.path.isdir(oldtree):
                print oldtree + ': not a directory'
                return 1
        try:
-               posix.mkdir(newtree, 0777)
-       except posix.error, msg:
+               os.mkdir(newtree, 0777)
+       except os.error, msg:
                print newtree + ': cannot mkdir:', msg
                return 1
-       linkname = path.cat(newtree, link)
+       linkname = os.path.join(newtree, link)
        try:
-               posix.symlink(path.cat('..', oldtree), linkname)
-       except posix.error, msg:
+               os.symlink(os.path.join(os.pardir, oldtree), linkname)
+       except os.error, msg:
                if not link_may_fail:
                        print linkname + ': cannot symlink:', msg
                        return 1
@@ -50,27 +50,27 @@ def main():
 def linknames(old, new, link):
        if debug: print 'linknames', (old, new, link)
        try:
-               names = posix.listdir(old)
-       except posix.error, msg:
+               names = os.listdir(old)
+       except os.error, msg:
                print old + ': warning: cannot listdir:', msg
                return
        for name in names:
-           if name not in ('.', '..'):
-               oldname = path.cat(old, name)
-               linkname = path.cat(link, name)
-               newname = path.cat(new, name)
+           if name not in (os.curdir, os.pardir):
+               oldname = os.path.join(old, name)
+               linkname = os.path.join(link, name)
+               newname = os.path.join(new, name)
                if debug > 1: print oldname, newname, linkname
-               if path.isdir(oldname) and not path.islink(oldname):
+               if os.path.isdir(oldname) and not os.path.islink(oldname):
                        try:
-                               posix.mkdir(newname, 0777)
+                               os.mkdir(newname, 0777)
                                ok = 1
                        except:
                                print newname + ': warning: cannot mkdir:', msg
                                ok = 0
                        if ok:
-                               linkname = path.cat('..', linkname)
+                               linkname = os.path.join(os.pardir, linkname)
                                linknames(oldname, newname, linkname)
                else:
-                       posix.symlink(linkname, newname)
+                       os.symlink(linkname, newname)
 
 sys.exit(main())
index 509936dbca78dd8cbd78232ea3c5c7a21374e721..6dd68ba8484022e1aa5f71611471b9f6e47b4049 100755 (executable)
@@ -5,17 +5,17 @@
 # No recursion.
 # (This is a totally different program from "findsymlinks.py"!)
 
-import sys, posix, path
+import sys, os
 
 def lll(dirname):
-       for name in posix.listdir(dirname):
-               if name not in ['.', '..']:
-                       full = path.join(dirname, name)
-                       if path.islink(full):
-                               print name, '->', posix.readlink(full)
+       for name in os.listdir(dirname):
+               if name not in (os.curdir, os.pardir):
+                       full = os.path.join(dirname, name)
+                       if os.path.islink(full):
+                               print name, '->', os.readlink(full)
 
 args = sys.argv[1:]
-if not args: args = ['.']
+if not args: args = [os.curdir]
 first = 1
 for arg in args:
        if len(args) > 1:
index b72c2e5b37e1a21e3b7c467f99c2105895a13226..e01b35d65a8b0e916eaa8219a0412884d3e8ce62 100755 (executable)
@@ -5,58 +5,57 @@
 # turn a symlink to a directory into a real directory
 
 import sys
-import posix
-import path
+import os
 from stat import *
 
-join = path.join
+join = os.path.join
 
 error = 'mkreal error'
 
 BUFSIZE = 32*1024
 
 def mkrealfile(name):
-       st = posix.stat(name) # Get the mode
+       st = os.stat(name) # Get the mode
        mode = S_IMODE(st[ST_MODE])
-       linkto = posix.readlink(name) # Make sure again it's a symlink
+       linkto = os.readlink(name) # Make sure again it's a symlink
        f_in = open(name, 'r') # This ensures it's a file
-       posix.unlink(name)
+       os.unlink(name)
        f_out = open(name, 'w')
        while 1:
                buf = f_in.read(BUFSIZE)
                if not buf: break
                f_out.write(buf)
        del f_out # Flush data to disk before changing mode
-       posix.chmod(name, mode)
+       os.chmod(name, mode)
 
 def mkrealdir(name):
-       st = posix.stat(name) # Get the mode
+       st = os.stat(name) # Get the mode
        mode = S_IMODE(st[ST_MODE])
-       linkto = posix.readlink(name)
-       files = posix.listdir(name)
-       posix.unlink(name)
-       posix.mkdir(name, mode)
-       posix.chmod(name, mode)
-       linkto = join('..', linkto)
+       linkto = os.readlink(name)
+       files = os.listdir(name)
+       os.unlink(name)
+       os.mkdir(name, mode)
+       os.chmod(name, mode)
+       linkto = join(os.pardir, linkto)
        #
        for file in files:
-               if file not in ('.', '..'):
-                       posix.symlink(join(linkto, file), join(name, file))
+               if file not in (os.curdir, os.pardir):
+                       os.symlink(join(linkto, file), join(name, file))
 
 def main():
        sys.stdout = sys.stderr
-       progname = path.basename(sys.argv[0])
+       progname = os.path.basename(sys.argv[0])
        args = sys.argv[1:]
        if not args:
                print 'usage:', progname, 'path ...'
                sys.exit(2)
        status = 0
        for name in args:
-               if not path.islink(name):
+               if not os.path.islink(name):
                        print progname+':', name+':', 'not a symlink'
                        status = 1
                else:
-                       if path.isdir(name):
+                       if os.path.isdir(name):
                                mkrealdir(name)
                        else:
                                mkrealfile(name)
index 94c7556195cc7330a8cd7c51b001b491cc93d682..d3186f48732bb812491e2f57df576d9d7f118d79 100755 (executable)
@@ -4,13 +4,13 @@
 # On stderr, near and total misses are reported.
 # '-l<flags>' argument adds ls -l<flags> of each file found.
 
-import sys, posix, string, path
+import sys, os, string
 from stat import *
 
 def msg(str):
        sys.stderr.write(str + '\n')
 
-pathlist = string.splitfields(posix.environ['PATH'], ':')
+pathlist = string.splitfields(os.environ['PATH'], ':')
 
 sts = 0
 longlist = ''
@@ -22,10 +22,10 @@ if sys.argv[1:] and sys.argv[1][:2] == '-l':
 for prog in sys.argv[1:]:
        ident = ()
        for dir in pathlist:
-               file = path.join(dir, prog)
+               file = os.path.join(dir, prog)
                try:
-                       st = posix.stat(file)
-               except posix.error:
+                       st = os.stat(file)
+               except os.error:
                        continue
                if not S_ISREG(st[ST_MODE]):
                        msg(file + ': not a disk file')
@@ -44,7 +44,7 @@ for prog in sys.argv[1:]:
                        else:
                                msg(file + ': not executable')
                if longlist:
-                       sts = posix.system('ls ' + longlist + ' ' + file)
+                       sts = os.system('ls ' + longlist + ' ' + file)
                        if sts: msg('"ls -l" exit status: ' + `sts`)
        if not ident:
                msg(prog + ': not found')
index 2cb1eadcc0a0cbd2c166ba01034d573d085e916d..aef3234e802b0b62c77aa83bf95e47409b4d97c2 100755 (executable)
@@ -6,9 +6,8 @@
 # check in files for which rcsdiff returns nonzero exit status
 
 import sys
-import posix
+import os
 from stat import *
-import path
 import commands
 import fnmatch
 import string
@@ -23,7 +22,7 @@ def getargs():
                return args
        print 'No arguments, checking almost *, in "ls -t" order'
        list = []
-       for file in posix.listdir('.'):
+       for file in os.listdir(os.curdir):
                if not skipfile(file):
                        list.append((getmtime(file), file))
        list.sort()
@@ -37,9 +36,9 @@ def getargs():
 
 def getmtime(file):
        try:
-               st = posix.stat(file)
+               st = os.stat(file)
                return st[ST_MTIME]
-       except posix.error:
+       except os.error:
                return -1
 
 badnames = ['tags', 'TAGS', 'xyzzy', 'nohup.out', 'core']
@@ -65,8 +64,8 @@ def skipfile(file):
        for p in ignore:
                if fnmatch.fnmatch(file, p): return 1
        try:
-               st = posix.lstat(file)
-       except posix.error:
+               st = os.lstat(file)
+       except os.error:
                return 1 # Doesn't exist -- skip it
        # Skip non-plain files.
        if not S_ISREG(st[ST_MODE]): return 1
@@ -94,18 +93,19 @@ def go(args):
        for file in args:
                print file + ':'
                if differing(file):
-                       sts = posix.system('rcsdiff ' + file) # ignored
+                       showdiffs(file)
                        if askyesno('Check in ' + file + ' ? '):
-                               sts = posix.system('rcs -l ' + file) # ignored
-                               sts = posix.system('ci -l ' + file)
+                               sts = os.system('rcs -l ' + file) # ignored
+                               sts = os.system('ci -l ' + file)
 
 def differing(file):
-       try:
-               this = open(file, 'r').read()
-               that = posix.popen('co -p '+file+' 2>/dev/null', 'r').read()
-               return this <> that
-       except:
-               return 1
+       cmd = 'co -p ' + file + ' 2>/dev/null | cmp -s - ' + file
+       sts = os.system(cmd)
+       return sts != 0
+
+def showdiffs(file):
+       cmd = 'rcsdiff ' + file + ' 2>&1 | ${PAGER-more}'
+       sts = os.system(cmd)
 
 def askyesno(prompt):
        s = raw_input(prompt)