def _toEndpoint(description, certificate=None):
 from twisted.internet import reactor
 try:
  port = int(description)
 except ValueError:
  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:
  ctx = SSLContextFactory(certificate)
  return endpoints.SSL4ServerEndpoint(reactor, port, ctx)
 return endpoints.TCP4ServerEndpoint(reactor, port)

def _toEndpoint ( description , certificate = None ) : from twisted . internet import reactor try : port = int ( description ) except ValueError : 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 : ctx = SSLContextFactory ( certificate ) return endpoints . SSL4ServerEndpoint ( reactor , port , ctx ) return endpoints . TCP4ServerEndpoint ( reactor , port )
tries to guess whether a description is a bare tcp port or a endpoint .