Browse Source

Deprecate output argument of the Song.render method

pull/165/head
Oliverpool 9 years ago
parent
commit
54084a56b4
  1. 3
      patacrep/content/song.py
  2. 2
      patacrep/songs/__init__.py
  3. 2
      patacrep/songs/chordpro/__init__.py
  4. 8
      patacrep/songs/latex/__init__.py
  5. 2
      test/test_chordpro/test_parser.py

3
patacrep/content/song.py

@ -33,6 +33,7 @@ class SongRenderer(Content):
"""Return the string to end a block."""
return r'\end{songs}'
#pylint: disable=unused-argument
def render(self, context):
"""Return the string that will render the song."""
return textwrap.dedent("""\
@ -43,7 +44,7 @@ class SongRenderer(Content):
""").format(
separator="%"*80,
path=files.path2posix(self.song.subpath),
song=self.song.render(output=context['filename']),
song=self.song.render(),
)
def __lt__(self, other):

2
patacrep/songs/__init__.py

@ -168,7 +168,7 @@ class Song:
def __repr__(self):
return repr((self.titles, self.data, self.fullpath))
def render(self, output=None, *args, **kwargs):
def render(self, *args, **kwargs):
"""Return the code rendering this song.
Arguments:

2
patacrep/songs/chordpro/__init__.py

@ -37,7 +37,7 @@ class ChordproSong(Song):
'song': song,
}
def render(self, output=None, template="song"): # pylint: disable=arguments-differ
def render(self, template="song"): # pylint: disable=arguments-differ
context = {
'lang': self.lang,
"titles": self.titles,

8
patacrep/songs/latex/__init__.py

@ -29,14 +29,14 @@ class Latex2LatexSong(Song):
else:
self.authors = []
def render(self, output):
def render(self):
"""Return the code rendering the song."""
# pylint: disable=signature-differs
if output is None:
raise ValueError(output)
if not self.datadir:
raise ValueError(self.datadir)
path = files.path2posix(files.relpath(
self.fullpath,
os.path.dirname(output)
os.path.dirname(self.datadir)
))
return r'\import{{{}/}}{{{}}}'.format(os.path.dirname(path), os.path.basename(path))

2
test/test_chordpro/test_parser.py

@ -62,7 +62,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest):
with disable_logging():
song = self.song_plugins[LANGUAGES[destformat]]['sgc'](sourcename, self.config)
self.assertMultiLineEqual(
song.render(output=sourcename).strip(),
song.render().strip(),
expectfile.read().strip(),
)

Loading…
Cancel
Save