def install(destDir=None, downloadDir=None, redownload=False): url = URL["STANFORD_PARSER"] packageName = url.split("/")[-1].split(".")[0] # Download if downloadDir == None: downloadDir = os.path.join(Settings.DATAPATH, "tools/download/") downloadFile = Download.download(url, downloadDir, clear=redownload) # Prepare destination if destDir == None: destDir = os.path.join(Settings.DATAPATH, "tools/") installDir = os.path.join(destDir, packageName) if os.path.exists(installDir): print >> sys.stderr, "Removing existing installation at", installDir shutil.rmtree(installDir) # Unpack print >> sys.stderr, "Extracting", downloadFile, "to", destDir f = tarfile.open(downloadFile, 'r:gz') f.extractall(destDir) f.close()