]> git.saurik.com Git - wxWidgets.git/blob - wxPython/distrib/genfilelist.py
Added SF Patch#
[wxWidgets.git] / wxPython / distrib / genfilelist.py
1 """
2 Walk a directory tree and output a filename list suitable for use
3 in an RPM spec.
4
5 Usage: genfilelist.py [-r] build_root filespec(s)
6
7 """
8
9
10 import sys, os, glob, stat
11
12
13 def walktree(names, buildroot, recurse):
14 for name in names:
15 isdir = os.path.isdir(name)
16 printfilename(name, buildroot, isdir)
17 if isdir and recurse:
18 walktree([os.path.join(name, x) for x in os.listdir(name)], buildroot, recurse)
19
20
21 def printfilename(name, buildroot, isdir):
22 s = os.lstat(name)
23 realname = name[len(buildroot):]
24 if isdir:
25 fmt = "%%dir %%attr(%o, root, root) %s"
26 else:
27 fmt = "%%attr(%o, root, root) %s"
28 print fmt % (s[stat.ST_MODE] & 0777, realname)
29
30
31 def main(args):
32 if args[0] == '-r':
33 recurse = 1
34 args = args[1:]
35 else:
36 recurse = 0
37
38 if len(args) < 2:
39 print __str__
40 sys.exit(1)
41
42 buildroot = args[0]
43 for arg in args[1:]:
44 if arg[0] == '/':
45 arg = arg[1:]
46 walktree(glob.glob(os.path.join(buildroot, arg)), buildroot, recurse)
47
48 if __name__ == "__main__":
49 main(sys.argv[1:])
50
51