waf/docs/book/examples/nodes_search/wscript

34 lines
624 B
Python

#! /usr/bin/env python
"""
find_node -> create or return a node corresponding to an existing path
make_node -> create a node object, even if there is no folder or file
search -> search for a node in the existing node hierarchy (do not ask the file system)
Try:
$ waf configure dosomething
"""
top = '.'
out = 'build'
def configure(ctx):
pass
def dosomething(ctx):
print(ctx.path.find_node('wscript'))
nd1 = ctx.path.make_node('foo.txt')
print(nd1)
nd2 = ctx.path.search('foo.txt')
print(nd2)
nd3 = ctx.path.search('bar.txt')
print(nd3)
nd2.write('some text')
print(nd2.read())
print(ctx.path.listdir())