def get_image_data_iter(uri):
 if uri.startswith('file://'):
  uri = uri.split('file://')[(-1)]
  return open(uri, 'r')
 return urllib.request.urlopen(uri)

def get_image_data_iter ( uri ) : if uri . startswith ( 'file://' ) : uri = uri . split ( 'file://' ) [ ( - 1 ) ] return open ( uri , 'r' ) return urllib . request . urlopen ( uri )
returns iterable object either for local file or uri .