1. Travis Shirk
  2. eyeD3

Commits

Travis Shirk  committed 69ffde8

eyed3.utils.copyBytes renamed to chunkCopy and optional chunk_sz arg added.

  • Participants
  • Parent commits 671d468
  • Branches default

Comments (0)

Files changed (2)

File src/eyed3/id3/tag.py

View file
  • Ignore whitespace
 ################################################################################
 import types, sys, string, re, os, shutil, types, tempfile
 
-from ..utils import requireUnicode, copyBytes
+from ..utils import requireUnicode, chunkCopy
 from .. import core
 from . import (ID3_ANY_VERSION, ID3_V1, ID3_V1_0, ID3_V1_1,
                ID3_V2, ID3_V2_2, ID3_V2_3, ID3_V2_4, versionToString)
                         log.debug("Seeking to beginning of audio data, "
                                   "byte %d (%x)" % (seek_point, seek_point))
                         tag_file.seek(seek_point)
-                        copyBytes(tag_file, tmp_file)
+                        chunkCopy(tag_file, tmp_file)
 
                 # Move tmp to orig.
                 shutil.copyfile(tmp_name, self.file_info.name)
                     # Open tmp file
                     tmp_name = tempfile.mktemp()
                     with open(tmp_name, "wb") as tmp_file:
-                        copyBytes(tag_file, tmp_file)
+                        chunkCopy(tag_file, tmp_file)
 
                     # Move tmp to orig
                     shutil.copyfile(tmp_name, filename)

File src/eyed3/utils/__init__.py

View file
  • Ignore whitespace
     return tstr
 
 
-def copyBytes(src_fp, dest_fp):
-    # Write audio data in chunks
+def chunkCopy(src_fp, dest_fp, chunk_sz=(1024 * 512)):
+    '''Copy ``src_fp`` to ``dest_fp`` in ``chunk_sz`` byte increments.'''
     done = False
-    chuck_sz = 1024 * 512
     while not done:
         data = src_fp.read(chuck_sz)
         if data: