]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/load_dir.py
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / test / load_dir.py
1 #!/usr/bin/python
2
3 """
4 Traverses a directory and output the code that would create the same directory
5 structure during testing. Assumes that the instance of Tester is called 't'.
6 """
7
8 import sys
9 import os
10 import stat
11 import string
12
13 def usage():
14 print "usage: load_dir.py directory"
15
16
17 def remove_first_component(path):
18 result = [path]
19 while 1:
20 s = os.path.split(result[0])
21 if not s[0]:
22 break
23 result[:1] = list(s)
24 return apply(os.path.join, result[1:])
25
26
27 def create_file(arg, dirname, fnames):
28 for n in fnames:
29 path = os.path.join(dirname, n)
30 if not os.path.isdir(path):
31 print "t.write(\"%s\", \"\"\"" % (remove_first_component(path),),
32 f = open(path, "r")
33 for l in f:
34 print l,
35 print '\n""")\n'
36
37
38 header = """#!/usr/bin/python
39
40 # Copyright (C) FILL SOMETHING HERE 2005.
41 # Distributed under the Boost Software License, Version 1.0. (See
42 # accompanying file LICENSE_1_0.txt or copy at
43 # http://www.boost.org/LICENSE_1_0.txt)
44
45 import BoostBuild
46
47 t = BoostBuild.Tester()
48 """
49
50 footer = """
51
52 t.run_build_system()
53
54 t.expect_addition("bin/$toolset/debug*/FILL_SOME_HERE.exe")
55
56 t.cleanup()
57 """
58
59
60 def main():
61 if len(sys.argv) != 2:
62 usage()
63 else:
64 path = sys.argv[1]
65
66 if not os.access(path, os.F_OK):
67 print "Path '%s' does not exist" % (path,)
68 sys.exit(1)
69
70 if not os.path.isdir(path):
71 print "Path '%s' is not a directory" % (path,)
72
73 print header
74
75 os.path.walk(path, create_file, None)
76
77 print footer
78
79
80 if __name__ == '__main__':
81 main()