/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brzlib/store/text.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
20
20
do any sort of delta compression.
21
21
"""
22
22
 
 
23
from __future__ import absolute_import
 
24
 
23
25
import gzip
24
26
import os
25
 
from cStringIO import StringIO
26
 
 
27
 
from bzrlib import osutils
28
 
from bzrlib.errors import BzrError, NoSuchFile, FileExists
29
 
import bzrlib.store
30
 
from bzrlib.trace import mutter
31
 
 
32
 
 
33
 
 
34
 
class TextStore(bzrlib.store.TransportStore):
 
27
 
 
28
from brzlib import osutils
 
29
from brzlib.errors import BzrError, NoSuchFile, FileExists
 
30
import brzlib.store
 
31
from brzlib.trace import mutter
 
32
 
 
33
 
 
34
 
 
35
class TextStore(brzlib.store.TransportStore):
35
36
    """Store that holds files indexed by unique names.
36
37
 
37
38
    Files can be added, but not modified once they are in.  Typically
43
44
 
44
45
    def _add_compressed(self, fn, f):
45
46
        from cStringIO import StringIO
46
 
        from bzrlib.osutils import pumpfile
 
47
        from brzlib.osutils import pumpfile
47
48
 
48
49
        if isinstance(f, basestring):
49
50
            f = StringIO(f)
118
119
        # so buffer them in a StringIO instead
119
120
        if getattr(f, 'tell', None) is not None:
120
121
            return gzip.GzipFile(mode='rb', fileobj=f)
121
 
        else:
 
122
        try:
122
123
            from cStringIO import StringIO
123
124
            sio = StringIO(f.read())
124
125
            return gzip.GzipFile(mode='rb', fileobj=sio)
 
126
        finally:
 
127
            f.close()