当前位置: 首页>>代码示例>>Python>>正文


Python doc.Doc类代码示例

本文整理汇总了Python中dexy.doc.Doc的典型用法代码示例。如果您正苦于以下问题:Python Doc类的具体用法?Python Doc怎么用?Python Doc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Doc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_jinja_pass_through

def test_jinja_pass_through():
    with wrap() as wrapper:
        with open("_template.html", "w") as f:
            f.write("{{ content }}")

        wrapper.reports = 'ws'
        contents = u"{{ link('input.txt') }}"
        doc = Doc("lines.html|jinja",
                    wrapper,
                    [
                        Doc("input.txt",
                            wrapper,
                            [],
                            contents = "nothing to see here"
                            )
                        ],
                    contents=contents,
                    apply_ws_to_content = True
                    )
        wrapper.run_docs(doc)
        assert unicode(doc.output_data()) == contents

        wrapper.report()

        with open("output-site/lines.html", 'r') as f:
            lines_html = f.read()
            assert lines_html == """<a href="/input.txt">Input</a>"""
开发者ID:horaciovasconcellos,项目名称:dexy,代码行数:27,代码来源:test_templating_filters.py

示例2: test_yamlargs_filterargs

def test_yamlargs_filterargs():
    with wrap() as wrapper:
        doc = Doc("example.txt|yamlargs|filterargs",
                wrapper,
                [],
                contents = "%s\n---\r\nThis is the content." % YAML,
                )

        wrapper.run_docs(doc)

        output = doc.output_data().as_text()
        assert "abc: xyz" in output
        assert "foo: 5" in output

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs|filterargs",
                wrapper,
                [],
                contents = "%s\n---\r\nThis is the content." % YAML,
                )

        wrapper.run_docs(doc)

        output = doc.output_data().as_text()
        assert "abc: xyz" in output
        assert "foo: 5" in output
开发者ID:aioupload,项目名称:dexy,代码行数:26,代码来源:test_yamlargs_filters.py

示例3: test_split_html_filter

def test_split_html_filter():
    with wrap() as wrapper:
        contents="""
        <p>This is at the top.</p>
        <!-- split "a-page" -->
        some content on a page
        <!-- split "another-page" -->
        some content on another page
        <!-- endsplit -->
        bottom
        """

        doc = Doc("subdir/example.html|splithtml", contents=contents, wrapper=wrapper)
        wrapper.docs = [doc]
        wrapper.run()

        assert doc.children[2].key == "subdir/a-page.html"
        assert doc.children[3].key == "subdir/another-page.html"

        od = doc.output().data()

        assert "<p>This is at the top.</p>" in od
        assert '<a href="a-page.html">' in od
        assert '<a href="another-page.html">' in od
        assert "bottom" in od

        assert "<p>This is at the top.</p>" in doc.children[2].output().data()
        assert "some content on a page" in doc.children[2].output().data()
        assert "bottom" in doc.children[2].output().data()

        assert "<p>This is at the top.</p>" in doc.children[3].output().data()
        assert "some content on another page" in doc.children[3].output().data()
        assert "bottom" in doc.children[3].output().data()
开发者ID:adityaathalye,项目名称:dexy,代码行数:33,代码来源:test_split_filters.py

示例4: test_regetron_filter

def test_regetron_filter():
    with wrap() as wrapper:
        wrapper.debug = False
        node = Doc("example.regex|regetron",
                wrapper,
                [
                    Doc("input1.txt",
                        wrapper,
                        [],
                        contents=REGETRON_INPUT_1),
                    Doc("input2.txt",
                        wrapper,
                        [],
                        contents=REGETRON_INPUT_2)
                    ],
                contents="^[a-z\s]+$"
                )

        wrapper.run_docs(node)
        
        if not wrapper.state == 'error':
            assert str(node.output_data()['input1.txt']) == """\
> ^[a-z\s]+$
0000: hello
> 

"""
            assert str(node.output_data()['input2.txt']) == """\
开发者ID:GWhized,项目名称:dexy,代码行数:28,代码来源:test_stdout_input_filters.py

示例5: test_pydoc_filter_on_module_names

def test_pydoc_filter_on_module_names():
    with wrap() as wrapper:
        doc = Doc("modules.txt|pydoc", wrapper, [], contents="os math")
        wrapper.run_docs(doc)
        data = doc.output_data()
        assert len(data.keys()) > 100
        assert data["math.e:value"].startswith("2.71828")
开发者ID:GWhized,项目名称:dexy,代码行数:7,代码来源:test_pydoc_filters.py

示例6: test_access_other_documents

def test_access_other_documents():
    with temprun() as runner:
        doc = Doc("hello.txt|newdoc", contents="hello", runner=runner)
        parent = Doc("test.txt|others", doc, contents="hello", runner=runner)
        runner.docs = [parent]
        runner.run()
        assert parent.output().data() == """Here is a list of previous docs in this tree (not including test.txt|others).
开发者ID:tomspur,项目名称:dexy,代码行数:7,代码来源:test_example_filters.py

示例7: test_java_filter

def test_java_filter():
    with wrap() as wrapper:
        doc = Doc("hello.java|java",
                contents=JAVA_SRC,
                wrapper=wrapper)
        wrapper.docs = [doc]
        wrapper.run()
        assert doc.output().data() == "Java Hello World!\n"
开发者ID:adityaathalye,项目名称:dexy,代码行数:8,代码来源:test_java_filters.py

示例8: test_rst2odt

def test_rst2odt():
    with wrap() as wrapper:
        doc = Doc("example.txt|rst2odt",
                contents=RST,
                wrapper=wrapper)
        wrapper.docs = [doc]
        wrapper.run()
        assert doc.output().filesize() > 8000
开发者ID:adityaathalye,项目名称:dexy,代码行数:8,代码来源:test_restructured_test_filters.py

示例9: test_key_value_example

def test_key_value_example():
    with wrap() as wrapper:
        doc = Doc("hello.txt|keyvalueexample", contents="hello", wrapper=wrapper)

        wrapper.docs = [doc]
        wrapper.run()

        assert doc.output().as_text() == "foo: bar"
开发者ID:evelynmitchell,项目名称:dexy,代码行数:8,代码来源:test_example_filters.py

示例10: test_pydoc_filter

def test_pydoc_filter():
    with wrap() as wrapper:
        doc = Doc("modules.txt|pydoc", contents="os math", wrapper=wrapper)
        wrapper.docs = [doc]
        wrapper.run()
        assert "os.ttyname:html-source" in doc.output().keys()

        print doc.output().query("math.log")
开发者ID:adityaathalye,项目名称:dexy,代码行数:8,代码来源:test_pydoc_filters.py

示例11: test_rst2odt

def test_rst2odt():
    with wrap() as wrapper:
        node = Doc("example.txt|rst2odt",
                wrapper,
                [],
                contents=RST)
        wrapper.run_docs(node)
        assert node.output_data().filesize() > 8000
开发者ID:GWhized,项目名称:dexy,代码行数:8,代码来源:test_restructured_test_filters.py

示例12: test_ps2pdf_filter

def test_ps2pdf_filter():
    with wrap() as wrapper:
        node = Doc("hello.ps|ps2pdf",
                wrapper, [],
                contents = PS)
        wrapper.run_docs(node)
        assert node.output_data().is_cached()
        assert node.output_data().filesize() > 1000
开发者ID:aioupload,项目名称:dexy,代码行数:8,代码来源:test_subprocess_filters.py

示例13: test_choose_extension_from_overlap

def test_choose_extension_from_overlap():
    with wrap() as wrapper:
        doc = Doc("hello.py|pyg|forcelatex",
                contents="""print "hello, world" """,
                wrapper=wrapper)
        wrapper.docs = [doc]
        wrapper.run()
        assert "begin{Verbatim}" in doc.output().as_text()
开发者ID:adityaathalye,项目名称:dexy,代码行数:8,代码来源:test_artifact.py

示例14: test_wordpress

def test_wordpress(MockXmlrpclib):
    with wrap() as wrapper:
        with open("wordpress.json", "wb") as f:
            json.dump({}, f)

        with open(".dexyapis", "wb") as f:
            json.dump({
                'wordpress' : {
                    'url' : 'http://example.com',
                    'username' : 'foo',
                    'password' : 'bar'
                    }}, f)

        # Create new (unpublished) draft
        doc = mk_wp_doc(wrapper)
        wrapper.run_docs(doc)

        with open("wordpress.json", "rb") as f:
            result = json.load(f)

        assert result['postid'] == 42
        assert result['publish'] == False

        # Update existing draft
        doc = mk_wp_doc(wrapper)
        wrapper.run_docs(doc)
        assert doc.output().json_as_dict().keys() == ['permaLink']

        result['publish'] = True
        with open("wordpress.json", "wb") as f:
            json.dump(result, f)

        # Publish existing draft
        doc = mk_wp_doc(wrapper)
        wrapper.run_docs(doc)
        assert doc.output().as_text() == "http://example.com/blog/42"

        # Now, separately, test an image upload.
        orig = os.path.join(TEST_DATA_DIR, 'color-graph.pdf')
        shutil.copyfile(orig, 'example.pdf')
        doc = Doc("example.pdf|wp",
                wrapper=wrapper)

        with open(".dexyapis", "wb") as f:
            json.dump({
                'wordpress' : {
                    'url' : 'http://example.com',
                    'username' : 'foo',
                    'password' : 'bar'
                    }}, f)

        wrapper.run_docs(doc)
        assert doc.output().as_text() == "http://example.com/example.pdf"

        # test list categories
        with divert_stdout() as stdout:
            WordPressFilter.docmd_list_categories()
            assert stdout.getvalue() == "categoryName\nfoo\nbar\n"
开发者ID:adityaathalye,项目名称:dexy,代码行数:58,代码来源:test_wordpress_filters.py

示例15: test_pdfcrop_filter

def test_pdfcrop_filter():
    with wrap() as wrapper:
        orig = os.path.join(TEST_DATA_DIR, 'color-graph.pdf')
        shutil.copyfile(orig, 'example.pdf')
        wrapper=Wrapper()
        node = Doc("example.pdf|pdfcrop|pdfinfo", wrapper)

        wrapper.run_docs(node)
        assert node.output_data().is_cached()
开发者ID:aioupload,项目名称:dexy,代码行数:9,代码来源:test_subprocess_filters.py


注:本文中的dexy.doc.Doc类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。