Browse Source

Sub-datadir (img and score) must be explicitely set

pull/125/head
Louis 9 years ago
parent
commit
1f6801b54b
  1. 0
      examples/datadir2/scores/datadir2.ly
  2. 0
      examples/scores/datadir.ly
  3. 6
      examples/songs/subdir/datadir.sg
  4. 6
      examples/songs/subdir/datadir2.sg
  5. 2
      patacrep/data/templates/patacrep.tex
  6. 2
      patacrep/data/templates/songs.tex
  7. 2
      patacrep/songs/__init__.py
  8. 17
      patacrep/songs/chordpro/__init__.py

0
examples/datadir2/img/datadir2.ly → examples/datadir2/scores/datadir2.ly

0
examples/img/datadir.ly → examples/scores/datadir.ly

6
examples/songs/subdir/datadir.sg

@ -1,10 +1,10 @@
\beginsong{Image included from datadir\\\LaTeX} \beginsong{Image included from datadir\\\LaTeX}
[cov={datadir}] [cov={img/datadir}]
\cover \cover
\lilypond{datadir.ly} \lilypond{scores/datadir.ly}
\image{datadir} \image{img/datadir}
\endsong \endsong

6
examples/songs/subdir/datadir2.sg

@ -1,10 +1,10 @@
\beginsong{Image included from a different datadir\\\LaTeX} \beginsong{Image included from a different datadir\\\LaTeX}
[cov={datadir2}] [cov={img/datadir2}]
\cover \cover
\lilypond{datadir2.ly} \lilypond{scores/datadir2.ly}
\image{datadir2} \image{img/datadir2}
\endsong \endsong

2
patacrep/data/templates/patacrep.tex

@ -34,7 +34,7 @@
}, },
"picture": {"description": {"english": "Cover picture", "french": "Image de couverture"}, "picture": {"description": {"english": "Cover picture", "french": "Image de couverture"},
"type": "file", "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"}, "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}"} "default": {"default": "Dbolton \\url{http://commons.wikimedia.org/wiki/User:Dbolton}"}

2
patacrep/data/templates/songs.tex

@ -89,7 +89,7 @@
\usepackage{graphicx} \usepackage{graphicx}
\graphicspath{ % \graphicspath{ %
(* for dir in datadir *) (* for dir in datadir *)
{(( path2posix(dir) ))/img/} % {(( path2posix(dir) ))/} %
(* endfor *) (* endfor *)
} }

2
patacrep/songs/__init__.py

@ -263,7 +263,7 @@ class Song:
return self.search_file( return self.search_file(
filename, filename,
['', '.ly'], ['', '.ly'],
datadirs=self.get_datadirs('img'), datadirs=self.get_datadirs('scores'),
) )
def unprefixed_title(title, prefixes): def unprefixed_title(title, prefixes):

17
patacrep/songs/chordpro/__init__.py

@ -93,16 +93,29 @@ class Chordpro2LatexSong(ChordproSong):
output_language = "latex" output_language = "latex"
def search_file(self, filename, extensions=None, *, datadirs=None): def search_file(self, filename, extensions=None, *, datadirs=None):
try:
_datadir, filename, _extension = self.search_datadir_file( _datadir, filename, _extension = self.search_datadir_file(
filename, filename,
extensions, extensions,
datadirs, datadirs,
) )
return filename return filename
def search_partition(self, filename):
try:
return os.path.join("scores", super().search_partition(filename))
except FileNotFoundError: except FileNotFoundError:
LOGGER.warning( LOGGER.warning(
"Song '%s' (datadir '%s'): File '%s' not found.", "Song '%s' (datadir '%s'): Score '%s' not found.",
self.subpath, self.datadir, 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'): Image '%s' not found.",
self.subpath, self.datadir, filename, self.subpath, self.datadir, filename,
) )
return None return None

Loading…
Cancel
Save