Mercurial > hg > fetch
comparison fetch.py @ 54:c62e80b8615a
account for paths that do not exit for the FileFetcher
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 15 Nov 2011 16:20:01 -0800 |
parents | 81fe0523a078 |
children |
comparison
equal
deleted
inserted
replaced
53:81fe0523a078 | 54:c62e80b8615a |
---|---|
92 @classmethod | 92 @classmethod |
93 def download(cls, url): | 93 def download(cls, url): |
94 return urllib2.urlopen(url).read() | 94 return urllib2.urlopen(url).read() |
95 | 95 |
96 def __call__(self, dest): | 96 def __call__(self, dest): |
97 | |
98 dirname = os.path.dirname(dest) | |
99 if not os.path.exists(dirname): | |
100 os.makedirs(dirname) | |
97 | 101 |
98 if os.path.isdir(dest): | 102 if os.path.isdir(dest): |
99 filename = self.url.rsplit('/', 1)[-1] | 103 filename = self.url.rsplit('/', 1)[-1] |
100 dest = os.path.join(dest, filename) | 104 dest = os.path.join(dest, filename) |
101 f = file(dest, 'w') | 105 f = file(dest, 'w') |