]> git.donarmstrong.com Git - lilypond.git/commitdiff
(is_derived_class): new function. Take
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 12:41:52 +0000 (12:41 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2004 12:41:52 +0000 (12:41 +0000)
class arg iso. object.

ChangeLog
scripts/lilypond-book.py

index 09612884e0e7540991447c3a36e170022fdbe735..dae37a15dc26b20a8eb64f186e3084ce2ed152b1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2004-03-22  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scripts/lilypond-book.py (is_derived_class): new function. Take
+       class arg iso. object.
+
        * lily/text-item.cc (interpret_markup): idem.
 
        * scm/define-markup-commands.scm: remove split around-space hack.
index fce567e274c00b6ab8544944b999281f13ac682a..216f7c4cb413b22be1559f4cb51069b15d083bf4 100644 (file)
@@ -718,18 +718,14 @@ def filter_pipe (input, cmd):
 def run_filter (s):
        return filter_pipe (s, filter_cmd)
 
-def is_derived (object, base):
-       def recurse (cl,  baseclass):
-               if cl == baseclass:
+def is_derived_class (cl,  baseclass):
+       if cl == baseclass:
+               return True
+       for b in cl.__bases__:
+               if is_derived_class (b, baseclass):
                        return True
-               for b in cl.__bases__:
-                       if recurse (b, baseclass):
-                               return True
-               return False
-                       
-       cl = object.__class__
-       return recurse (cl, base)
-       
+       return False
+
 
 def process_snippets (cmd, snippets):
        names = filter (lambda x: x, map (Lilypond_snippet.basename, snippets))
@@ -891,7 +887,7 @@ def do_file (input_filename):
                
                
        elif process_cmd:
-               outdated = filter (lambda x: is_derived (x, Lilypond_snippet) \
+               outdated = filter (lambda x: is_derived_class (x.__class__, Lilypond_snippet) \
                                   and x.is_outdated (), chunks)
                ly.progress (_ ("Writing snippets..."))
                map (Lilypond_snippet.write_ly, outdated)
@@ -917,7 +913,7 @@ def do_file (input_filename):
                do_file (name)
                
        map (process_include,
-            filter (lambda x: is_derived (x, Include_snippet), chunks))
+            filter (lambda x: is_derived_class (x.__class__, Include_snippet), chunks))
 
 def do_options ():
        global format, output_name