Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get dateutil
import os
import urllib2
import tarfile
import shutil
workingPath = os.getcwd()
tempPath = os.path.join(workingPath, 'temp')
dateutilArchiveDir = 'python-dateutil-1.5'
dateutilArchive = dateutilArchiveDir + '.tar.gz'
dateutilArchivePath = os.path.join(tempPath, dateutilArchive)
try:
os.mkdir(tempPath)
except OSError:
pass
dateutilArchiveUrl = urllib2.urlopen('http://labix.org/download/python-dateutil/' + dateutilArchive)
localArchive = open(dateutilArchivePath, 'w')
localArchive.write(dateutilArchiveUrl.read())
localArchive.close()
dateutilArchiveUrl.close()
archive = tarfile.open(dateutilArchivePath, 'r:gz')
try:
os.chdir(tempPath)
archive.extractall()
finally:
archive.close()
os.chdir(workingPath)
dateutilDir = 'dateutil'
tempDateutilPath = os.path.join(os.path.join(tempPath, dateutilArchiveDir), dateutilDir)
dateutilPath = os.path.join(workingPath, dateutilDir)
shutil.rmtree(dateutilPath, True)
shutil.copytree(tempDateutilPath, dateutilPath)
shutil.rmtree(tempPath)
@mmurdoch
Copy link
Author

mmurdoch commented Nov 6, 2012

Fetches dateutil into Pythonista.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment