Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/tools/build/v2/test/load_dir.py @ 32

Last change on this file since 32 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 1.7 KB
Line 
1#!/usr/bin/python
2
3"""
4Traverses a directory and output the code that would
5create the same directory structure during testing.
6Assumes that the instance of Tester is called 't'.
7"""
8
9import sys
10import os
11import stat
12import string
13
14def usage():
15    print "usage: load_dir.py directory"
16
17def 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
28def create_file(arg, dirname, fnames):
29    for n in fnames:
30        path = os.path.join(dirname, n)
31        if not os.path.isdir(path):
32            print "t.write(\"%s\", \"\"\"" % (remove_first_component(path),),
33            f = open(path, "r")
34            for l in f:
35                print l,
36            print '\n""")\n'
37
38header =  """#!/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
45from BoostBuild import Tester, List
46import string
47
48t = Tester()
49"""
50
51footer = """
52
53t.run_build_system()
54
55t.expect_addition("bin/$toolset/debug/FILL_SOME_HERE.exe")
56
57t.cleanup()
58"""
59   
60def 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
79if __name__ == '__main__':
80    main()
81
82       
83       
84   
Note: See TracBrowser for help on using the repository browser.