def _post_processing(kwargs, skip_translate, invalid):
    '''
    Additional container-specific post-translation processing
    '''
    # Don't allow conflicting options to be set
    if kwargs.get('port_bindings') is not None \
            and kwargs.get('publish_all_ports'):
        kwargs.pop('port_bindings')
        invalid['port_bindings'] = 'Cannot be used when publish_all_ports=True'
    if kwargs.get('hostname') is not None \
            and kwargs.get('network_mode') == 'host':
        kwargs.pop('hostname')
        invalid['hostname'] = 'Cannot be used when network_mode=True'

    # Make sure volumes and ports are defined to match the binds and port_bindings
    if kwargs.get('binds') is not None \
            and (skip_translate is True or
                 all(x not in skip_translate
                     for x in ('binds', 'volume', 'volumes'))):
        # Make sure that all volumes defined in "binds" are included in the
        # "volumes" param.
        auto_volumes = []
        if isinstance(kwargs['binds'], dict):
            for val in six.itervalues(kwargs['binds']):
                try:
                    if 'bind' in val:
                        auto_volumes.append(val['bind'])
                except TypeError:
                    continue
        else:
            if isinstance(kwargs['binds'], list):
                auto_volume_defs = kwargs['binds']
            else:
                try:
                    auto_volume_defs = helpers.split(kwargs['binds'])
                except AttributeError:
                    auto_volume_defs = []
            for val in auto_volume_defs:
                try:
                    auto_volumes.append(helpers.split(val, ':')[1])
                except IndexError:
                    continue
        if auto_volumes:
            actual_volumes = kwargs.setdefault('volumes', [])
            actual_volumes.extend([x for x in auto_volumes
                                   if x not in actual_volumes])
            # Sort list to make unit tests more reliable
            actual_volumes.sort()

    if kwargs.get('port_bindings') is not None \
            and all(x not in skip_translate
                    for x in ('port_bindings', 'expose', 'ports')):
        # Make sure that all ports defined in "port_bindings" are included in
        # the "ports" param.
        ports_to_bind = list(kwargs['port_bindings'])
        if ports_to_bind:
            ports_to_open = set(kwargs.get('ports', []))
            ports_to_open.update([helpers.get_port_def(x) for x in ports_to_bind])
            kwargs['ports'] = list(ports_to_open)

    if 'ports' in kwargs \
            and all(x not in skip_translate for x in ('expose', 'ports')):
        # TCP ports should only be passed as the port number. Normalize the
        # input so a port definition of 80/tcp becomes just 80 instead of
        # (80, 'tcp').
        for index, _ in enumerate(kwargs['ports']):
            try:
                if kwargs['ports'][index][1] == 'tcp':
                    kwargs['ports'][index] = ports_to_open[index][0]
            except TypeError:
                continue
def _post_processing ( kwargs , skip_translate , invalid ) : if kwargs . get ( 'port_bindings' ) is not None and kwargs . get ( 'publish_all_ports' ) : kwargs . pop ( 'port_bindings' ) invalid [ 'port_bindings' ] = 'Cannot be used when publish_all_ports=True' if kwargs . get ( 'hostname' ) is not None and kwargs . get ( 'network_mode' ) == 'host' : kwargs . pop ( 'hostname' ) invalid [ 'hostname' ] = 'Cannot be used when network_mode=True' if kwargs . get ( 'binds' ) is not None and ( skip_translate is True or all ( x not in skip_translate for x in ( 'binds' , 'volume' , 'volumes' ) ) ) : auto_volumes = [ ] if isinstance ( kwargs [ 'binds' ] , dict ) : for val in six . itervalues ( kwargs [ 'binds' ] ) : try : if 'bind' in val : auto_volumes . append ( val [ 'bind' ] ) except TypeError : continue else : if isinstance ( kwargs [ 'binds' ] , list ) : auto_volume_defs = kwargs [ 'binds' ] else : try : auto_volume_defs = helpers . split ( kwargs [ 'binds' ] ) except AttributeError : auto_volume_defs = [ ] for val in auto_volume_defs : try : auto_volumes . append ( helpers . split ( val , ':' ) [ 1 ] ) except IndexError : continue if auto_volumes : actual_volumes = kwargs . setdefault ( 'volumes' , [ ] ) actual_volumes . extend ( [ x for x in auto_volumes if x not in actual_volumes ] ) actual_volumes . sort ( ) if kwargs . get ( 'port_bindings' ) is not None and all ( x not in skip_translate for x in ( 'port_bindings' , 'expose' , 'ports' ) ) : ports_to_bind = list ( kwargs [ 'port_bindings' ] ) if ports_to_bind : ports_to_open = set ( kwargs . get ( 'ports' , [ ] ) ) ports_to_open . update ( [ helpers . get_port_def ( x ) for x in ports_to_bind ] ) kwargs [ 'ports' ] = list ( ports_to_open ) if 'ports' in kwargs and all ( x not in skip_translate for x in ( 'expose' , 'ports' ) ) : for index , _ in enumerate ( kwargs [ 'ports' ] ) : try : if kwargs [ 'ports' ] [ index ] [ 1 ] == 'tcp' : kwargs [ 'ports' ] [ index ] = ports_to_open [ index ] [ 0 ] except TypeError : continue
Additional container-specific post-translation processing