/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 bzrlib/tuned_gzip.py

  • Committer: Martin Pool
  • Date: 2011-05-20 14:46:02 UTC
  • mto: This revision was merged to the branch mainline in revision 5923.
  • Revision ID: mbp@canonical.com-20110520144602-bqli0t6dj01gl0pv
Various pyflakes import fixes.

Some modules were used for subclassing or at module load time, so there is no
point loading them lazily.

Some were not imported when they should be.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
# Written by Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
27
27
import zlib
28
28
 
29
29
# we want a \n preserved, break on \n only splitlines.
30
 
import bzrlib
 
30
from bzrlib import symbol_versioning
31
31
 
32
32
__all__ = ["GzipFile", "bytes_to_gzip"]
33
33
 
118
118
    Yes, its only 1.6 seconds, but they add up.
119
119
    """
120
120
 
 
121
    def __init__(self, *args, **kwargs):
 
122
        symbol_versioning.warn(
 
123
            symbol_versioning.deprecated_in((2, 3, 0))
 
124
            % 'bzrlib.tuned_gzip.GzipFile',
 
125
            DeprecationWarning, stacklevel=2)
 
126
        gzip.GzipFile.__init__(self, *args, **kwargs)
 
127
 
121
128
    def _add_read_data(self, data):
122
129
        # 4169 calls in 183
123
130
        # temp var for len(data) and switch to +='s.
395
402
        # (4 seconds to 1 seconds for the sample upgrades I was testing).
396
403
        self.write(''.join(lines))
397
404
 
 
405
    if sys.version_info > (2, 7):
 
406
        # As of Python 2.7 the crc32 must be positive when close is called
 
407
        def close(self):
 
408
            if self.fileobj is None:
 
409
                return
 
410
            if self.mode == gzip.WRITE:
 
411
                self.crc &= 0xFFFFFFFFL
 
412
            gzip.GzipFile.close(self)
398
413