本文整理汇总了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
示例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 == []
示例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'
示例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()
示例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()
示例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()
示例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()
示例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
示例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'