From fcf42cd1c942d83ce46bfcce9844e9d3badf1d6a Mon Sep 17 00:00:00 2001 From: Phil Holmes Date: Wed, 18 Jul 2012 17:59:22 +0100 Subject: [PATCH] Correct makelsr handling of local update and tags --- scripts/auxiliar/makelsr.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/auxiliar/makelsr.py b/scripts/auxiliar/makelsr.py index 278173f636..24dd0d900f 100755 --- a/scripts/auxiliar/makelsr.py +++ b/scripts/auxiliar/makelsr.py @@ -149,6 +149,7 @@ def exit_with_usage (n=0): options_parser.print_help (sys.stderr) sys.exit (n) +tags=[] if len (args): in_dir = args[0] if not (os.path.isdir (in_dir)): @@ -156,6 +157,9 @@ if len (args): sys.exit (4) if len (args) > 1: exit_with_usage (2) + tags = os.listdir (in_dir) + ## Make sure all users get the same ordering of tags + tags.sort() else: in_dir = '.' @@ -175,8 +179,6 @@ if not os.path.exists (lilypond_bin): lilypond_bin = "lilypond" sys.stderr.write ("Using %s, %s\n" % (convert_ly, lilypond_bin)) -tags = os.listdir (in_dir) - unsafe = [] unconverted = [] notags_files = [] @@ -305,9 +307,13 @@ def dump_file_list (file, file_list, update=False): f = open (file, 'w') f.write ('\n'.join (sorted (new_list)) + '\n') -## clean out existing lys and generated files -map (os.remove, glob.glob (os.path.join (lys_from_lsr, '*.ly')) + - glob.glob (os.path.join (lys_from_lsr, '*.snippet-list'))) +## clean out existing lys and generated files - but only when we're +## completely recreating them from the tarball. Otherwise +## tags will be empty and so we can use this to skip this step + +if len(tags) > 0: + map (os.remove, glob.glob (os.path.join (lys_from_lsr, '*.ly')) + + glob.glob (os.path.join (lys_from_lsr, '*.snippet-list'))) # read LSR source where tags are defined by subdirs snippets, tag_lists = read_source_with_dirs (in_dir) @@ -318,8 +324,8 @@ snippets.update (s) for t in tags: tag_lists[t].update (l[t]) -for (name, (srcdir, tags)) in snippets.items (): - copy_ly (srcdir, name, tags) +for (name, (srcdir, file_tags)) in snippets.items (): + copy_ly (srcdir, name, file_tags) for (tag, file_set) in tag_lists.items (): dump_file_list (os.path.join (lys_from_lsr, tag + '.snippet-list'), file_set, update=not(in_dir)) -- 2.39.2