Travis Shirk avatar Travis Shirk committed 69ffde8

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

Comments (0)

Files changed (2)

src/eyed3/id3/tag.py

 ################################################################################
 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)

src/eyed3/utils/__init__.py

     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:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.