def parse_port_bindings(bindings):

    def parse_port_mapping(s):
        """
        Parse single port mapping.
        """
        if ':' in s:
            parts = s.split(':')
            if len(parts) > 2:
                ip, hp, cp = parts[0], parts[1], parts[2]
                return cp, (ip, None if hp == '' else hp)
            else:
                hp, cp = parts[0], parts[1]
                return cp, None if hp == '' else hp
        else:
            return s, None

    result = {}
    if bindings:
        for binding in bindings:
            container_port, mapping = parse_port_mapping(binding)
            result[container_port] = mapping
    return result
Test a relative nested req file path is joined with the req file dir
dataset/ETHPy150Open j-bennet/wharfee/wharfee/helpers.py/parse_port_bindings--crossover with--dataset/ETHPy150Open pypa/pip/tests/unit/test_req_file.py/TestProcessLine.test_relative_local_nested_req_files