summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/mkreal.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-03-30 11:13:59 (GMT)
committerGuido van Rossum <guido@python.org>1992-03-30 11:13:59 (GMT)
commite7b88e7402b3683afeec3ed602dd53288772991c (patch)
tree3f31c12fc6504ec423ba944312b3c7b364552ce8 /Tools/scripts/mkreal.py
parentb2ac8092a8f32de529675e14f3ba5c1f6ef06737 (diff)
downloadcpython-e7b88e7402b3683afeec3ed602dd53288772991c.zip
cpython-e7b88e7402b3683afeec3ed602dd53288772991c.tar.gz
cpython-e7b88e7402b3683afeec3ed602dd53288772991c.tar.bz2
change posix to os
Diffstat (limited to 'Tools/scripts/mkreal.py')
-rwxr-xr-xTools/scripts/mkreal.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/Tools/scripts/mkreal.py b/Tools/scripts/mkreal.py
index b72c2e5..e01b35d 100755
--- a/Tools/scripts/mkreal.py
+++ b/Tools/scripts/mkreal.py
@@ -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)