From 88d97971d3cb4766cadf938f58553e468e31417c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 22 Oct 2015 14:50:49 +0200 Subject: [PATCH] Force consistent ordering of the datadir --- patacrep/content/song.py | 6 ++- test/test_compilation/subdir.tex.control | 54 ++++++++++++------------ 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 480583fa..b4247918 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -46,6 +46,10 @@ class SongRenderer(Content): song=self.song.render(output=context['filename']), ) + def __lt__(self, other): + """Order by song path""" + return self.song.fullpath < other.song.fullpath + #pylint: disable=unused-argument def parse(keyword, argument, contentlist, config): """Parse data associated with keyword 'song'. @@ -102,7 +106,7 @@ def parse(keyword, argument, contentlist, config): [item.fullpath for item in config['_songdir']], message='Ignoring "{name}": did not match any file in {paths}.', )) - return songlist + return sorted(songlist) CONTENT_PLUGINS = {'song': parse} diff --git a/test/test_compilation/subdir.tex.control b/test/test_compilation/subdir.tex.control index ffe1023b..cac3f9e5 100644 --- a/test/test_compilation/subdir.tex.control +++ b/test/test_compilation/subdir.tex.control @@ -93,23 +93,28 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir2.sgc +%% songs/./datadir.sg -\selectlanguage{french} +\import{subdir_datadir/songs/}{datadir.sg} -\beginsong{Image included from a different datadir\\ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./datadir.sgc + +\selectlanguage{english} + +\beginsong{Image included from datadir\\ Chordpro}[ by={ }, - cov={img/datadir2.png}, + cov={img/datadir.png}, ] \cover -\lilypond{scores/datadir2.ly} -\image{img/datadir2.png} +\lilypond{scores/datadir.ly} +\image{img/datadir.png} \endsong @@ -120,59 +125,54 @@ Chordpro}[ \import{subdir_datadir/songs/}{datadir2.sg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sgc +%% songs/./datadir2.sgc \selectlanguage{french} -\beginsong{Image included from song directory\\ +\beginsong{Image included from a different datadir\\ Chordpro}[ by={ }, - cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, + cov={img/datadir2.png}, ] \cover -\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} -\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} +\lilypond{scores/datadir2.ly} +\image{img/datadir2.png} \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sgc +%% songs/./relative.sg -\selectlanguage{english} +\import{subdir_datadir/songs/}{relative.sg} -\beginsong{Image included from datadir\\ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./relative.sgc + +\selectlanguage{french} + +\beginsong{Image included from song directory\\ Chordpro}[ by={ }, - cov={img/datadir.png}, + cov={/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png}, ] \cover -\lilypond{scores/datadir.ly} -\image{img/datadir.png} +\lilypond{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.ly} +\image{/home/louis/projets/patacrep/patacrep/test/test_compilation/subdir_datadir/songs/relative.png} \endsong -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sg - -\import{subdir_datadir/songs/}{relative.sg} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sg - -\import{subdir_datadir/songs/}{datadir.sg} - \end{songs}