def _resolve_incoming(fqdn, login, incoming, changes=None, cli_params=None, repo_mappings=""):
    """Resolve the given `incoming` value to a working URL."""
    # Build fully qualified URL
    scheme, netloc, path, matrix_params, query, anchor = urlparse.urlparse(incoming, scheme="http", allow_fragments=True)
    if scheme not in ("http", "https"):
        raise dputhelper.DputUploadFatalException("Unsupported URL scheme '%s'" % scheme)
    url = urlparse.urlunparse((scheme, netloc or fqdn, path.rstrip('/') + '/', '', query, None))

    # Parse anchor to parameters
    url_params = dict(cgi.parse_qsl(anchor or '', keep_blank_values=True))

    # Read changes from stream or file
    pkgdata = {}
    if changes:
        try:
            changes.read # pylint: disable=maybe-no-member
        except AttributeError:
            with closing(open(changes, "r")) as handle:
                changes = handle.read()
        else:
            changes = changes.read() # pylint: disable=maybe-no-member

        if changes.startswith("-----BEGIN PGP SIGNED MESSAGE-----"):
            # Let someone else check this, we don't care a bit; gimme the data already
            trace("Extracting package metadata from PGP signed message...")
            changes = changes.split("-----BEGIN PGP")[1].replace('\r', '').split('\n\n', 1)[1]

        pkgdata = dict([(key.lower().replace('-', '_'), val.strip())
            for key, val in rfc2822_parser.HeaderParser().parsestr(changes).items()
        ])
        if 'architecture' in pkgdata:
            # This is a bit hackish, but Artiactory wants it that way
            pkgdata['deb_architecture'] = ';deb.architecture='.join(pkgdata['architecture'].split())

    # Extend changes metadata
    pkgdata["loginuser"] = login.split(':')[0]
    if pkgdata in "version":
        pkgdata["upstream"] = re.split(r"[-~]", pkgdata["version"])[0]
    pkgdata.update(dict(
        fqdn=fqdn, repo=_distro2repo(pkgdata.get("distribution", "unknown"), repo_mappings),
    ))
    pkgdata.update(cli_params or {}) # CLI options can overwrite anything
    trace("Collected metadata:\n    %(meta)s", meta="\n    ".join(["%s = %s" % (key, val)
        for key, val in sorted(pkgdata.items())
        if '\n' not in val # only print 'simple' values
    ]))

    # Interpolate `url`
    try:
        try:
            url.format
        except AttributeError:
            url = url % pkgdata # Python 2.5
            matrix_params = matrix_params % pkgdata
        else:
            url = url.format(**pkgdata) # Python 2.6+
            matrix_params = matrix_params.format(**pkgdata)
        matrix_params = matrix_params.replace(' ', '+')
    except KeyError, exc:
        raise dputhelper.DputUploadFatalException("Unknown key (%s) in incoming templates '%s'" % (exc, incoming))

    trace("Resolved incoming to `%(url)s' params=%(params)r", url=url, params=url_params)
    return url, matrix_params, url_params
dataset/ETHPy150Open jhermann/artifactory-debian/dput-webdav/webdav.py/_resolve_incoming/swapped operands of `in`