From 4710c53dcad1ebf3755f3efb9e80ac24bd72a9b2 Mon Sep 17 00:00:00 2001 From: darylm503 Date: Mon, 16 Apr 2012 22:12:42 +0000 Subject: AppPkg/Applications/Python: Add Python 2.7.2 sources since the release of Python 2.7.3 made them unavailable from the python.org web site. These files are a subset of the python-2.7.2.tgz distribution from python.org. Changed files from PyMod-2.7.2 have been copied into the corresponding directories of this tree, replacing the original files in the distribution. Signed-off-by: daryl.mcdaniel@intel.com git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13197 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Python/Python-2.7.2/Tools/scripts/mkreal.py | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/mkreal.py (limited to 'AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/mkreal.py') diff --git a/AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/mkreal.py b/AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/mkreal.py new file mode 100644 index 0000000000..da2f410b10 --- /dev/null +++ b/AppPkg/Applications/Python/Python-2.7.2/Tools/scripts/mkreal.py @@ -0,0 +1,66 @@ +#! /usr/bin/env python + +# mkreal +# +# turn a symlink to a directory into a real directory + +import sys +import os +from stat import * + +join = os.path.join + +error = 'mkreal error' + +BUFSIZE = 32*1024 + +def mkrealfile(name): + st = os.stat(name) # Get the mode + mode = S_IMODE(st[ST_MODE]) + linkto = os.readlink(name) # Make sure again it's a symlink + f_in = open(name, 'r') # This ensures it's a file + 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 + os.chmod(name, mode) + +def mkrealdir(name): + st = os.stat(name) # Get the mode + mode = S_IMODE(st[ST_MODE]) + 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 filename in files: + if filename not in (os.curdir, os.pardir): + os.symlink(join(linkto, filename), join(name, filename)) + +def main(): + sys.stdout = sys.stderr + progname = os.path.basename(sys.argv[0]) + if progname == '-c': progname = 'mkreal' + args = sys.argv[1:] + if not args: + print 'usage:', progname, 'path ...' + sys.exit(2) + status = 0 + for name in args: + if not os.path.islink(name): + print progname+':', name+':', 'not a symlink' + status = 1 + else: + if os.path.isdir(name): + mkrealdir(name) + else: + mkrealfile(name) + sys.exit(status) + +if __name__ == '__main__': + main() -- cgit v1.2.3