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