Update extractunitypackage.py

Added support for python 3.
Now works on both versions.
This commit is contained in:
Entwicklerpages 2014-07-25 10:24:45 +02:00
parent fc515eec95
commit 481862710b

View file

@ -15,6 +15,8 @@
# extracted to. If omitted, the current working directory is used. If # extracted to. If omitted, the current working directory is used. If
# specified, the path should already exist. # specified, the path should already exist.
# Update (by Entwicklerpages): Simple fixes for python3 support. Now works on both versions.
import os import os
import stat import stat
import shutil import shutil
@ -22,7 +24,7 @@ import sys
import tarfile import tarfile
if len(sys.argv) < 2: if len(sys.argv) < 2:
print 'No input file specified.' print ('No input file specified.')
sys.exit() sys.exit()
name, extension = os.path.splitext(sys.argv[1]) name, extension = os.path.splitext(sys.argv[1])
@ -37,7 +39,7 @@ workingDir = './.working'
# can't proceed if the output dir exists already # can't proceed if the output dir exists already
# but if the temp working dir exists, we clean it out before extracting # but if the temp working dir exists, we clean it out before extracting
if os.path.exists(outputDir): if os.path.exists(outputDir):
print 'Output dir "' + outputDir + '" exists. Aborting.' print ('Output dir "' + outputDir + '" exists. Aborting.')
sys.exit(); sys.exit();
if os.path.exists(workingDir): if os.path.exists(workingDir):
shutil.rmtree(workingDir) shutil.rmtree(workingDir)
@ -98,7 +100,7 @@ for asset in mapping:
# for safety reasons os x prevent the access to the extracted files # for safety reasons os x prevent the access to the extracted files
os.chmod(destFile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) os.chmod(destFile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
print asset, '=>', mapping[asset] print (asset + ' => ' + mapping[asset])
# done, cleanup any leftovers... # done, cleanup any leftovers...
shutil.rmtree(workingDir) shutil.rmtree(workingDir)