Browse Source

Improve get_subdirs signature

pull/156/head
Louis 9 years ago
parent
commit
4820293f90
  1. 10
      patacrep/songs/__init__.py
  2. 2
      patacrep/songs/chordpro/__init__.py

10
patacrep/songs/__init__.py

@ -192,11 +192,11 @@ class Song:
""" """
raise NotImplementedError() raise NotImplementedError()
def get_datadirs(self, subdir=None): def iter_datadirs(self, *subpath):
"""Return an iterator of existing datadirs (with eventually a subdir) """Return an iterator of existing datadirs (with an optionnal subpath)
""" """
for directory in self.config['datadir']: for directory in self.config['datadir']:
fullpath = os.path.join(directory, subdir) fullpath = os.path.join(directory, *subpath)
if os.path.isdir(fullpath): if os.path.isdir(fullpath):
yield fullpath yield fullpath
@ -255,7 +255,7 @@ class Song:
return self.search_file( return self.search_file(
filename, filename,
['', '.jpg', '.png'], ['', '.jpg', '.png'],
datadirs=self.get_datadirs('img'), datadirs=self.iter_datadirs('img'),
) )
def search_partition(self, filename): def search_partition(self, filename):
@ -263,7 +263,7 @@ class Song:
return self.search_file( return self.search_file(
filename, filename,
['', '.ly'], ['', '.ly'],
datadirs=self.get_datadirs('scores'), datadirs=self.iter_datadirs('scores'),
) )
def unprefixed_title(title, prefixes): def unprefixed_title(title, prefixes):

2
patacrep/songs/chordpro/__init__.py

@ -50,7 +50,7 @@ class ChordproSong(Song):
jinjaenv = Environment(loader=ChoiceLoader([ jinjaenv = Environment(loader=ChoiceLoader([
FileSystemLoader( FileSystemLoader(
self.get_datadirs(os.path.join("templates", self.output_language)) self.iter_datadirs("templates", self.output_language)
), ),
FileSystemLoader( FileSystemLoader(
pkg_datapath('ast_templates', 'chordpro', self.output_language) pkg_datapath('ast_templates', 'chordpro', self.output_language)

Loading…
Cancel
Save