~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to upstream_import.py

  • Committer: Aaron Bentley
  • Date: 2007-07-26 15:52:55 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070726155255-cawzo84zpzoulzbr
Allow importing directly from a URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from bzrlib.trace import warning
17
17
from bzrlib.transform import TreeTransform, resolve_conflicts, cook_conflicts
18
18
from bzrlib.workingtree import WorkingTree
 
19
from bzrlib.plugins.bzrtools.bzrtools import open_from_url
19
20
 
20
21
class ZipFileWrapper(object):
21
22
 
267
268
        if (source.endswith('.tar') or source.endswith('.tar.gz') or
268
269
            source.endswith('.tar.bz2')) or source.endswith('.tgz'):
269
270
            try:
 
271
                tar_input = open_from_url(source)
270
272
                if source.endswith('.bz2'):
271
 
                    tar_input = BZ2File(source, 'r')
272
 
                    tar_input = StringIO(tar_input.read())
273
 
                else:
274
 
                    tar_input = file(source, 'rb')
 
273
                    tar_input = StringIO(tar_input.read().decode('bz2'))
275
274
            except IOError, e:
276
275
                if e.errno == errno.ENOENT:
277
276
                    raise NoSuchFile(source)
280
279
            finally:
281
280
                tar_input.close()
282
281
        elif source.endswith('.zip'):
283
 
            import_zip(tree, open(source, 'rb'))
 
282
            import_zip(tree, open_from_url(source))
284
283
        elif file_kind(source) == 'directory':
285
284
            s = StringIO(source)
286
285
            s.seek(0)