From a4d1091e3005664ad7cfc460bb4e34a72b41b106 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 30 Oct 2015 13:17:49 +0100 Subject: [PATCH] Use path2posix on LaTeX path --- patacrep/content/song.py | 2 +- .../ast_templates/chordpro/latex/content_image | 2 +- .../chordpro/latex/content_partition | 4 ++-- patacrep/data/ast_templates/chordpro/latex/song | 2 +- patacrep/songs/chordpro/__init__.py | 2 ++ test/test_compilation/test_compilation.py | 15 +++++++++------ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 71473aa8..4f9ab809 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -42,7 +42,7 @@ class SongRenderer(Content): {song} """).format( separator="%"*80, - path=self.song.subpath, + path=files.path2posix(self.song.subpath), song=self.song.render(output=context['filename']), ) diff --git a/patacrep/data/ast_templates/chordpro/latex/content_image b/patacrep/data/ast_templates/chordpro/latex/content_image index ac97404b..a567730d 100644 --- a/patacrep/data/ast_templates/chordpro/latex/content_image +++ b/patacrep/data/ast_templates/chordpro/latex/content_image @@ -1,5 +1,5 @@ (* block image *) -(* set image = content.argument|search_image *) +(* set image = content.argument|search_image|path2posix *) (* if image *) \image{(( image ))} (*- endif *) diff --git a/patacrep/data/ast_templates/chordpro/latex/content_partition b/patacrep/data/ast_templates/chordpro/latex/content_partition index a3c35a3e..6942492a 100644 --- a/patacrep/data/ast_templates/chordpro/latex/content_partition +++ b/patacrep/data/ast_templates/chordpro/latex/content_partition @@ -1,6 +1,6 @@ (* block partition *) -(* set partition = content.argument|search_partition *) +(* set partition = content.argument|search_partition|path2posix *) (* if partition *) -\lilypond{ ((- content.argument|search_partition -)) } +\lilypond{ ((- partition -)) } (*- endif -*) (*- endblock -*) diff --git a/patacrep/data/ast_templates/chordpro/latex/song b/patacrep/data/ast_templates/chordpro/latex/song index 2fe34c48..e8016107 100644 --- a/patacrep/data/ast_templates/chordpro/latex/song +++ b/patacrep/data/ast_templates/chordpro/latex/song @@ -29,7 +29,7 @@ (* endfor *) (* if 'cover' in metadata *) (* block cover *) - (* set cover = metadata["cover"].argument|search_image *) + (* set cover = metadata["cover"].argument|search_image|path2posix *) (* if cover *) cover={(( cover ))}, (* endif *) diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index fd035e30..46f0f37c 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -11,6 +11,7 @@ from patacrep.songs import Song from patacrep.songs.chordpro.syntax import parse_song from patacrep.templates import Renderer from patacrep.latex import lang2babel +from patacrep.files import path2posix LOGGER = logging.getLogger(__name__) @@ -59,6 +60,7 @@ class ChordproSong(Song): jinjaenv.filters['search_partition'] = self.search_partition jinjaenv.filters['lang2babel'] = lang2babel jinjaenv.filters['sortargs'] = sort_directive_argument + jinjaenv.filters['path2posix'] = path2posix try: return Renderer( diff --git a/test/test_compilation/test_compilation.py b/test/test_compilation/test_compilation.py index dc07107a..d8aee822 100644 --- a/test/test_compilation/test_compilation.py +++ b/test/test_compilation/test_compilation.py @@ -9,6 +9,7 @@ import subprocess import unittest from patacrep.encoding import open_read +from patacrep.files import path2posix from .. import dynamic # pylint: disable=unused-import @@ -67,16 +68,18 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): expected = expectfile.read().strip() expected = expected.replace( "@TEST_FOLDER@", - os.path.dirname(__file__), + path2posix(os.path.dirname(__file__)), ) expected = expected.replace( "@DATA_FOLDER@", - subprocess.check_output( - ["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long - universal_newlines=True, - cwd=os.path.dirname(songbook), - ).strip(), + path2posix( + subprocess.check_output( + ["python", "-c", 'import patacrep, pkg_resources; print(pkg_resources.resource_filename(patacrep.__name__, "data"))'], # pylint: disable=line-too-long + universal_newlines=True, + cwd=os.path.dirname(songbook), + ).strip() + ), ) self.assertMultiLineEqual(