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

2
patacrep/songs/__init__.py

@ -168,7 +168,7 @@ class Song:
def __repr__(self): def __repr__(self):
return repr((self.titles, self.data, self.fullpath)) 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. """Return the code rendering this song.
Arguments: Arguments:

2
patacrep/songs/chordpro/__init__.py

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

8
patacrep/songs/latex/__init__.py

@ -29,14 +29,14 @@ class Latex2LatexSong(Song):
else: else:
self.authors = [] self.authors = []
def render(self, output): def render(self):
"""Return the code rendering the song.""" """Return the code rendering the song."""
# pylint: disable=signature-differs # pylint: disable=signature-differs
if output is None: if not self.datadir:
raise ValueError(output) raise ValueError(self.datadir)
path = files.path2posix(files.relpath( path = files.path2posix(files.relpath(
self.fullpath, self.fullpath,
os.path.dirname(output) os.path.dirname(self.datadir)
)) ))
return r'\import{{{}/}}{{{}}}'.format(os.path.dirname(path), os.path.basename(path)) 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(): with disable_logging():
song = self.song_plugins[LANGUAGES[destformat]]['sgc'](sourcename, self.config) song = self.song_plugins[LANGUAGES[destformat]]['sgc'](sourcename, self.config)
self.assertMultiLineEqual( self.assertMultiLineEqual(
song.render(output=sourcename).strip(), song.render().strip(),
expectfile.read().strip(), expectfile.read().strip(),
) )

Loading…
Cancel
Save