def parse_spec(opts, spec, port):

    # Example spec: http://Administrator:password@HOST:8091
    p = urlparse.urlparse(spec)

    # Example netloc: Administrator:password@HOST:8091
    #ParseResult tuple(scheme, netloc, path, params, query, fragment)
    netloc = p[1]

    if not netloc: # When urlparse() can't parse non-http URI's.
        netloc = spec.split('://')[-1].split('/')[0]

    pair = netloc.split('@') # [ "user:pwsd", "host:port" ].
    host = (pair[-1] + ":" + str(port)).split(':')[0]
    port = (pair[-1] + ":" + str(port)).split(':')[1]

    username = opts.username
    password = opts.password
    if len(pair) > 1:
        username = username or (pair[0] + ':').split(':')[0] \
            or os.environ['CB_REST_USERNAME'] or ''
        password = password or (pair[0] + ':').split(':')[1] \
            or os.environ['CB_REST_PASSWORD'] or ''

    return host, port, username, password, p[2]
Main entry point
dataset/ETHPy150Open membase/membase-cli/pump.py/parse_spec--crossover with--dataset/ETHPy150Open aldebaran/qibuild/python/qibuild/actions/package.py/do