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


Python Wrapper.run_docs方法代码示例

本文整理汇总了Python中dexy.wrapper.Wrapper.run_docs方法的典型用法代码示例。如果您正苦于以下问题:Python Wrapper.run_docs方法的具体用法?Python Wrapper.run_docs怎么用?Python Wrapper.run_docs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dexy.wrapper.Wrapper的用法示例。


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

示例1: test_yamlargs_filterargs

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
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,代码行数:28,代码来源:test_yamlargs_filters.py

示例2: test_pattern_node

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_pattern_node():
    with wrap() as wrapper:
        with open("foo.txt", "w") as f:
            f.write("foo!")

        with open("bar.txt", "w") as f:
            f.write("bar!")

        wrapper = Wrapper(log_level='DEBUG')
        wrapper.to_valid()

        wrapper.nodes = {}
        wrapper.roots = []
        wrapper.batch = dexy.batch.Batch(wrapper)
        wrapper.filemap = wrapper.map_files()

        node = PatternNode("*.txt", 
                wrapper,
                [],
                foo="bar")
        assert node.args['foo'] == 'bar'
        wrapper.run_docs(node)
        assert len(node.children) == 2

        for child in node.children:
            assert child.__class__.__name__ == "Doc"
            assert child.args['foo'] == 'bar'
            assert child.key_with_class() in ["doc:foo.txt", "doc:bar.txt"]
            assert child.filters == []
开发者ID:aioupload,项目名称:dexy,代码行数:31,代码来源:test_node.py

示例3: test_yamlargs_with_caching

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_yamlargs_with_caching():
    with wrap() as wrapper:
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)

        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'ran'

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)
        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'consolidated'

        wrapper = Wrapper()
        doc = Doc("example.txt|yamlargs",
                wrapper,
                [],
                contents = "title: My Title\n---\r\nThis is the content."
                )
        wrapper.run_docs(doc)
        task = wrapper.nodes["doc:example.txt|yamlargs"]
        assert task.output_data().title() == "My Title"
        assert task.state == 'consolidated'
开发者ID:aioupload,项目名称:dexy,代码行数:36,代码来源:test_yamlargs_filters.py

示例4: test_zip_archive_filter

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_zip_archive_filter():
    with tempdir():
        with open("hello.py", "w") as f:
            f.write("print 'hello'")

        with open("hello.rb", "w") as f:
            f.write("puts 'hello'")

        wrapper = Wrapper()
        wrapper.create_dexy_dirs()
        wrapper = Wrapper()

        doc = Doc("archive.zip|zip",
                wrapper,
                [
                    Doc("hello.py", wrapper),
                    Doc("hello.rb", wrapper),
                    Doc("hello.py|pyg", wrapper),
                    Doc("hello.rb|pyg", wrapper)
                    ],
                contents=" ")

        wrapper.run_docs(doc)
        wrapper.report()

        path_exists = os.path.exists("output/archive.zip")
        assert path_exists
        z = zipfile.ZipFile("output/archive.zip", "r")
        names = z.namelist()
        assert "archive/hello.py" in names
        assert "archive/hello.rb" in names
        assert "archive/hello.py-pyg.html" in names
        assert "archive/hello.rb-pyg.html" in names
        z.close()
开发者ID:GWhized,项目名称:dexy,代码行数:36,代码来源:test_archive_filters.py

示例5: test_archive_filter

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_archive_filter():
    with wrap() as wrapper:
        with open("hello.py", "w") as f:
            f.write("print 'hello'")

        with open("hello.rb", "w") as f:
            f.write("puts 'hello'")

        wrapper = Wrapper()
        wrapper.create_dexy_dirs()
        wrapper = Wrapper()

        doc = Doc("archive.tgz|archive",
                wrapper,
                [
                    Doc("hello.py", wrapper),
                    Doc("hello.rb", wrapper),
                    Doc("hello.py|pyg", wrapper),
                    Doc("hello.rb|pyg", wrapper)
                ],
                contents=" ")

        wrapper.run_docs(doc)
        wrapper.report()

        assert os.path.exists("output/archive.tgz")
        tar = tarfile.open("output/archive.tgz", mode="r:gz")
        names = tar.getnames()
        assert "archive/hello.py" in names
        assert "archive/hello.rb" in names
        assert "archive/hello.py-pyg.html" in names
        assert "archive/hello.rb-pyg.html" in names
        tar.close()
开发者ID:GWhized,项目名称:dexy,代码行数:35,代码来源:test_archive_filters.py

示例6: test_unprocessed_directory_archive_filter

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_unprocessed_directory_archive_filter():
    with wrap() as wrapper:
        with open("abc.txt", "w") as f:
            f.write('this is abc')

        with open("def.txt", "w") as f:
            f.write('this is def')

        wrapper = Wrapper()
        wrapper.create_dexy_dirs()
        wrapper = Wrapper()

        doc = Doc("archive.tgz|tgzdir",
                wrapper,
                [],
                contents="ignore",
                tgzdir={'dir' : '.'}
                )
        wrapper.run_docs(doc)
        wrapper.report()

        assert os.path.exists("output/archive.tgz")
        tar = tarfile.open("output/archive.tgz", mode="r:gz")
        names = tar.getnames()

        assert ("./abc.txt" in names) or ("abc.txt" in names)
        assert ("./def.txt" in names) or ("def.txt" in names)
        tar.close()
开发者ID:GWhized,项目名称:dexy,代码行数:30,代码来源:test_archive_filters.py

示例7: test_pdfcrop_filter

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
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,代码行数:11,代码来源:test_subprocess_filters.py

示例8: test_casperjs_svg2pdf_filter

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_casperjs_svg2pdf_filter():
    # TODO find smaller file - make test go faster?
    with wrap() as wrapper:
        orig = os.path.join(TEST_DATA_DIR, 'butterfly.svg')
        shutil.copyfile(orig, 'butterfly.svg')

        from dexy.wrapper import Wrapper
        wrapper = Wrapper()

        node = Doc("butterfly.svg|svg2pdf", wrapper)

        wrapper.run_docs(node)

        assert node.output_data().is_cached()
        assert node.output_data().filesize() > 1000
开发者ID:aioupload,项目名称:dexy,代码行数:17,代码来源:test_phantomjs_filters.py

示例9: test_node_caching__slow

# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import run_docs [as 别名]
def test_node_caching__slow():
    with wrap() as wrapper:
        with open("hello.py", "w") as f:
            f.write("print 1+2\n")

        with open("doc.txt", "w") as f:
            f.write("1 + 1 = {{ d['hello.py|py'] }}")

        wrapper = Wrapper(log_level='DEBUG')
        hello_py = Doc("hello.py|py", wrapper)
        doc_txt = Doc("doc.txt|jinja",
                wrapper,
                [hello_py]
                )

        wrapper.run_docs(doc_txt)

        assert str(doc_txt.output_data()) == "1 + 1 = 3\n"
        assert str(hello_py.output_data()) == "3\n"

        assert hello_py.state == 'ran'
        assert doc_txt.state == 'ran'

        wrapper = Wrapper(log_level='DEBUG')
        hello_py = Doc("hello.py|py", wrapper)
        doc_txt = Doc("doc.txt|jinja",
                wrapper,
                [hello_py]
                )
        wrapper.run_docs(doc_txt)

        assert hello_py.state == 'consolidated'
        assert doc_txt.state == 'consolidated'

        time.sleep(1.1)
        with open("doc.txt", "w") as f:
            f.write("1 + 1 = {{ d['hello.py|py'] }}\n")

        wrapper = Wrapper(log_level='DEBUG')
        hello_py = Doc("hello.py|py", wrapper)
        doc_txt = Doc("doc.txt|jinja",
                wrapper,
                [hello_py]
                )
        wrapper.run_docs(doc_txt)

        assert hello_py.state == 'consolidated'
        assert doc_txt.state == 'ran'

        time.sleep(1.1)
        with open("hello.py", "w") as f:
            f.write("print 1+1\n")

        wrapper = Wrapper(log_level='DEBUG')
        hello_py = Doc("hello.py|py", wrapper)
        doc_txt = Doc("doc.txt|jinja",
                wrapper,
                [hello_py]
                )
        wrapper.run_docs(doc_txt)

        assert hello_py.state == 'ran'
        assert doc_txt.state == 'ran'
开发者ID:aioupload,项目名称:dexy,代码行数:65,代码来源:test_node.py


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