<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_part_visibility(self, ports):
 # type: (APortMap) -> None """Calculate what is connected to what Args: ports: {part_name: [PortInfo]} from other ports """

        # Calculate a lookup of Source Port connected_value to part_name
        source_port_lookup = {}
        for part_name, port_infos in SourcePortInfo.filter_parts(ports).items():
            for port_info in port_infos:
                source_port_lookup[port_info.connected_value] = (
                    part_name, port_info.port)
        # Look through all the Sink Ports, and set both ends of the
        # connection to visible if they aren't specified
        for part_name, port_infos in SinkPortInfo.filter_parts(
                ports).items():
            for port_info in port_infos:
                if port_info.value != port_info.disconnected_value:
                    conn_part, port = source_port_lookup.get(
                        port_info.value, (None, None))
                    if conn_part and port == port_info.port:
                        if conn_part not in self.part_visibility:
                            self.part_visibility[conn_part] = True
                        if part_name not in self.part_visibility:
                            self.part_visibility[part_name] = True