From 54084a56b4a27ad2792de732bdf4d277794a6066 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sat, 7 Nov 2015 15:20:59 +0100 Subject: [PATCH] Deprecate output argument of the Song.render method --- patacrep/content/song.py | 3 ++- patacrep/songs/__init__.py | 2 +- patacrep/songs/chordpro/__init__.py | 2 +- patacrep/songs/latex/__init__.py | 8 ++++---- test/test_chordpro/test_parser.py | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 4f9ab809..45bbfeac 100755 --- a/patacrep/content/song.py +++ b/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): diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index 922ecb00..a13025ef 100644 --- a/patacrep/songs/__init__.py +++ b/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: diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 0be23592..dcc573ab 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/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, diff --git a/patacrep/songs/latex/__init__.py b/patacrep/songs/latex/__init__.py index 8dd8d15b..bed2d037 100644 --- a/patacrep/songs/latex/__init__.py +++ b/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)) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 39c37052..6834af4b 100644 --- a/test/test_chordpro/test_parser.py +++ b/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(), )