'Convert a legacy URL to a job destination'

def url_to_destination(self, url):

    if (not url):
        return
    url_split = url.split('/')
    server = url_split[2]
    if (server == ''):
        server = self.default_pbs_server
    if (server is None):
        raise Exception('Could    not    find    TORQUE    server')
    pbs_destination = ('@%s' % server)
    pbs_queue = (url_split[3] or None)
    if (pbs_queue is not None):
        pbs_destination = ('%s%s' % (pbs_queue, pbs_destination))
    params = dict(destination=pbs_destination)
    try:
        opts = url.split('/')[4].strip().lstrip('-').split('    -')
        assert (opts != [''])
        for (i, opt) in enumerate(opts):
            opts[i] = ('-' + opt)
    except:
        opts = []
    for opt in opts:
        (param, value) = opt.split(None, 1)
        params[param] = value
    log.debug(("Converted    URL    '%s'    to    destination    runner=pbs,    params=%s" % (url, params)))
    return JobDestination(runner='pbs', params=params)
