本文整理汇总了Python中dexy.wrapper.Wrapper.to_valid方法的典型用法代码示例。如果您正苦于以下问题:Python Wrapper.to_valid方法的具体用法?Python Wrapper.to_valid怎么用?Python Wrapper.to_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dexy.wrapper.Wrapper
的用法示例。
在下文中一共展示了Wrapper.to_valid方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_pattern_node
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [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 == []
示例2: test_text_parser
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_text_parser():
with wrap() as wrapper:
with open("f1.py", "w") as f:
f.write("print 'hello'")
with open("f2.py", "w") as f:
f.write("print 'hello'")
with open("index.md", "w") as f:
f.write("")
wrapper = Wrapper()
wrapper.to_valid()
wrapper.nodes = {}
wrapper.roots = []
wrapper.batch = dexy.batch.Batch(wrapper)
wrapper.filemap = wrapper.map_files()
ast = AbstractSyntaxTree(wrapper)
parser = TextFile(wrapper, ast)
parser.parse(".", """
*.py
*.py|pyg
*.md|jinja
""")
ast.walk()
assert len(wrapper.nodes) == 8
示例3: test_error_if_to_valid_called_without_dirs_setup
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_error_if_to_valid_called_without_dirs_setup():
with tempdir():
wrapper = Wrapper()
try:
wrapper.to_valid()
assert False, "should not get here"
except InternalDexyProblem:
assert True
示例4: test_create_remove_dexy_dirs
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_create_remove_dexy_dirs():
with tempdir():
wrapper = Wrapper()
wrapper.create_dexy_dirs()
wrapper.to_valid()
assert wrapper.dexy_dirs_exist()
wrapper.remove_dexy_dirs()
assert not wrapper.dexy_dirs_exist()
示例5: test_parse_doc_configs_no_configs
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_parse_doc_configs_no_configs():
with tempdir():
with capture_stdout() as stdout:
wrapper = Wrapper()
wrapper.create_dexy_dirs()
wrapper = Wrapper()
wrapper.to_valid()
wrapper.to_walked()
value = stdout.getvalue()
assert "didn't find any document config files" in value
示例6: test_walked
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_walked():
with tempdir():
with open("dexy.yaml", "w") as f:
f.write("foo.txt")
with open("foo.txt", "w") as f:
f.write("foo")
wrapper = Wrapper()
wrapper.create_dexy_dirs()
wrapper.to_valid()
wrapper.to_walked()
wrapper.validate_state('walked')
示例7: test_parse_doc_configs_single_empty_config
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_parse_doc_configs_single_empty_config():
with tempdir():
wrapper = Wrapper()
wrapper.create_dexy_dirs()
with open("dexy.yaml", "w") as f:
f.write("foo.txt")
with open("foo.txt", "w") as f:
f.write("foo")
wrapper = Wrapper()
wrapper.to_valid()
wrapper.to_walked()
示例8: test_init_wrapper_if_dexy_dirs_exist
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_init_wrapper_if_dexy_dirs_exist():
with tempdir():
wrapper = Wrapper()
wrapper.create_dexy_dirs()
with open("hello.txt", "w") as f:
f.write("hello")
wrapper = Wrapper()
wrapper.to_valid()
assert wrapper.project_root
wrapper.to_walked()
assert 'hello.txt' in wrapper.filemap
assert 'dexy.log' in os.listdir('.dexy')
assert not '.dexy/dexy.log' in wrapper.filemap
示例9: test_pattern_node_one_filter
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_pattern_node_one_filter():
with wrap() as wrapper:
with open("foo.txt", "w") as f:
f.write("foo!")
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|dexy", wrapper=wrapper)
doc = node.children[0]
assert doc.key == "foo.txt|dexy"
assert doc.filter_aliases == ['dexy']
assert doc.parent == node
示例10: test_config_for_directory
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_config_for_directory():
with wrap() as wrapper:
with open("dexy.yaml", "w") as f:
f.write(""".abc""")
with open("root.abc", "w") as f:
f.write("hello")
with open("root.def", "w") as f:
f.write("hello")
os.makedirs("s1")
os.makedirs("s2")
with open("s1/s1.abc", "w") as f:
f.write("hello")
with open("s1/s1.def", "w") as f:
f.write("hello")
with open("s2/s2.abc", "w") as f:
f.write("hello")
with open("s2/s2.def", "w") as f:
f.write("hello")
with open(os.path.join('s1', 'dexy.yaml'), 'w') as f:
f.write(""".def|dexy""")
wrapper = Wrapper()
wrapper.to_valid()
wrapper.to_walked()
wrapper.to_checked()
wrapper.run()
assert len(wrapper.nodes) == 6
p = wrapper.nodes["pattern:*.abc"]
c = wrapper.nodes["doc:s2/s2.abc"]
assert c in p.children
示例11: test_except_patterndoc_pattern
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_except_patterndoc_pattern():
with wrap() as wrapper:
with open("exceptme.abc", "w") as f:
f.write("hello")
wrapper = Wrapper()
wrapper.to_valid()
wrapper.nodes = {}
wrapper.roots = []
wrapper.batch = dexy.batch.Batch(wrapper)
wrapper.filemap = wrapper.map_files()
ast = AbstractSyntaxTree(wrapper)
parser = Yaml(wrapper, ast)
parser.parse('.', """.abc:\n - except : 'exceptme.*' """)
ast.walk()
wrapper.transition('walked')
wrapper.to_checked()
wrapper.run()
assert len(wrapper.nodes) == 1
示例12: test_nodexy_files
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_nodexy_files():
with tempdir():
wrapper = Wrapper()
wrapper.create_dexy_dirs()
with open("hello.txt", "w") as f:
f.write("hello")
os.makedirs("s1/s2/s3")
nodexy_path = "s1/s2/.nodexy"
with open(nodexy_path, 'w') as f:
f.write("dexy stop here")
with open("s1/s2/ignore.txt", "w") as f:
f.write("dexy should ignore this")
with open("s1/s2/s3/ignore.txt", "w") as f:
f.write("dexy should also ignore this")
# Only the hello.txt file is visible to dexy
wrapper = Wrapper()
wrapper.to_valid()
wrapper.to_walked()
assert len(wrapper.filemap) == 1
assert 'hello.txt' in wrapper.filemap
os.remove(nodexy_path)
# Now we can see all 3 text files.
wrapper = Wrapper()
wrapper.to_valid()
wrapper.to_walked()
assert len(wrapper.filemap) == 3
assert 'hello.txt' in wrapper.filemap
assert 's1/s2/ignore.txt' in wrapper.filemap
assert 's1/s2/s3/ignore.txt' in wrapper.filemap
示例13: test_state_valid_after_to_valid
# 需要导入模块: from dexy.wrapper import Wrapper [as 别名]
# 或者: from dexy.wrapper.Wrapper import to_valid [as 别名]
def test_state_valid_after_to_valid():
with tempdir():
wrapper = Wrapper()
wrapper.create_dexy_dirs()
wrapper.to_valid()
wrapper.validate_state('valid')