Skip to content

Commit c345ed3

Browse files
committed
PEP-8: extra lines
* Two lines between top-level functions and classes * One line between methods and properties
1 parent 97af0df commit c345ed3

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

bagit.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,33 +551,40 @@ def _validate_bagittxt(self):
551551
class BagError(Exception):
552552
pass
553553

554+
554555
class BagValidationError(BagError):
555556
def __init__(self, message, details=[]):
556557
self.message = message
557558
self.details = details
559+
558560
def __str__(self):
559561
if len(self.details) > 0:
560562
details = " ; ".join([str(e) for e in self.details])
561563
return "%s: %s" % (self.message, details)
562564
return self.message
563565

566+
564567
class ManifestErrorDetail(BagError):
565568
def __init__(self, path):
566569
self.path = path
567570

571+
568572
class ChecksumMismatch(ManifestErrorDetail):
569573
def __init__(self, path, algorithm=None, expected=None, found=None):
570574
self.path = path
571575
self.algorithm = algorithm
572576
self.expected = expected
573577
self.found = found
578+
574579
def __str__(self):
575580
return "%s checksum validation failed (alg=%s expected=%s found=%s)" % (self.path, self.algorithm, self.expected, self.found)
576581

582+
577583
class FileMissing(ManifestErrorDetail):
578584
def __str__(self):
579585
return "%s exists in manifest but not found on filesystem" % self.path
580586

587+
581588
class UnexpectedFile(ManifestErrorDetail):
582589
def __str__(self):
583590
return "%s exists on filesystem but is not in manifest" % self.path
@@ -771,6 +778,7 @@ def _walk(data_dir):
771778
path = '/'.join(parts)
772779
yield path
773780

781+
774782
def _can_bag(test_dir):
775783
"""returns (unwriteable files/folders)
776784
"""
@@ -780,6 +788,7 @@ def _can_bag(test_dir):
780788
unwriteable.append(os.path.join(os.path.abspath(test_dir), inode))
781789
return tuple(unwriteable)
782790

791+
783792
def _can_read(test_dir):
784793
"""
785794
returns ((unreadable_dirs), (unreadable_files))
@@ -795,18 +804,23 @@ def _can_read(test_dir):
795804
unreadable_files.append(os.path.join(dirpath, fn))
796805
return (tuple(unreadable_dirs), tuple(unreadable_files))
797806

807+
798808
def _manifest_line_md5(filename):
799809
return _manifest_line(filename, 'md5')
800810

811+
801812
def _manifest_line_sha1(filename):
802813
return _manifest_line(filename, 'sha1')
803814

815+
804816
def _manifest_line_sha256(filename):
805817
return _manifest_line(filename, 'sha256')
806818

819+
807820
def _manifest_line_sha512(filename):
808821
return _manifest_line(filename, 'sha512')
809822

823+
810824
def _hasher(algorithm='md5'):
811825
if algorithm == 'md5':
812826
m = hashlib.md5()
@@ -818,6 +832,7 @@ def _hasher(algorithm='md5'):
818832
m = hashlib.sha512()
819833
return m
820834

835+
821836
def _manifest_line(filename, algorithm='md5'):
822837
with open(filename, 'rb') as fh:
823838
m = _hasher(algorithm)
@@ -832,11 +847,13 @@ def _manifest_line(filename, algorithm='md5'):
832847

833848
return (m.hexdigest(), _decode_filename(filename), total_bytes)
834849

850+
835851
def _encode_filename(s):
836852
s = s.replace("\r", "%0D")
837853
s = s.replace("\n", "%0A")
838854
return s
839855

856+
840857
def _decode_filename(s):
841858
s = re.sub("%0D", "\r", s, re.IGNORECASE)
842859
s = re.sub("%0A", "\n", s, re.IGNORECASE)
@@ -850,11 +867,13 @@ def __init__(self, *args, **opts):
850867
self.bag_info = {}
851868
optparse.OptionParser.__init__(self, *args, **opts)
852869

870+
853871
def _bag_info_store(option, opt, value, parser):
854872
opt = opt.lstrip('--')
855873
opt_caps = '-'.join([o.capitalize() for o in opt.split('-')])
856874
parser.bag_info[opt_caps] = value
857875

876+
858877
def _make_opt_parser():
859878
parser = BagOptionParser(usage='usage: %prog [options] dir1 dir2 ...')
860879
parser.add_option('--processes', action='store', type="int",
@@ -881,6 +900,7 @@ def _make_opt_parser():
881900
action='callback', callback=_bag_info_store)
882901
return parser
883902

903+
884904
def _configure_logging(opts):
885905
log_format="%(asctime)s - %(levelname)s - %(message)s"
886906
if opts.quiet:

0 commit comments

Comments
 (0)