def _check_url(url, login, allowed, mindepth=0):
    """Check if HTTP GET `url` returns a status code in `allowed`."""
    if mindepth:
        scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
        path = '/'.join(path.split('/')[:mindepth+1]).rstrip('/') + '/'
        url = urlparse.urlunparse((scheme, netloc, path, params, query, fragment))

    trace("Checking URL '%(url)s'", url=url)
    try:
        # Could use a HTTPBasicAuthHandler here, but meh!
        # Should use 'requests', but dependency hell.
        request = urllib2.Request(url)
        request.add_header("Authorization", 'Basic %s' % login.encode('base64').replace('\n', '').strip())
        with closing(urllib2.urlopen(request)) as handle:
            handle.read()
            code = handle.code
            if allowed not in code:
                raise urllib2.HTTPError(url, code,
                    "Unallowed HTTP status %d (%s)" % (code, handle.msg),
                    handle.headers, None)
    except urllib2.HTTPError, exc:
        code = exc.code
        if code not in allowed:
            raise

    trace("Code %(code)d OK for URL '%(url)s'", url=url, code=code)
dataset/ETHPy150Open jhermann/artifactory-debian/dput-webdav/webdav.py/_check_url/swapped operands of `not in`