~duplicity-team/duplicity/0.8-series

« back to all changes in this revision

Viewing changes to duplicity/diffdir.py

* Merged in lp:~kenneth-loafman/duplicity/duplicity-pylint
  - Enable additional pylint warnings. Make 1st pass at correction.
      unused-argument,
      unused-wildcard-import,
      redefined-builtin,
      bad-indentation,
      mixed-indentation,
     unreachable
  - Renamed globals to config to fix conflict with __builtin__.glogals()
  - Resolved conflict between duplicity.config and testing.manual.config
  - Normalized emacs mode line to have encoding:utf8 on all *.py files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
 
1
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4; encoding:utf8 -*-
2
2
#
3
3
# Copyright 2002 Ben Escoto <ben@emerose.org>
4
4
# Copyright 2007 Kenneth Loafman <kenneth@loafman.com>
37
37
from builtins import object
38
38
 
39
39
import io
40
 
import types
41
 
import math
 
40
import sys
 
41
 
42
42
from duplicity import statistics
43
43
from duplicity import util
44
 
from duplicity import globals
45
 
from duplicity.path import *  # @UnusedWildImport
46
 
from duplicity.lazy import *  # @UnusedWildImport
 
44
from duplicity import config
 
45
from duplicity.path import *  # pylint: disable=unused-wildcard-import,redefined-builtin
 
46
from duplicity.lazy import *  # pylint: disable=unused-wildcard-import,redefined-builtin
47
47
from duplicity import progress
48
48
 
49
49
# A StatsObj will be written to this from DirDelta and DirDelta_WriteSig.
96
96
    else:
97
97
        sig_iter = sigtar2path_iter(dirsig_fileobj_list)
98
98
    delta_iter = get_delta_iter(path_iter, sig_iter)
99
 
    if globals.dry_run or (globals.progress and not progress.tracker.has_collected_evidence()):
 
99
    if config.dry_run or (config.progress and not progress.tracker.has_collected_evidence()):
100
100
        return DummyBlockIter(delta_iter)
101
101
    else:
102
102
        return DeltaTarBlockIter(delta_iter)
103
103
 
104
104
 
105
 
def delta_iter_error_handler(exc, new_path, sig_path, sig_tar=None):
 
105
def delta_iter_error_handler(exc, new_path, sig_path, sig_tar=None):  # pylint: disable=unused-argument
106
106
    u"""
107
107
    Called by get_delta_iter, report error in getting delta
108
108
    """
389
389
    else:
390
390
        sig_path_iter = sigtar2path_iter(sig_infp_list)
391
391
    delta_iter = get_delta_iter(path_iter, sig_path_iter, newsig_outfp)
392
 
    if globals.dry_run or (globals.progress and not progress.tracker.has_collected_evidence()):
 
392
    if config.dry_run or (config.progress and not progress.tracker.has_collected_evidence()):
393
393
        return DummyBlockIter(delta_iter)
394
394
    else:
395
395
        return DeltaTarBlockIter(delta_iter)
502
502
        Make tarblock out of tarinfo and file data
503
503
        """
504
504
        tarinfo.size = len(file_data)
505
 
        headers = tarinfo.tobuf(errors=u'replace', encoding=globals.fsencoding)
506
 
        blocks, remainder = divmod(tarinfo.size, tarfile.BLOCKSIZE)  # @UnusedVariable
 
505
        headers = tarinfo.tobuf(errors=u'replace', encoding=config.fsencoding)
 
506
        blocks, remainder = divmod(tarinfo.size, tarfile.BLOCKSIZE)
507
507
        if remainder > 0:
508
508
            filler_data = b"\0" * (tarfile.BLOCKSIZE - remainder)
509
509
        else:
510
510
            filler_data = b""
511
511
        return TarBlock(index, b"%s%s%s" % (headers, file_data, filler_data))
512
512
 
513
 
    def process(self, val):
 
513
    def process(self, val):  # pylint: disable=unused-argument
514
514
        u"""
515
515
        Turn next value of input_iter into a TarBlock
516
516
        """
589
589
        u"""
590
590
        Return closing string for tarfile, reset offset
591
591
        """
592
 
        blocks, remainder = divmod(self.offset, tarfile.RECORDSIZE)  # @UnusedVariable
 
592
        blocks, remainder = divmod(self.offset, tarfile.RECORDSIZE)
593
593
        self.offset = 0
594
594
        return b'\0' * (tarfile.RECORDSIZE - remainder)  # remainder can be 0
595
595
 
767
767
    else:
768
768
        # Split file into about 2000 pieces, rounding to 512
769
769
        file_blocksize = int((file_len / (2000 * 512))) * 512
770
 
        return min(file_blocksize, globals.max_blocksize)
 
770
        return min(file_blocksize, config.max_blocksize)