def open_for_read(name,mode='b', urlopen=urlopen):
    '''attempt to open a file or URL for reading'''
    if hasattr(name,'read'): return name
    try:
        return open_for_read_by_name(name,mode)
    except:
        try:
            return getBytesIO(urlopen(name).read())
        except:
            raise IOError('Cannot open resource "%s"' % name)