def _open_image(filename, path=None):
 if os.path.isfile(filename):
  return open(filename, 'rb')
 for p in (path or []):
  if (p and os.path.isabs(p)):
   fullpath = os.path.join(p, filename)
   if os.path.isfile(fullpath):
    return open(fullpath, 'rb')
  try:
   if p:
    fullpath = os.path.join(p, filename)
   else:
    fullpath = filename
   return file_open(fullpath)
  except IOError:
   pass
 raise IOError(('File %s cannot be found in image path' % filename))

def _open_image ( filename , path = None ) : if os . path . isfile ( filename ) : return open ( filename , 'rb' ) for p in ( path or [ ] ) : if ( p and os . path . isabs ( p ) ) : fullpath = os . path . join ( p , filename ) if os . path . isfile ( fullpath ) : return open ( fullpath , 'rb' ) try : if p : fullpath = os . path . join ( p , filename ) else : fullpath = filename return file_open ( fullpath ) except IOError : pass raise IOError ( ( 'File %s cannot be found in image path' % filename ) )
attempt to open a binary file and return the descriptor .