diff --git a/examples/datadir2/img/datadir2.ly b/examples/datadir2/scores/datadir2.ly similarity index 100% rename from examples/datadir2/img/datadir2.ly rename to examples/datadir2/scores/datadir2.ly diff --git a/examples/img/datadir.ly b/examples/scores/datadir.ly similarity index 100% rename from examples/img/datadir.ly rename to examples/scores/datadir.ly diff --git a/examples/songs/subdir/datadir.sg b/examples/songs/subdir/datadir.sg index 18e92c3d..933e208b 100644 --- a/examples/songs/subdir/datadir.sg +++ b/examples/songs/subdir/datadir.sg @@ -1,10 +1,10 @@ \beginsong{Image included from datadir\\\LaTeX} - [cov={datadir}] + [cov={img/datadir}] \cover - \lilypond{datadir.ly} + \lilypond{scores/datadir.ly} - \image{datadir} + \image{img/datadir} \endsong diff --git a/examples/songs/subdir/datadir2.sg b/examples/songs/subdir/datadir2.sg index f5bad860..6a805725 100644 --- a/examples/songs/subdir/datadir2.sg +++ b/examples/songs/subdir/datadir2.sg @@ -1,10 +1,10 @@ \beginsong{Image included from a different datadir\\\LaTeX} - [cov={datadir2}] + [cov={img/datadir2}] \cover - \lilypond{datadir2.ly} + \lilypond{scores/datadir2.ly} - \image{datadir2} + \image{img/datadir2} \endsong diff --git a/patacrep/data/templates/patacrep.tex b/patacrep/data/templates/patacrep.tex index 96367078..50dacf5e 100644 --- a/patacrep/data/templates/patacrep.tex +++ b/patacrep/data/templates/patacrep.tex @@ -34,7 +34,7 @@ }, "picture": {"description": {"english": "Cover picture", "french": "Image de couverture"}, "type": "file", - "default": {"default": "treble_a"} + "default": {"default": "img/treble_a"} }, "picturecopyright": {"description": {"english": "Copyright for the cover picture", "french": "Copyright pour l'image de couverture"}, "default": {"default": "Dbolton \\url{http://commons.wikimedia.org/wiki/User:Dbolton}"} diff --git a/patacrep/data/templates/songs.tex b/patacrep/data/templates/songs.tex index 957e610e..741b5d39 100644 --- a/patacrep/data/templates/songs.tex +++ b/patacrep/data/templates/songs.tex @@ -89,7 +89,7 @@ \usepackage{graphicx} \graphicspath{ % (* for dir in datadir *) - {(( path2posix(dir) ))/img/} % + {(( path2posix(dir) ))/} % (* endfor *) } diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index e8a91fa3..129c8045 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -263,7 +263,7 @@ class Song: return self.search_file( filename, ['', '.ly'], - datadirs=self.get_datadirs('img'), + datadirs=self.get_datadirs('scores'), ) def unprefixed_title(title, prefixes): diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index c5b80888..c46a0880 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -93,16 +93,29 @@ class Chordpro2LatexSong(ChordproSong): output_language = "latex" def search_file(self, filename, extensions=None, *, datadirs=None): + _datadir, filename, _extension = self.search_datadir_file( + filename, + extensions, + datadirs, + ) + return filename + + def search_partition(self, filename): try: - _datadir, filename, _extension = self.search_datadir_file( - filename, - extensions, - datadirs, + return os.path.join("scores", super().search_partition(filename)) + except FileNotFoundError: + LOGGER.warning( + "Song '%s' (datadir '%s'): Score '%s' not found.", + self.subpath, self.datadir, filename, ) - return filename + return None + + def search_image(self, filename): + try: + return os.path.join("img", super().search_image(filename)) except FileNotFoundError: LOGGER.warning( - "Song '%s' (datadir '%s'): File '%s' not found.", + "Song '%s' (datadir '%s'): Image '%s' not found.", self.subpath, self.datadir, filename, ) return None diff --git a/test/test_chordpro/datadir/img/greensleeves.ly b/test/test_chordpro/datadir/scores/greensleeves.ly similarity index 100% rename from test/test_chordpro/datadir/img/greensleeves.ly rename to test/test_chordpro/datadir/scores/greensleeves.ly diff --git a/test/test_chordpro/greensleeves.tex b/test/test_chordpro/greensleeves.tex index b7186121..f582b0c8 100644 --- a/test/test_chordpro/greensleeves.tex +++ b/test/test_chordpro/greensleeves.tex @@ -7,14 +7,14 @@ Un sous titre}[ by={ Traditionnel }, album={Angleterre}, - cov={traditionnel}, + cov={img/traditionnel}, ] \cover -\lilypond{greensleeves.ly} +\lilypond{scores/greensleeves.ly} diff --git a/test/test_chordpro/metadata.tex b/test/test_chordpro/metadata.tex index 46368580..a3a36676 100644 --- a/test/test_chordpro/metadata.tex +++ b/test/test_chordpro/metadata.tex @@ -11,7 +11,7 @@ Subtitle5}[ Author2 }, album={Album}, copyright={Copyright}, - cov={test/test_chordpro/metadata_cover}, + cov={img/test/test_chordpro/metadata_cover}, foo={Foo}, ] @@ -19,8 +19,8 @@ Subtitle5}[ \textnote{Comment} \musicnote{GuitarComment} -\lilypond{test/test_chordpro/metadata_lilypond} -\image{test/test_chordpro/metadata_image} +\lilypond{scores/test/test_chordpro/metadata_lilypond} +\image{img/test/test_chordpro/metadata_image}