@staticmethod
def _parse_conn(server, default_name):
    """Parse a connection string of form (user@)server(:port)"""
    import re
    pat = '^((?P<name>.+)@)?(?P<server>.*?)(:(?P<port>\\d{1,5}))?$'
    match = re.match(pat, server)
    server = match.group('server')
    name = match.group('name')
    port = match.group('port')
    if not name:
        name = default_name
    return server, name, port
