@@ -657,7 +657,8 @@ def _load_tag_file(tag_file_name):
657657 tags [name ].append (value )
658658 return tags
659659
660- def _parse_tags (file ):
660+
661+ def _parse_tags (tag_file ):
661662 """Parses a tag file, according to RFC 2822. This
662663 includes line folding, permitting extra-long
663664 field values.
@@ -671,7 +672,7 @@ def _parse_tags(file):
671672
672673 # Line folding is handled by yielding values only after we encounter
673674 # the start of a new tag, or if we pass the EOF.
674- for num , line in enumerate (file ):
675+ for num , line in enumerate (tag_file ):
675676 # If byte-order mark ignore it for now.
676677 if num == 0 :
677678 if line .startswith (BOM ):
@@ -687,7 +688,8 @@ def _parse_tags(file):
687688 yield (tag_name , tag_value .strip ())
688689
689690 if ':' not in line :
690- raise BagValidationError ("invalid line '%s' in %s" % (line .strip (), os .path .basename (file .name )))
691+ raise BagValidationError ("invalid line '%s' in %s" % (line .strip (),
692+ os .path .basename (tag_file .name )))
691693
692694 parts = line .strip ().split (':' , 1 )
693695 tag_name = parts [0 ].strip ()
@@ -739,9 +741,9 @@ def _make_manifest(manifest_file, data_dir, processes, algorithm='md5'):
739741 num_files = 0
740742 total_bytes = 0
741743
742- for digest , filename , bytes in checksums :
744+ for digest , filename , byte_count in checksums :
743745 num_files += 1
744- total_bytes += bytes
746+ total_bytes += byte_count
745747 manifest .write ("%s %s\n " % (digest , _encode_filename (filename )))
746748 manifest .close ()
747749 return "%s.%s" % (total_bytes , num_files )
@@ -758,10 +760,10 @@ def _make_tagmanifest_file(alg, bag_dir):
758760 with open (join (bag_dir , f ), 'rb' ) as fh :
759761 m = _hasher (alg )
760762 while True :
761- bytes = fh .read (16384 )
762- if not bytes :
763+ block = fh .read (16384 )
764+ if not block :
763765 break
764- m .update (bytes )
766+ m .update (block )
765767 checksums .append ((m .hexdigest (), f ))
766768
767769 with open (join (bag_dir , tagmanifest_file ), 'w' ) as tagmanifest :
@@ -844,11 +846,11 @@ def _manifest_line(filename, algorithm='md5'):
844846
845847 total_bytes = 0
846848 while True :
847- bytes = fh .read (16384 )
848- total_bytes += len (bytes )
849- if not bytes :
849+ block = fh .read (16384 )
850+ total_bytes += len (block )
851+ if not block :
850852 break
851- m .update (bytes )
853+ m .update (block )
852854
853855 return (m .hexdigest (), _decode_filename (filename ), total_bytes )
854856
0 commit comments