]> git.donarmstrong.com Git - lilypond.git/blob - bin/flower.py
release: 0.1.57
[lilypond.git] / bin / flower.py
1 #!@PYTHON@
2
3
4 # flower.py -- python flower lib
5
6 # source file of the GNU LilyPond music typesetter
7
8 # (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9
10
11 import sys
12
13 class File:
14     """silly wrapper for Python file object."""
15     def __init__ (self,nm, mode='r'):
16         if nm:
17             self.file_ = open (nm, mode);
18         elif mode == 'w':
19             self.file_ = sys.stdout
20         else:
21             self.file_ = sys.stdin
22             
23         self.eof_ = 0;
24     def readline (self):
25         l=  self.file_.readline ();
26         if not l:
27             self.eof_ = 1;
28         return l;
29     def write (self, str):
30         self.file_.write (str)
31     def eof (self):
32         return self.eof_
33     def close (self):
34         self.file_.close ()
35     def __del__ (self):
36         self.close ();
37
38
39
40 import fnmatch
41 import os
42
43 _debug = 0
44
45 _prune = ['(*)']
46
47
48 def my_find(patterns, dir = os.curdir):
49         list = []
50         names = os.listdir(dir)
51         names.sort()
52         for name in names:
53                 if name in (os.curdir, os.pardir):
54                         continue
55                 fullname = os.path.join(dir, name)
56                 for pat in patterns:
57                     if fnmatch.fnmatch(name, pat):
58                         list.append(fullname)
59                 if os.path.isdir(fullname) and not os.path.islink(fullname):
60                         for p in _prune:
61                                 if fnmatch.fnmatch(name, p):
62                                         if _debug: print "skip", `fullname`
63                                         break
64                         else:
65                                 if _debug: print "descend into", `fullname`
66                                 found = my_find(patterns, fullname)
67                                 if found:
68                                     list = list + found
69         return list
70
71 def multiple_find(pats, dirnames):
72     from find import find
73     l = []
74     for d in dirnames:
75         l = l + my_find(pats,  d)
76     return l
77 #!@PYTHON@
78
79
80 # flower.py -- python flower lib
81
82 # source file of the GNU LilyPond music typesetter
83
84 # (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
85
86
87 class File:
88     """silly wrapper for Python file object."""
89     def __init__ (self,nm, mode='r'):
90         if nm:
91             self.file_ = open (nm, mode);
92         elif mode == 'w':
93             self.file_ = sys.stdout
94         else:
95             self.file_ = sys.stdin
96             
97         self.eof_ = 0;
98     def readline (self):
99         l=  self.file_.readline ();
100         if not l:
101             self.eof_ = 1;
102         return l;
103     def write (self, str):
104         self.file_.write (str)
105     def eof (self):
106         return self.eof_
107     def close (self):
108         self.file_.close ()
109     def __del__ (self):
110         self.close ();
111
112
113
114 import fnmatch
115 import os
116
117 _debug = 0
118
119 _prune = ['(*)']
120
121
122 def my_find(patterns, dir = os.curdir):
123         list = []
124         try:
125             names = os.listdir(dir)
126         except os.error:
127             names = []
128         names.sort()
129         for name in names:
130                 if name in (os.curdir, os.pardir):
131                         continue
132                 fullname = os.path.join(dir, name)
133                 for pat in patterns:
134                     if fnmatch.fnmatch(name, pat):
135                         list.append(fullname)
136                 if os.path.isdir(fullname) and not os.path.islink(fullname):
137                         for p in _prune:
138                                 if fnmatch.fnmatch(name, p):
139                                         if _debug: print "skip", `fullname`
140                                         break
141                         else:
142                                 if _debug: print "descend into", `fullname`
143                                 found = my_find(patterns, fullname)
144                                 if found:
145                                     list = list + found
146         return list
147
148 def multiple_find(pats, dirnames):
149     from find import find
150     l = []
151     for d in dirnames:
152         l = l + my_find(pats,  d)
153     return l