コード例 #1
0
ファイル: test_indexing.py プロジェクト: yunstanford/devpi
def test_doc_unpack_cleanup(mapp, testapp):
    api = mapp.create_and_use()
    content = zip_dict({
        "index.html": "<html><body>2.6</body></html>",
        "foo.html": "<html><body>Foo</body></html>"
    })
    mapp.set_versiondata({"name": "pkg1", "version": "2.6"})
    mapp.upload_doc("pkg1.zip",
                    content,
                    "pkg1",
                    "2.6",
                    code=200,
                    waithooks=True)
    with mapp.xom.keyfs.transaction(write=False):
        stage = mapp.xom.model.getstage(api.stagename)
        path = get_unpack_path(stage, 'pkg1', '2.6')
    testapp.xget(200, api.index + '/pkg1/2.6/+doc/foo.html')
    assert path.join('foo.html').exists()
    content = zip_dict({"index.html": "<html><body>2.6</body></html>"})
    mapp.upload_doc("pkg1.zip",
                    content,
                    "pkg1",
                    "2.6",
                    code=200,
                    waithooks=True)
    with mapp.xom.keyfs.transaction(write=False):
        stage = mapp.xom.model.getstage(api.stagename)
        path = get_unpack_path(stage, 'pkg1', '2.6')
    testapp.xget(404, api.index + '/pkg1/2.6/+doc/foo.html')
    assert not path.join('foo.html').exists()
コード例 #2
0
def get_doc_info(context, request):
    relpath = request.matchdict['relpath']
    if not relpath:
        raise HTTPFound(location="index.html")
    name = context.project
    version = context.version
    if version == 'latest':
        versions = context.versions
    elif version == 'stable':
        versions = context.stable_versions
    else:
        versions = [version]
    for doc_version in versions:
        doc_path = get_unpack_path(context.stage, name, doc_version)
        if doc_path.check():
            break
    if not doc_path.check():
        if version == 'stable':
            raise HTTPNotFound("No stable documentation available.")
        raise HTTPNotFound("No documentation available.")
    doc_path = doc_path.join(relpath)
    if not doc_path.check():
        raise HTTPNotFound("File %s not found in documentation." % relpath)
    return dict(doc_path=doc_path,
                relpath=relpath,
                doc_version=doc_version,
                version_mismatch=doc_version != navigation_version(context))
コード例 #3
0
ファイル: test_views_search.py プロジェクト: kaiix/devpi
def test_search_deleted_docs(mapp, testapp):
    from devpi_web.doczip import get_unpack_path
    api = mapp.create_and_use()
    mapp.set_versiondata(
        {
            "name": "pkg1",
            "version": "2.6",
            "description": "foo"
        },
        waithooks=True)
    mapp.upload_file_pypi("pkg1-2.6.tar.gz", b"content", "pkg1", "2.6")
    content = zip_dict({
        "index.html":
        "\n".join([
            "<html>", "<head><title>Foo</title></head>", "<body>Bar</body>",
            "</html>"
        ])
    })
    mapp.upload_doc("pkg1.zip",
                    content,
                    "pkg1",
                    "2.6",
                    code=200,
                    waithooks=True)
    with mapp.xom.keyfs.transaction():
        stage = mapp.xom.model.getstage(api.stagename)
        path = get_unpack_path(stage, "pkg1", "2.6")
        path.remove()
    r = testapp.get('/+search?query=bar')
    assert r.status_code == 200
    highlights = r.html.select('.packageinfo dd')
    text = [compareable_text(h.text) for h in highlights]
    assert len(text) == 1
    assert text[0].startswith("Couldn't access documentation files for pkg1 "
                              "version 2.6 on %s." % api.stagename)
コード例 #4
0
ファイル: views.py プロジェクト: t-8ch/devpi
def get_docs_info(request, stage, metadata):
    if stage.name == 'root/pypi':
        return
    name, ver = metadata["name"], metadata["version"]
    doc_path = get_unpack_path(stage, name, ver)
    if doc_path.exists():
        return dict(
            title="%s-%s" % (name, ver),
            url=request.route_url(
                "docviewroot", user=stage.user.name, index=stage.index,
                name=name, version=ver, relpath="index.html"))
コード例 #5
0
def get_docs_info(request, stage, metadata):
    if stage.ixconfig['type'] == 'mirror':
        return
    name, ver = normalize_name(metadata["name"]), metadata["version"]
    doc_path = get_unpack_path(stage, name, ver)
    if doc_path.exists():
        return dict(title="%s-%s" % (name, ver),
                    url=request.route_url("docviewroot",
                                          user=stage.user.name,
                                          index=stage.index,
                                          project=name,
                                          version=ver,
                                          relpath="index.html"))
コード例 #6
0
ファイル: views.py プロジェクト: t-8ch/devpi
def get_doc_path_info(context, request):
    relpath = request.matchdict['relpath']
    if not relpath:
        raise HTTPFound(location="index.html")
    name = context.name
    version = context.version
    if version != 'latest':
        versions = [version]
    else:
        versions = context.versions
    for version in versions:
        doc_path = get_unpack_path(context.stage, name, version)
        if doc_path.check():
            break
    if not doc_path.check():
        raise HTTPNotFound("No documentation available.")
    doc_path = doc_path.join(relpath)
    if not doc_path.check():
        raise HTTPNotFound("File %s not found in documentation." % relpath)
    return doc_path, relpath