def get_container_data_volumes(container, volumes_option):
 volumes = []
 volumes_option = (volumes_option or [])
 container_mounts = dict(((mount[u'Destination'], mount) for mount in (container.get(u'Mounts') or {})))
 image_volumes = [VolumeSpec.parse(volume) for volume in (container.image_config[u'ContainerConfig'].get(u'Volumes') or {})]
 for volume in set((volumes_option + image_volumes)):
  if volume.external:
   continue
  mount = container_mounts.get(volume.internal)
  if (not mount):
   continue
  if (not mount.get(u'Name')):
   continue
  volume = volume._replace(external=mount[u'Name'])
  volumes.append(volume)
 return volumes

def get_container_data_volumes ( container , volumes_option ) : volumes = [ ] volumes_option = ( volumes_option or [ ] ) container_mounts = dict ( ( ( mount [ u'Destination' ] , mount ) for mount in ( container . get ( u'Mounts' ) or { } ) ) ) image_volumes = [ VolumeSpec . parse ( volume ) for volume in ( container . image_config [ u'ContainerConfig' ] . get ( u'Volumes' ) or { } ) ] for volume in set ( ( volumes_option + image_volumes ) ) : if volume . external : continue mount = container_mounts . get ( volume . internal ) if ( not mount ) : continue if ( not mount . get ( u'Name' ) ) : continue volume = volume . _replace ( external = mount [ u'Name' ] ) volumes . append ( volume ) return volumes
find the container data volumes that are in volumes_option .