<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def postOptions(self):
 """ Display details about the ports which already exist. """

        store = self.parent.parent.getStore()
        port = None
        factories = {}
        for portType in [TCPPort, SSLPort, StringEndpointPort]:
            for port in store.query(portType):
                key = port.factory.storeID
                if key not in factories:
                    factories[key] = (port.factory, [])
                factories[key][1].append(port)
        for factory in store.powerupsFor(IProtocolFactoryFactory):
            key = factory.storeID
            if key not in factories:
                factories[key] = (factory, [])
        def key((factory, ports)):
            return factory.storeID
        for factory, ports in sorted(factories.values(), key=key):
            if ports:
                print '%d) %r listening on:' % (factory.storeID, factory)
                for port in ports:
                    if getattr(port, 'interface', None):
                        interface = "interface " + port.interface
                    else:
                        interface = "any interface"
                    if isinstance(port, TCPPort):
                        print '  %d) TCP, %s, port %d' % (
                            port.storeID, interface, port.portNumber)
                    elif isinstance(port, SSLPort):
                        if port.certificatePath is not None:
                            pathPart = 'certificate %s' % (
                                port.certificatePath.path,)
                        else:
                            pathPart = 'NO CERTIFICATE'
                        if port.portNumber is not None:
                            portPart = 'port %d' % (port.portNumber,)
                        else:
                            portPart = 'NO PORT'
                        print '  %d) SSL, %s, %s, %s' % (
                            port.storeID, interface, portPart, pathPart)
                    elif isinstance(port, StringEndpointPort):
                        print '  {:d}) Endpoint {!r}'.format(
                            port.storeID, port.description)
            else:
                print '%d) %r is not listening.' % (factory.storeID, factory)
        if not factories:
            print "There are no ports configured."
        raise SystemExit(0)