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