MacPython Logo from __future__ import *

buy music albums Silver Apples buy mp3 albums Tarrus Riley buy tracks mp3 Kravits buy Reaper albums mp3 buy Kravits albums music buy music Evita CD online albums mp3 Silver Apples download Madonna CD music buy tracks music Kravits download music albums Silver Apples

2004-06-28

Talking Panda

Filed under: PyObjC, iPod, python — bob @ 10:21 pm

My first commercial consumer application, Talking Panda, has just been released! We offer a set of foreign language phrase books for iPods.

The installer is written in PyObjC, and I've described some of the development process in this pythonmac-sig message.

2004-06-19

Determining the number of common bytes at the beginning of N files

Filed under: python — bob @ 6:05 pm

I have a need to compare binary files that are slightly different. I haven't found or written any particularly good tools yet, but here is a script that prints the number of bytes N files have in common before they differ, or nothing if all the files are identical.

#!/usr/bin/env python
from itertools import izip

def blockread(f, size=1024):
    while True:
        block = f.read(size)
        if not block:
            break
        yield block

def blockseq(blocks):
    blocks = iter(blocks)
    first = blocks.next()
    for block in blocks:
        if block != first:
            return False
    return True

def byteseq(blocks):
    idx = 0
    for idx, bytes in enumerate(izip(*blocks)):
        if not blockseq(bytes):
            return idx
    else:
        # this shouldn't happen
        return idx + 1

def firstdiff(generators):
    offset = 0
    for blocks in izip(*generators):
        if not blockseq(blocks):
            break
        offset += len(blocks[0])
    else:
        return None
    return offset + byteseq(blocks)

if __name__ == '__main__':
    import sys
    rval = firstdiff([blockread(file(fn, 'rb')) for fn in sys.argv[1:]])
    if rval is not None:
        print rval

2004-06-17

Checking the current directory for progressive JPEGs

Filed under: pil, python — bob @ 8:13 pm

This is a quick hack, you'll need PIL with JPEG support installed to use it.

import glob, Image
print 'n'.join([fn for fn in glob.glob('*.jpg') if Image.open(fn).info.get('progression')])

Powered by WordPress