original_docstring: Calls out to Glance for data and writes data.
  
          :param image_id: The opaque image identifier.
          :param data: (Optional) File object to write data to.
          
docstring: Calls out to Glance for data and writes data.
docstring_tokens: Calls out to Glance for data and writes data .
code: def _download(self, image_href, data=None, method='data'):
          """Calls out to Glance for data and writes data.
  
          :param image_id: The opaque image identifier.
          :param data: (Optional) File object to write data to.
          """
          image_id = service_utils.parse_image_ref(image_href)[0]
  
          if (self.version == 2 and
                  'file' in CONF.glance.allowed_direct_url_schemes):
  
              location = self._get_location(image_id)
              url = urlparse.urlparse(location)
              if url.scheme == "file":
                  with open(url.path, "r") as f:
                      filesize = os.path.getsize(f.name)
                      sendfile.sendfile(data.fileno(), f.fileno(), 0, filesize)
                  return
  
          image_chunks = self.call(method, image_id)
  
          if data is None:
              return image_chunks
          else:
              for chunk in image_chunks:
                  data.write(chunk)
code_tokens: def _download ( self , image_href , data = None , method = 'data' ) : image_id = service_utils . parse_image_ref ( image_href ) [ 0 ] if ( self . version == 2 and 'file' in CONF . glance . allowed_direct_url_schemes ) : location = self . _get_location ( image_id ) url = urlparse . urlparse ( location ) if url . scheme == "file" : with open ( url . path , "r" ) as f : filesize = os . path . getsize ( f . name ) sendfile . sendfile ( data . fileno ( ) , f . fileno ( ) , 0 , filesize ) return image_chunks = self . call ( method , image_id ) if data is None : return image_chunks else : for chunk in image_chunks : data . write ( chunk )
short_docstring: Calls out to Glance for data and writes data.
short_docstring_tokens: Calls out to Glance for data and writes data .
comment: """Calls out to Glance for data and writes data.
  
          :param image_id: The opaque image identifier.
          :param data: (Optional) File object to write data to.
          """