~ubuntu-branches/ubuntu/quantal/glance/quantal

« back to all changes in this revision

Viewing changes to glance/common/utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Dave Walker (Daviey
  • Date: 2012-02-17 09:50:40 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20120217095040-i5fk163vyuryak76
Tags: 2012.1~e4~20120217.1275-0ubuntu1
[ Chuck Short ]
* New upstream release.

[ Dave Walker (Daviey ]
* debian/patches/fix-broken-unittests.patch: Back out patch as it seems 
  to be present in upstream git, but missing in upstream tarballs. Which
  is blocking CI testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
40
40
 
41
41
 
 
42
def chunkreadable(iter, chunk_size=65536):
 
43
    """
 
44
    Wrap a readable iterator with a reader yielding chunks of
 
45
    a preferred size, otherwise leave iterator unchanged.
 
46
 
 
47
    :param iter: an iter which may also be readable
 
48
    :param chunk_size: maximum size of chunk
 
49
    """
 
50
    return chunkiter(iter, chunk_size) if hasattr(iter, 'read') else iter
 
51
 
 
52
 
42
53
def chunkiter(fp, chunk_size=65536):
43
54
    """
44
55
    Return an iterator to a file-like obj which yields fixed size chunks