def _toEndpoint(description, certificate=None):
    """
    Tries to guess whether a description is a bare TCP port or a endpoint.  If a
    bare port is specified and a certificate file is present, returns an
    SSL4ServerEndpoint and otherwise returns a TCP4ServerEndpoint.
    """
    from twisted.internet import reactor
    try:
        port = int(description)
    except __HOLE__:
        return endpoints.serverFromString(reactor, description)

    warnings.warn(
        "Specifying plain ports and/or a certificate is deprecated since "
        "Twisted 11.0; use endpoint descriptions instead.",
        category=DeprecationWarning, stacklevel=3)

    if certificate:
        from twisted.internet.ssl import DefaultOpenSSLContextFactory
        ctx = DefaultOpenSSLContextFactory(certificate, certificate)
        return endpoints.SSL4ServerEndpoint(reactor, port, ctx)
    return endpoints.TCP4ServerEndpoint(reactor, port)
dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/mail/tap.py/_toEndpoint