From 1da076773d523f6cd0cd8f233e6f8ae73a693391 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 07:30:11 +0100 Subject: [PATCH 01/41] Test for lilypond compiler before starting compilation --- patacrep/build.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/patacrep/build.py b/patacrep/build.py index a720b9b1..f3391744 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -123,6 +123,9 @@ class Songbook(object): renderer.render_tex(output, config) + def requires_lilypond(self): + return 'lilypond' in self.config.get('bookoptions', []) + def _log_pipe(pipe): """Log content from `pipe`.""" while 1: @@ -227,6 +230,20 @@ class SongbookBuilder(object): except Exception as error: raise errors.ExecutableNotFound(compiler) + # Test if lilypond compiler is accessible + lilypond_compiler = 'lilypond' + if self.songbook.requires_lilypond(): + try: + check_call( + [lilypond_compiler, "--version"], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE, + universal_newlines=True, + ) + except Exception as error: + raise errors.ExecutableNotFound(lilypond_compiler) + # Perform compilation try: process = Popen( From 95d27724ea2522ae7a3ef6eed4df90e082af7882 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 07:33:26 +0100 Subject: [PATCH 02/41] (pylint) Add docstring --- patacrep/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patacrep/build.py b/patacrep/build.py index f3391744..83817d1c 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -124,6 +124,7 @@ class Songbook(object): renderer.render_tex(output, config) def requires_lilypond(self): + """Tell if lilypond is part of the bookoptions""" return 'lilypond' in self.config.get('bookoptions', []) def _log_pipe(pipe): From 61bc9a5731e9b459e8aaf3dbf1f446f13b6331a7 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 07:41:18 +0100 Subject: [PATCH 03/41] move variable declaration --- patacrep/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/build.py b/patacrep/build.py index 83817d1c..baa335fb 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -232,8 +232,8 @@ class SongbookBuilder(object): raise errors.ExecutableNotFound(compiler) # Test if lilypond compiler is accessible - lilypond_compiler = 'lilypond' if self.songbook.requires_lilypond(): + lilypond_compiler = 'lilypond' try: check_call( [lilypond_compiler, "--version"], From 80deae38ea1dc360feac77c11ca630eb302b8453 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 15:44:42 +0100 Subject: [PATCH 04/41] Rename test folders --- test/test_compilation/.gitignore | 2 -- test/{test_chordpro => test_song}/00.csg | 0 test/{test_chordpro => test_song}/00.csg.source | 0 test/{test_chordpro => test_song}/00.tsg | 0 test/{test_chordpro => test_song}/01.csg | 0 test/{test_chordpro => test_song}/01.csg.source | 0 test/{test_chordpro => test_song}/01.tsg | 0 test/{test_chordpro => test_song}/02.csg | 0 test/{test_chordpro => test_song}/02.csg.source | 0 test/{test_chordpro => test_song}/02.tsg | 0 test/{test_chordpro => test_song}/03.csg | 0 test/{test_chordpro => test_song}/03.csg.source | 0 test/{test_chordpro => test_song}/03.tsg | 0 test/{test_chordpro => test_song}/04.csg | 0 test/{test_chordpro => test_song}/04.csg.source | 0 test/{test_chordpro => test_song}/04.tsg | 0 test/{test_chordpro => test_song}/05.csg | 0 test/{test_chordpro => test_song}/05.csg.source | 0 test/{test_chordpro => test_song}/05.tsg | 0 test/{test_chordpro => test_song}/06.csg | 0 test/{test_chordpro => test_song}/06.csg.source | 0 test/{test_chordpro => test_song}/06.tsg | 0 test/{test_chordpro => test_song}/07.csg | 0 test/{test_chordpro => test_song}/07.csg.source | 0 test/{test_chordpro => test_song}/07.tsg | 0 test/{test_chordpro => test_song}/08.csg | 0 test/{test_chordpro => test_song}/08.csg.source | 0 test/{test_chordpro => test_song}/08.tsg | 0 test/{test_chordpro => test_song}/09.csg | 0 test/{test_chordpro => test_song}/09.csg.source | 0 test/{test_chordpro => test_song}/09.tsg | 0 test/{test_chordpro => test_song}/10.csg | 0 test/{test_chordpro => test_song}/10.csg.source | 0 test/{test_chordpro => test_song}/10.tsg | 0 test/{test_chordpro => test_song}/11.csg | 0 test/{test_chordpro => test_song}/11.csg.source | 0 test/{test_chordpro => test_song}/11.tsg | 0 test/{test_chordpro => test_song}/12.csg | 0 test/{test_chordpro => test_song}/12.csg.source | 0 test/{test_chordpro => test_song}/12.tsg | 0 test/{test_chordpro => test_song}/13.csg | 0 test/{test_chordpro => test_song}/13.csg.source | 0 test/{test_chordpro => test_song}/13.tsg | 0 test/{test_chordpro => test_song}/21.csg | 0 test/{test_chordpro => test_song}/21.csg.source | 0 test/{test_chordpro => test_song}/21.tsg | 0 test/{test_chordpro => test_song}/22.csg | 0 test/{test_chordpro => test_song}/22.csg.source | 0 test/{test_chordpro => test_song}/22.tsg | 0 test/{test_chordpro => test_song}/23.csg | 0 test/{test_chordpro => test_song}/23.csg.source | 0 test/{test_chordpro => test_song}/23.tsg | 0 test/{test_chordpro => test_song}/24.csg | 0 test/{test_chordpro => test_song}/24.csg.source | 0 test/{test_chordpro => test_song}/24.tsg | 0 test/{test_chordpro => test_song}/25.csg | 0 test/{test_chordpro => test_song}/25.csg.source | 0 test/{test_chordpro => test_song}/25.tsg | 0 test/{test_chordpro => test_song}/26.csg | 0 test/{test_chordpro => test_song}/26.csg.source | 0 test/{test_chordpro => test_song}/26.tsg | 0 test/{test_chordpro => test_song}/27.csg | 0 test/{test_chordpro => test_song}/27.csg.source | 0 test/{test_chordpro => test_song}/27.tsg | 0 test/{test_chordpro => test_song}/28.csg | 0 test/{test_chordpro => test_song}/28.csg.source | 0 test/{test_chordpro => test_song}/28.tsg | 0 test/{test_chordpro => test_song}/29.csg | 0 test/{test_chordpro => test_song}/29.csg.source | 0 test/{test_chordpro => test_song}/29.tsg | 0 test/{test_chordpro => test_song}/__init__.py | 0 test/{test_chordpro => test_song}/author_names.csg | 0 .../author_names.csg.source | 0 test/{test_chordpro => test_song}/author_names.tsg | 0 test/{test_chordpro => test_song}/chords.csg | 0 test/{test_chordpro => test_song}/chords.csg.source | 0 test/{test_chordpro => test_song}/chords.tsg | 0 test/{test_chordpro => test_song}/customchords.csg | 0 .../customchords.csg.source | 0 test/{test_chordpro => test_song}/customchords.tsg | 0 .../datadir/img/traditionnel.png | 0 .../datadir/scores/greensleeves.ly | 0 .../errors/invalid_content.csg.source | 0 test/{test_chordpro => test_song}/greensleeves.csg | 0 .../greensleeves.csg.source | 0 test/{test_chordpro => test_song}/greensleeves.tsg | 0 test/{test_chordpro => test_song}/invalid_chord.csg | 0 .../invalid_chord.csg.source | 0 test/{test_chordpro => test_song}/invalid_chord.tsg | 0 .../invalid_customchord.csg | 0 .../invalid_customchord.csg.source | 0 .../invalid_customchord.tsg | 0 .../invalid_directive.csg | 0 .../invalid_directive.csg.source | 0 .../invalid_directive.tsg | 0 test/{test_chordpro => test_song}/lang.csg | 0 test/{test_chordpro => test_song}/lang.csg.source | 0 test/{test_chordpro => test_song}/metadata.csg | 0 .../metadata.csg.source | 0 test/{test_chordpro => test_song}/metadata.tsg | 0 .../{test_chordpro => test_song}/metadata_cover.png | 0 .../{test_chordpro => test_song}/metadata_image.png | 0 .../metadata_lilypond.ly | 0 test/{test_chordpro => test_song}/newline.crlf.csg | 0 .../newline.crlf.csg.source | 0 test/{test_chordpro => test_song}/newline.crlf.html | 0 test/{test_chordpro => test_song}/newline.crlf.tsg | 0 test/{test_chordpro => test_song}/newline.csg | 0 .../{test_chordpro => test_song}/newline.csg.source | 0 test/{test_chordpro => test_song}/newline.html | 0 test/{test_chordpro => test_song}/newline.tsg | 0 test/{test_chordpro => test_song}/nolyrics.csg | 0 .../nolyrics.csg.source | 0 test/{test_chordpro => test_song}/nolyrics.tsg | 0 test/{test_chordpro => test_song}/tags.csg | 0 test/{test_chordpro => test_song}/tags.csg.source | 0 test/{test_chordpro => test_song}/tags.tsg | 0 test/{test_chordpro => test_song}/test_parser.py | 0 test/{test_chordpro => test_song}/ukulelechords.csg | 0 .../ukulelechords.csg.source | 0 test/{test_chordpro => test_song}/ukulelechords.tsg | 0 .../{test_compilation => test_songbook}/__init__.py | 0 test/{test_compilation => test_songbook}/datadir.sb | 0 .../datadir.tex.control | 0 .../datadir_datadir/img/datadir.png | Bin .../datadir_datadir/scores/datadir.ly | 0 .../datadir_datadir/songs/datadir.csg | 0 .../datadir_datadir/songs/datadir.tsg | 0 .../datadir_datadir/songs/datadir2.csg | 0 .../datadir_datadir/songs/datadir2.sg | 0 .../datadir_datadir/songs/relative.csg | 0 .../datadir_datadir/songs/relative.ly | 0 .../datadir_datadir/songs/relative.png | Bin .../datadir_datadir/songs/relative.tsg | 0 .../datadir_datadir/songs/subdir/subdir.csg | 0 .../datadir_datadir/songs/subdir/subdir.ly | 0 .../datadir_datadir/songs/subdir/subdir.png | Bin .../datadir_datadir/songs/subdir/subdir.tsg | 0 .../datadir_datadir2/img/datadir2.png | Bin .../datadir_datadir2/scores/datadir2.ly | 0 .../languages.sb | 0 .../languages.tex.control | 0 .../languages_datadir/songs/language.csg | 0 .../languages_datadir/songs/language_location.csg | 0 .../languages_datadir/songs/no_language.csg | 0 .../languages_datadir/songs/wrong_language.csg | 0 .../languages_datadir/songs/wrong_location.csg | 0 test/{test_compilation => test_songbook}/syntax.sb | 0 .../syntax.tex.control | 0 .../syntax_datadir/songs/musicnote.csg | 0 .../test_compilation.py | 0 test/{test_compilation => test_songbook}/unicode.sb | 0 .../unicode.tex.control | 0 .../unicode_datadir/songs/nonbreak.csg | 0 154 files changed, 2 deletions(-) delete mode 100644 test/test_compilation/.gitignore rename test/{test_chordpro => test_song}/00.csg (100%) rename test/{test_chordpro => test_song}/00.csg.source (100%) rename test/{test_chordpro => test_song}/00.tsg (100%) rename test/{test_chordpro => test_song}/01.csg (100%) rename test/{test_chordpro => test_song}/01.csg.source (100%) rename test/{test_chordpro => test_song}/01.tsg (100%) rename test/{test_chordpro => test_song}/02.csg (100%) rename test/{test_chordpro => test_song}/02.csg.source (100%) rename test/{test_chordpro => test_song}/02.tsg (100%) rename test/{test_chordpro => test_song}/03.csg (100%) rename test/{test_chordpro => test_song}/03.csg.source (100%) rename test/{test_chordpro => test_song}/03.tsg (100%) rename test/{test_chordpro => test_song}/04.csg (100%) rename test/{test_chordpro => test_song}/04.csg.source (100%) rename test/{test_chordpro => test_song}/04.tsg (100%) rename test/{test_chordpro => test_song}/05.csg (100%) rename test/{test_chordpro => test_song}/05.csg.source (100%) rename test/{test_chordpro => test_song}/05.tsg (100%) rename test/{test_chordpro => test_song}/06.csg (100%) rename test/{test_chordpro => test_song}/06.csg.source (100%) rename test/{test_chordpro => test_song}/06.tsg (100%) rename test/{test_chordpro => test_song}/07.csg (100%) rename test/{test_chordpro => test_song}/07.csg.source (100%) rename test/{test_chordpro => test_song}/07.tsg (100%) rename test/{test_chordpro => test_song}/08.csg (100%) rename test/{test_chordpro => test_song}/08.csg.source (100%) rename test/{test_chordpro => test_song}/08.tsg (100%) rename test/{test_chordpro => test_song}/09.csg (100%) rename test/{test_chordpro => test_song}/09.csg.source (100%) rename test/{test_chordpro => test_song}/09.tsg (100%) rename test/{test_chordpro => test_song}/10.csg (100%) rename test/{test_chordpro => test_song}/10.csg.source (100%) rename test/{test_chordpro => test_song}/10.tsg (100%) rename test/{test_chordpro => test_song}/11.csg (100%) rename test/{test_chordpro => test_song}/11.csg.source (100%) rename test/{test_chordpro => test_song}/11.tsg (100%) rename test/{test_chordpro => test_song}/12.csg (100%) rename test/{test_chordpro => test_song}/12.csg.source (100%) rename test/{test_chordpro => test_song}/12.tsg (100%) rename test/{test_chordpro => test_song}/13.csg (100%) rename test/{test_chordpro => test_song}/13.csg.source (100%) rename test/{test_chordpro => test_song}/13.tsg (100%) rename test/{test_chordpro => test_song}/21.csg (100%) rename test/{test_chordpro => test_song}/21.csg.source (100%) rename test/{test_chordpro => test_song}/21.tsg (100%) rename test/{test_chordpro => test_song}/22.csg (100%) rename test/{test_chordpro => test_song}/22.csg.source (100%) rename test/{test_chordpro => test_song}/22.tsg (100%) rename test/{test_chordpro => test_song}/23.csg (100%) rename test/{test_chordpro => test_song}/23.csg.source (100%) rename test/{test_chordpro => test_song}/23.tsg (100%) rename test/{test_chordpro => test_song}/24.csg (100%) rename test/{test_chordpro => test_song}/24.csg.source (100%) rename test/{test_chordpro => test_song}/24.tsg (100%) rename test/{test_chordpro => test_song}/25.csg (100%) rename test/{test_chordpro => test_song}/25.csg.source (100%) rename test/{test_chordpro => test_song}/25.tsg (100%) rename test/{test_chordpro => test_song}/26.csg (100%) rename test/{test_chordpro => test_song}/26.csg.source (100%) rename test/{test_chordpro => test_song}/26.tsg (100%) rename test/{test_chordpro => test_song}/27.csg (100%) rename test/{test_chordpro => test_song}/27.csg.source (100%) rename test/{test_chordpro => test_song}/27.tsg (100%) rename test/{test_chordpro => test_song}/28.csg (100%) rename test/{test_chordpro => test_song}/28.csg.source (100%) rename test/{test_chordpro => test_song}/28.tsg (100%) rename test/{test_chordpro => test_song}/29.csg (100%) rename test/{test_chordpro => test_song}/29.csg.source (100%) rename test/{test_chordpro => test_song}/29.tsg (100%) rename test/{test_chordpro => test_song}/__init__.py (100%) rename test/{test_chordpro => test_song}/author_names.csg (100%) rename test/{test_chordpro => test_song}/author_names.csg.source (100%) rename test/{test_chordpro => test_song}/author_names.tsg (100%) rename test/{test_chordpro => test_song}/chords.csg (100%) rename test/{test_chordpro => test_song}/chords.csg.source (100%) rename test/{test_chordpro => test_song}/chords.tsg (100%) rename test/{test_chordpro => test_song}/customchords.csg (100%) rename test/{test_chordpro => test_song}/customchords.csg.source (100%) rename test/{test_chordpro => test_song}/customchords.tsg (100%) rename test/{test_chordpro => test_song}/datadir/img/traditionnel.png (100%) rename test/{test_chordpro => test_song}/datadir/scores/greensleeves.ly (100%) rename test/{test_chordpro => test_song}/errors/invalid_content.csg.source (100%) rename test/{test_chordpro => test_song}/greensleeves.csg (100%) rename test/{test_chordpro => test_song}/greensleeves.csg.source (100%) rename test/{test_chordpro => test_song}/greensleeves.tsg (100%) rename test/{test_chordpro => test_song}/invalid_chord.csg (100%) rename test/{test_chordpro => test_song}/invalid_chord.csg.source (100%) rename test/{test_chordpro => test_song}/invalid_chord.tsg (100%) rename test/{test_chordpro => test_song}/invalid_customchord.csg (100%) rename test/{test_chordpro => test_song}/invalid_customchord.csg.source (100%) rename test/{test_chordpro => test_song}/invalid_customchord.tsg (100%) rename test/{test_chordpro => test_song}/invalid_directive.csg (100%) rename test/{test_chordpro => test_song}/invalid_directive.csg.source (100%) rename test/{test_chordpro => test_song}/invalid_directive.tsg (100%) rename test/{test_chordpro => test_song}/lang.csg (100%) rename test/{test_chordpro => test_song}/lang.csg.source (100%) rename test/{test_chordpro => test_song}/metadata.csg (100%) rename test/{test_chordpro => test_song}/metadata.csg.source (100%) rename test/{test_chordpro => test_song}/metadata.tsg (100%) rename test/{test_chordpro => test_song}/metadata_cover.png (100%) rename test/{test_chordpro => test_song}/metadata_image.png (100%) rename test/{test_chordpro => test_song}/metadata_lilypond.ly (100%) rename test/{test_chordpro => test_song}/newline.crlf.csg (100%) rename test/{test_chordpro => test_song}/newline.crlf.csg.source (100%) rename test/{test_chordpro => test_song}/newline.crlf.html (100%) rename test/{test_chordpro => test_song}/newline.crlf.tsg (100%) rename test/{test_chordpro => test_song}/newline.csg (100%) rename test/{test_chordpro => test_song}/newline.csg.source (100%) rename test/{test_chordpro => test_song}/newline.html (100%) rename test/{test_chordpro => test_song}/newline.tsg (100%) rename test/{test_chordpro => test_song}/nolyrics.csg (100%) rename test/{test_chordpro => test_song}/nolyrics.csg.source (100%) rename test/{test_chordpro => test_song}/nolyrics.tsg (100%) rename test/{test_chordpro => test_song}/tags.csg (100%) rename test/{test_chordpro => test_song}/tags.csg.source (100%) rename test/{test_chordpro => test_song}/tags.tsg (100%) rename test/{test_chordpro => test_song}/test_parser.py (100%) rename test/{test_chordpro => test_song}/ukulelechords.csg (100%) rename test/{test_chordpro => test_song}/ukulelechords.csg.source (100%) rename test/{test_chordpro => test_song}/ukulelechords.tsg (100%) rename test/{test_compilation => test_songbook}/__init__.py (100%) rename test/{test_compilation => test_songbook}/datadir.sb (100%) rename test/{test_compilation => test_songbook}/datadir.tex.control (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/img/datadir.png (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/scores/datadir.ly (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/datadir.csg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/datadir.tsg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/datadir2.csg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/datadir2.sg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/relative.csg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/relative.ly (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/relative.png (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/relative.tsg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/subdir/subdir.csg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/subdir/subdir.ly (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/subdir/subdir.png (100%) rename test/{test_compilation => test_songbook}/datadir_datadir/songs/subdir/subdir.tsg (100%) rename test/{test_compilation => test_songbook}/datadir_datadir2/img/datadir2.png (100%) rename test/{test_compilation => test_songbook}/datadir_datadir2/scores/datadir2.ly (100%) rename test/{test_compilation => test_songbook}/languages.sb (100%) rename test/{test_compilation => test_songbook}/languages.tex.control (100%) rename test/{test_compilation => test_songbook}/languages_datadir/songs/language.csg (100%) rename test/{test_compilation => test_songbook}/languages_datadir/songs/language_location.csg (100%) rename test/{test_compilation => test_songbook}/languages_datadir/songs/no_language.csg (100%) rename test/{test_compilation => test_songbook}/languages_datadir/songs/wrong_language.csg (100%) rename test/{test_compilation => test_songbook}/languages_datadir/songs/wrong_location.csg (100%) rename test/{test_compilation => test_songbook}/syntax.sb (100%) rename test/{test_compilation => test_songbook}/syntax.tex.control (100%) rename test/{test_compilation => test_songbook}/syntax_datadir/songs/musicnote.csg (100%) rename test/{test_compilation => test_songbook}/test_compilation.py (100%) rename test/{test_compilation => test_songbook}/unicode.sb (100%) rename test/{test_compilation => test_songbook}/unicode.tex.control (100%) rename test/{test_compilation => test_songbook}/unicode_datadir/songs/nonbreak.csg (100%) diff --git a/test/test_compilation/.gitignore b/test/test_compilation/.gitignore deleted file mode 100644 index 3f49c007..00000000 --- a/test/test_compilation/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/*tex -.cache diff --git a/test/test_chordpro/00.csg b/test/test_song/00.csg similarity index 100% rename from test/test_chordpro/00.csg rename to test/test_song/00.csg diff --git a/test/test_chordpro/00.csg.source b/test/test_song/00.csg.source similarity index 100% rename from test/test_chordpro/00.csg.source rename to test/test_song/00.csg.source diff --git a/test/test_chordpro/00.tsg b/test/test_song/00.tsg similarity index 100% rename from test/test_chordpro/00.tsg rename to test/test_song/00.tsg diff --git a/test/test_chordpro/01.csg b/test/test_song/01.csg similarity index 100% rename from test/test_chordpro/01.csg rename to test/test_song/01.csg diff --git a/test/test_chordpro/01.csg.source b/test/test_song/01.csg.source similarity index 100% rename from test/test_chordpro/01.csg.source rename to test/test_song/01.csg.source diff --git a/test/test_chordpro/01.tsg b/test/test_song/01.tsg similarity index 100% rename from test/test_chordpro/01.tsg rename to test/test_song/01.tsg diff --git a/test/test_chordpro/02.csg b/test/test_song/02.csg similarity index 100% rename from test/test_chordpro/02.csg rename to test/test_song/02.csg diff --git a/test/test_chordpro/02.csg.source b/test/test_song/02.csg.source similarity index 100% rename from test/test_chordpro/02.csg.source rename to test/test_song/02.csg.source diff --git a/test/test_chordpro/02.tsg b/test/test_song/02.tsg similarity index 100% rename from test/test_chordpro/02.tsg rename to test/test_song/02.tsg diff --git a/test/test_chordpro/03.csg b/test/test_song/03.csg similarity index 100% rename from test/test_chordpro/03.csg rename to test/test_song/03.csg diff --git a/test/test_chordpro/03.csg.source b/test/test_song/03.csg.source similarity index 100% rename from test/test_chordpro/03.csg.source rename to test/test_song/03.csg.source diff --git a/test/test_chordpro/03.tsg b/test/test_song/03.tsg similarity index 100% rename from test/test_chordpro/03.tsg rename to test/test_song/03.tsg diff --git a/test/test_chordpro/04.csg b/test/test_song/04.csg similarity index 100% rename from test/test_chordpro/04.csg rename to test/test_song/04.csg diff --git a/test/test_chordpro/04.csg.source b/test/test_song/04.csg.source similarity index 100% rename from test/test_chordpro/04.csg.source rename to test/test_song/04.csg.source diff --git a/test/test_chordpro/04.tsg b/test/test_song/04.tsg similarity index 100% rename from test/test_chordpro/04.tsg rename to test/test_song/04.tsg diff --git a/test/test_chordpro/05.csg b/test/test_song/05.csg similarity index 100% rename from test/test_chordpro/05.csg rename to test/test_song/05.csg diff --git a/test/test_chordpro/05.csg.source b/test/test_song/05.csg.source similarity index 100% rename from test/test_chordpro/05.csg.source rename to test/test_song/05.csg.source diff --git a/test/test_chordpro/05.tsg b/test/test_song/05.tsg similarity index 100% rename from test/test_chordpro/05.tsg rename to test/test_song/05.tsg diff --git a/test/test_chordpro/06.csg b/test/test_song/06.csg similarity index 100% rename from test/test_chordpro/06.csg rename to test/test_song/06.csg diff --git a/test/test_chordpro/06.csg.source b/test/test_song/06.csg.source similarity index 100% rename from test/test_chordpro/06.csg.source rename to test/test_song/06.csg.source diff --git a/test/test_chordpro/06.tsg b/test/test_song/06.tsg similarity index 100% rename from test/test_chordpro/06.tsg rename to test/test_song/06.tsg diff --git a/test/test_chordpro/07.csg b/test/test_song/07.csg similarity index 100% rename from test/test_chordpro/07.csg rename to test/test_song/07.csg diff --git a/test/test_chordpro/07.csg.source b/test/test_song/07.csg.source similarity index 100% rename from test/test_chordpro/07.csg.source rename to test/test_song/07.csg.source diff --git a/test/test_chordpro/07.tsg b/test/test_song/07.tsg similarity index 100% rename from test/test_chordpro/07.tsg rename to test/test_song/07.tsg diff --git a/test/test_chordpro/08.csg b/test/test_song/08.csg similarity index 100% rename from test/test_chordpro/08.csg rename to test/test_song/08.csg diff --git a/test/test_chordpro/08.csg.source b/test/test_song/08.csg.source similarity index 100% rename from test/test_chordpro/08.csg.source rename to test/test_song/08.csg.source diff --git a/test/test_chordpro/08.tsg b/test/test_song/08.tsg similarity index 100% rename from test/test_chordpro/08.tsg rename to test/test_song/08.tsg diff --git a/test/test_chordpro/09.csg b/test/test_song/09.csg similarity index 100% rename from test/test_chordpro/09.csg rename to test/test_song/09.csg diff --git a/test/test_chordpro/09.csg.source b/test/test_song/09.csg.source similarity index 100% rename from test/test_chordpro/09.csg.source rename to test/test_song/09.csg.source diff --git a/test/test_chordpro/09.tsg b/test/test_song/09.tsg similarity index 100% rename from test/test_chordpro/09.tsg rename to test/test_song/09.tsg diff --git a/test/test_chordpro/10.csg b/test/test_song/10.csg similarity index 100% rename from test/test_chordpro/10.csg rename to test/test_song/10.csg diff --git a/test/test_chordpro/10.csg.source b/test/test_song/10.csg.source similarity index 100% rename from test/test_chordpro/10.csg.source rename to test/test_song/10.csg.source diff --git a/test/test_chordpro/10.tsg b/test/test_song/10.tsg similarity index 100% rename from test/test_chordpro/10.tsg rename to test/test_song/10.tsg diff --git a/test/test_chordpro/11.csg b/test/test_song/11.csg similarity index 100% rename from test/test_chordpro/11.csg rename to test/test_song/11.csg diff --git a/test/test_chordpro/11.csg.source b/test/test_song/11.csg.source similarity index 100% rename from test/test_chordpro/11.csg.source rename to test/test_song/11.csg.source diff --git a/test/test_chordpro/11.tsg b/test/test_song/11.tsg similarity index 100% rename from test/test_chordpro/11.tsg rename to test/test_song/11.tsg diff --git a/test/test_chordpro/12.csg b/test/test_song/12.csg similarity index 100% rename from test/test_chordpro/12.csg rename to test/test_song/12.csg diff --git a/test/test_chordpro/12.csg.source b/test/test_song/12.csg.source similarity index 100% rename from test/test_chordpro/12.csg.source rename to test/test_song/12.csg.source diff --git a/test/test_chordpro/12.tsg b/test/test_song/12.tsg similarity index 100% rename from test/test_chordpro/12.tsg rename to test/test_song/12.tsg diff --git a/test/test_chordpro/13.csg b/test/test_song/13.csg similarity index 100% rename from test/test_chordpro/13.csg rename to test/test_song/13.csg diff --git a/test/test_chordpro/13.csg.source b/test/test_song/13.csg.source similarity index 100% rename from test/test_chordpro/13.csg.source rename to test/test_song/13.csg.source diff --git a/test/test_chordpro/13.tsg b/test/test_song/13.tsg similarity index 100% rename from test/test_chordpro/13.tsg rename to test/test_song/13.tsg diff --git a/test/test_chordpro/21.csg b/test/test_song/21.csg similarity index 100% rename from test/test_chordpro/21.csg rename to test/test_song/21.csg diff --git a/test/test_chordpro/21.csg.source b/test/test_song/21.csg.source similarity index 100% rename from test/test_chordpro/21.csg.source rename to test/test_song/21.csg.source diff --git a/test/test_chordpro/21.tsg b/test/test_song/21.tsg similarity index 100% rename from test/test_chordpro/21.tsg rename to test/test_song/21.tsg diff --git a/test/test_chordpro/22.csg b/test/test_song/22.csg similarity index 100% rename from test/test_chordpro/22.csg rename to test/test_song/22.csg diff --git a/test/test_chordpro/22.csg.source b/test/test_song/22.csg.source similarity index 100% rename from test/test_chordpro/22.csg.source rename to test/test_song/22.csg.source diff --git a/test/test_chordpro/22.tsg b/test/test_song/22.tsg similarity index 100% rename from test/test_chordpro/22.tsg rename to test/test_song/22.tsg diff --git a/test/test_chordpro/23.csg b/test/test_song/23.csg similarity index 100% rename from test/test_chordpro/23.csg rename to test/test_song/23.csg diff --git a/test/test_chordpro/23.csg.source b/test/test_song/23.csg.source similarity index 100% rename from test/test_chordpro/23.csg.source rename to test/test_song/23.csg.source diff --git a/test/test_chordpro/23.tsg b/test/test_song/23.tsg similarity index 100% rename from test/test_chordpro/23.tsg rename to test/test_song/23.tsg diff --git a/test/test_chordpro/24.csg b/test/test_song/24.csg similarity index 100% rename from test/test_chordpro/24.csg rename to test/test_song/24.csg diff --git a/test/test_chordpro/24.csg.source b/test/test_song/24.csg.source similarity index 100% rename from test/test_chordpro/24.csg.source rename to test/test_song/24.csg.source diff --git a/test/test_chordpro/24.tsg b/test/test_song/24.tsg similarity index 100% rename from test/test_chordpro/24.tsg rename to test/test_song/24.tsg diff --git a/test/test_chordpro/25.csg b/test/test_song/25.csg similarity index 100% rename from test/test_chordpro/25.csg rename to test/test_song/25.csg diff --git a/test/test_chordpro/25.csg.source b/test/test_song/25.csg.source similarity index 100% rename from test/test_chordpro/25.csg.source rename to test/test_song/25.csg.source diff --git a/test/test_chordpro/25.tsg b/test/test_song/25.tsg similarity index 100% rename from test/test_chordpro/25.tsg rename to test/test_song/25.tsg diff --git a/test/test_chordpro/26.csg b/test/test_song/26.csg similarity index 100% rename from test/test_chordpro/26.csg rename to test/test_song/26.csg diff --git a/test/test_chordpro/26.csg.source b/test/test_song/26.csg.source similarity index 100% rename from test/test_chordpro/26.csg.source rename to test/test_song/26.csg.source diff --git a/test/test_chordpro/26.tsg b/test/test_song/26.tsg similarity index 100% rename from test/test_chordpro/26.tsg rename to test/test_song/26.tsg diff --git a/test/test_chordpro/27.csg b/test/test_song/27.csg similarity index 100% rename from test/test_chordpro/27.csg rename to test/test_song/27.csg diff --git a/test/test_chordpro/27.csg.source b/test/test_song/27.csg.source similarity index 100% rename from test/test_chordpro/27.csg.source rename to test/test_song/27.csg.source diff --git a/test/test_chordpro/27.tsg b/test/test_song/27.tsg similarity index 100% rename from test/test_chordpro/27.tsg rename to test/test_song/27.tsg diff --git a/test/test_chordpro/28.csg b/test/test_song/28.csg similarity index 100% rename from test/test_chordpro/28.csg rename to test/test_song/28.csg diff --git a/test/test_chordpro/28.csg.source b/test/test_song/28.csg.source similarity index 100% rename from test/test_chordpro/28.csg.source rename to test/test_song/28.csg.source diff --git a/test/test_chordpro/28.tsg b/test/test_song/28.tsg similarity index 100% rename from test/test_chordpro/28.tsg rename to test/test_song/28.tsg diff --git a/test/test_chordpro/29.csg b/test/test_song/29.csg similarity index 100% rename from test/test_chordpro/29.csg rename to test/test_song/29.csg diff --git a/test/test_chordpro/29.csg.source b/test/test_song/29.csg.source similarity index 100% rename from test/test_chordpro/29.csg.source rename to test/test_song/29.csg.source diff --git a/test/test_chordpro/29.tsg b/test/test_song/29.tsg similarity index 100% rename from test/test_chordpro/29.tsg rename to test/test_song/29.tsg diff --git a/test/test_chordpro/__init__.py b/test/test_song/__init__.py similarity index 100% rename from test/test_chordpro/__init__.py rename to test/test_song/__init__.py diff --git a/test/test_chordpro/author_names.csg b/test/test_song/author_names.csg similarity index 100% rename from test/test_chordpro/author_names.csg rename to test/test_song/author_names.csg diff --git a/test/test_chordpro/author_names.csg.source b/test/test_song/author_names.csg.source similarity index 100% rename from test/test_chordpro/author_names.csg.source rename to test/test_song/author_names.csg.source diff --git a/test/test_chordpro/author_names.tsg b/test/test_song/author_names.tsg similarity index 100% rename from test/test_chordpro/author_names.tsg rename to test/test_song/author_names.tsg diff --git a/test/test_chordpro/chords.csg b/test/test_song/chords.csg similarity index 100% rename from test/test_chordpro/chords.csg rename to test/test_song/chords.csg diff --git a/test/test_chordpro/chords.csg.source b/test/test_song/chords.csg.source similarity index 100% rename from test/test_chordpro/chords.csg.source rename to test/test_song/chords.csg.source diff --git a/test/test_chordpro/chords.tsg b/test/test_song/chords.tsg similarity index 100% rename from test/test_chordpro/chords.tsg rename to test/test_song/chords.tsg diff --git a/test/test_chordpro/customchords.csg b/test/test_song/customchords.csg similarity index 100% rename from test/test_chordpro/customchords.csg rename to test/test_song/customchords.csg diff --git a/test/test_chordpro/customchords.csg.source b/test/test_song/customchords.csg.source similarity index 100% rename from test/test_chordpro/customchords.csg.source rename to test/test_song/customchords.csg.source diff --git a/test/test_chordpro/customchords.tsg b/test/test_song/customchords.tsg similarity index 100% rename from test/test_chordpro/customchords.tsg rename to test/test_song/customchords.tsg diff --git a/test/test_chordpro/datadir/img/traditionnel.png b/test/test_song/datadir/img/traditionnel.png similarity index 100% rename from test/test_chordpro/datadir/img/traditionnel.png rename to test/test_song/datadir/img/traditionnel.png diff --git a/test/test_chordpro/datadir/scores/greensleeves.ly b/test/test_song/datadir/scores/greensleeves.ly similarity index 100% rename from test/test_chordpro/datadir/scores/greensleeves.ly rename to test/test_song/datadir/scores/greensleeves.ly diff --git a/test/test_chordpro/errors/invalid_content.csg.source b/test/test_song/errors/invalid_content.csg.source similarity index 100% rename from test/test_chordpro/errors/invalid_content.csg.source rename to test/test_song/errors/invalid_content.csg.source diff --git a/test/test_chordpro/greensleeves.csg b/test/test_song/greensleeves.csg similarity index 100% rename from test/test_chordpro/greensleeves.csg rename to test/test_song/greensleeves.csg diff --git a/test/test_chordpro/greensleeves.csg.source b/test/test_song/greensleeves.csg.source similarity index 100% rename from test/test_chordpro/greensleeves.csg.source rename to test/test_song/greensleeves.csg.source diff --git a/test/test_chordpro/greensleeves.tsg b/test/test_song/greensleeves.tsg similarity index 100% rename from test/test_chordpro/greensleeves.tsg rename to test/test_song/greensleeves.tsg diff --git a/test/test_chordpro/invalid_chord.csg b/test/test_song/invalid_chord.csg similarity index 100% rename from test/test_chordpro/invalid_chord.csg rename to test/test_song/invalid_chord.csg diff --git a/test/test_chordpro/invalid_chord.csg.source b/test/test_song/invalid_chord.csg.source similarity index 100% rename from test/test_chordpro/invalid_chord.csg.source rename to test/test_song/invalid_chord.csg.source diff --git a/test/test_chordpro/invalid_chord.tsg b/test/test_song/invalid_chord.tsg similarity index 100% rename from test/test_chordpro/invalid_chord.tsg rename to test/test_song/invalid_chord.tsg diff --git a/test/test_chordpro/invalid_customchord.csg b/test/test_song/invalid_customchord.csg similarity index 100% rename from test/test_chordpro/invalid_customchord.csg rename to test/test_song/invalid_customchord.csg diff --git a/test/test_chordpro/invalid_customchord.csg.source b/test/test_song/invalid_customchord.csg.source similarity index 100% rename from test/test_chordpro/invalid_customchord.csg.source rename to test/test_song/invalid_customchord.csg.source diff --git a/test/test_chordpro/invalid_customchord.tsg b/test/test_song/invalid_customchord.tsg similarity index 100% rename from test/test_chordpro/invalid_customchord.tsg rename to test/test_song/invalid_customchord.tsg diff --git a/test/test_chordpro/invalid_directive.csg b/test/test_song/invalid_directive.csg similarity index 100% rename from test/test_chordpro/invalid_directive.csg rename to test/test_song/invalid_directive.csg diff --git a/test/test_chordpro/invalid_directive.csg.source b/test/test_song/invalid_directive.csg.source similarity index 100% rename from test/test_chordpro/invalid_directive.csg.source rename to test/test_song/invalid_directive.csg.source diff --git a/test/test_chordpro/invalid_directive.tsg b/test/test_song/invalid_directive.tsg similarity index 100% rename from test/test_chordpro/invalid_directive.tsg rename to test/test_song/invalid_directive.tsg diff --git a/test/test_chordpro/lang.csg b/test/test_song/lang.csg similarity index 100% rename from test/test_chordpro/lang.csg rename to test/test_song/lang.csg diff --git a/test/test_chordpro/lang.csg.source b/test/test_song/lang.csg.source similarity index 100% rename from test/test_chordpro/lang.csg.source rename to test/test_song/lang.csg.source diff --git a/test/test_chordpro/metadata.csg b/test/test_song/metadata.csg similarity index 100% rename from test/test_chordpro/metadata.csg rename to test/test_song/metadata.csg diff --git a/test/test_chordpro/metadata.csg.source b/test/test_song/metadata.csg.source similarity index 100% rename from test/test_chordpro/metadata.csg.source rename to test/test_song/metadata.csg.source diff --git a/test/test_chordpro/metadata.tsg b/test/test_song/metadata.tsg similarity index 100% rename from test/test_chordpro/metadata.tsg rename to test/test_song/metadata.tsg diff --git a/test/test_chordpro/metadata_cover.png b/test/test_song/metadata_cover.png similarity index 100% rename from test/test_chordpro/metadata_cover.png rename to test/test_song/metadata_cover.png diff --git a/test/test_chordpro/metadata_image.png b/test/test_song/metadata_image.png similarity index 100% rename from test/test_chordpro/metadata_image.png rename to test/test_song/metadata_image.png diff --git a/test/test_chordpro/metadata_lilypond.ly b/test/test_song/metadata_lilypond.ly similarity index 100% rename from test/test_chordpro/metadata_lilypond.ly rename to test/test_song/metadata_lilypond.ly diff --git a/test/test_chordpro/newline.crlf.csg b/test/test_song/newline.crlf.csg similarity index 100% rename from test/test_chordpro/newline.crlf.csg rename to test/test_song/newline.crlf.csg diff --git a/test/test_chordpro/newline.crlf.csg.source b/test/test_song/newline.crlf.csg.source similarity index 100% rename from test/test_chordpro/newline.crlf.csg.source rename to test/test_song/newline.crlf.csg.source diff --git a/test/test_chordpro/newline.crlf.html b/test/test_song/newline.crlf.html similarity index 100% rename from test/test_chordpro/newline.crlf.html rename to test/test_song/newline.crlf.html diff --git a/test/test_chordpro/newline.crlf.tsg b/test/test_song/newline.crlf.tsg similarity index 100% rename from test/test_chordpro/newline.crlf.tsg rename to test/test_song/newline.crlf.tsg diff --git a/test/test_chordpro/newline.csg b/test/test_song/newline.csg similarity index 100% rename from test/test_chordpro/newline.csg rename to test/test_song/newline.csg diff --git a/test/test_chordpro/newline.csg.source b/test/test_song/newline.csg.source similarity index 100% rename from test/test_chordpro/newline.csg.source rename to test/test_song/newline.csg.source diff --git a/test/test_chordpro/newline.html b/test/test_song/newline.html similarity index 100% rename from test/test_chordpro/newline.html rename to test/test_song/newline.html diff --git a/test/test_chordpro/newline.tsg b/test/test_song/newline.tsg similarity index 100% rename from test/test_chordpro/newline.tsg rename to test/test_song/newline.tsg diff --git a/test/test_chordpro/nolyrics.csg b/test/test_song/nolyrics.csg similarity index 100% rename from test/test_chordpro/nolyrics.csg rename to test/test_song/nolyrics.csg diff --git a/test/test_chordpro/nolyrics.csg.source b/test/test_song/nolyrics.csg.source similarity index 100% rename from test/test_chordpro/nolyrics.csg.source rename to test/test_song/nolyrics.csg.source diff --git a/test/test_chordpro/nolyrics.tsg b/test/test_song/nolyrics.tsg similarity index 100% rename from test/test_chordpro/nolyrics.tsg rename to test/test_song/nolyrics.tsg diff --git a/test/test_chordpro/tags.csg b/test/test_song/tags.csg similarity index 100% rename from test/test_chordpro/tags.csg rename to test/test_song/tags.csg diff --git a/test/test_chordpro/tags.csg.source b/test/test_song/tags.csg.source similarity index 100% rename from test/test_chordpro/tags.csg.source rename to test/test_song/tags.csg.source diff --git a/test/test_chordpro/tags.tsg b/test/test_song/tags.tsg similarity index 100% rename from test/test_chordpro/tags.tsg rename to test/test_song/tags.tsg diff --git a/test/test_chordpro/test_parser.py b/test/test_song/test_parser.py similarity index 100% rename from test/test_chordpro/test_parser.py rename to test/test_song/test_parser.py diff --git a/test/test_chordpro/ukulelechords.csg b/test/test_song/ukulelechords.csg similarity index 100% rename from test/test_chordpro/ukulelechords.csg rename to test/test_song/ukulelechords.csg diff --git a/test/test_chordpro/ukulelechords.csg.source b/test/test_song/ukulelechords.csg.source similarity index 100% rename from test/test_chordpro/ukulelechords.csg.source rename to test/test_song/ukulelechords.csg.source diff --git a/test/test_chordpro/ukulelechords.tsg b/test/test_song/ukulelechords.tsg similarity index 100% rename from test/test_chordpro/ukulelechords.tsg rename to test/test_song/ukulelechords.tsg diff --git a/test/test_compilation/__init__.py b/test/test_songbook/__init__.py similarity index 100% rename from test/test_compilation/__init__.py rename to test/test_songbook/__init__.py diff --git a/test/test_compilation/datadir.sb b/test/test_songbook/datadir.sb similarity index 100% rename from test/test_compilation/datadir.sb rename to test/test_songbook/datadir.sb diff --git a/test/test_compilation/datadir.tex.control b/test/test_songbook/datadir.tex.control similarity index 100% rename from test/test_compilation/datadir.tex.control rename to test/test_songbook/datadir.tex.control diff --git a/test/test_compilation/datadir_datadir/img/datadir.png b/test/test_songbook/datadir_datadir/img/datadir.png similarity index 100% rename from test/test_compilation/datadir_datadir/img/datadir.png rename to test/test_songbook/datadir_datadir/img/datadir.png diff --git a/test/test_compilation/datadir_datadir/scores/datadir.ly b/test/test_songbook/datadir_datadir/scores/datadir.ly similarity index 100% rename from test/test_compilation/datadir_datadir/scores/datadir.ly rename to test/test_songbook/datadir_datadir/scores/datadir.ly diff --git a/test/test_compilation/datadir_datadir/songs/datadir.csg b/test/test_songbook/datadir_datadir/songs/datadir.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir.csg rename to test/test_songbook/datadir_datadir/songs/datadir.csg diff --git a/test/test_compilation/datadir_datadir/songs/datadir.tsg b/test/test_songbook/datadir_datadir/songs/datadir.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir.tsg rename to test/test_songbook/datadir_datadir/songs/datadir.tsg diff --git a/test/test_compilation/datadir_datadir/songs/datadir2.csg b/test/test_songbook/datadir_datadir/songs/datadir2.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir2.csg rename to test/test_songbook/datadir_datadir/songs/datadir2.csg diff --git a/test/test_compilation/datadir_datadir/songs/datadir2.sg b/test/test_songbook/datadir_datadir/songs/datadir2.sg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir2.sg rename to test/test_songbook/datadir_datadir/songs/datadir2.sg diff --git a/test/test_compilation/datadir_datadir/songs/relative.csg b/test/test_songbook/datadir_datadir/songs/relative.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.csg rename to test/test_songbook/datadir_datadir/songs/relative.csg diff --git a/test/test_compilation/datadir_datadir/songs/relative.ly b/test/test_songbook/datadir_datadir/songs/relative.ly similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.ly rename to test/test_songbook/datadir_datadir/songs/relative.ly diff --git a/test/test_compilation/datadir_datadir/songs/relative.png b/test/test_songbook/datadir_datadir/songs/relative.png similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.png rename to test/test_songbook/datadir_datadir/songs/relative.png diff --git a/test/test_compilation/datadir_datadir/songs/relative.tsg b/test/test_songbook/datadir_datadir/songs/relative.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.tsg rename to test/test_songbook/datadir_datadir/songs/relative.tsg diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.csg b/test/test_songbook/datadir_datadir/songs/subdir/subdir.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.csg rename to test/test_songbook/datadir_datadir/songs/subdir/subdir.csg diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.ly b/test/test_songbook/datadir_datadir/songs/subdir/subdir.ly similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.ly rename to test/test_songbook/datadir_datadir/songs/subdir/subdir.ly diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.png b/test/test_songbook/datadir_datadir/songs/subdir/subdir.png similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.png rename to test/test_songbook/datadir_datadir/songs/subdir/subdir.png diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.tsg b/test/test_songbook/datadir_datadir/songs/subdir/subdir.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.tsg rename to test/test_songbook/datadir_datadir/songs/subdir/subdir.tsg diff --git a/test/test_compilation/datadir_datadir2/img/datadir2.png b/test/test_songbook/datadir_datadir2/img/datadir2.png similarity index 100% rename from test/test_compilation/datadir_datadir2/img/datadir2.png rename to test/test_songbook/datadir_datadir2/img/datadir2.png diff --git a/test/test_compilation/datadir_datadir2/scores/datadir2.ly b/test/test_songbook/datadir_datadir2/scores/datadir2.ly similarity index 100% rename from test/test_compilation/datadir_datadir2/scores/datadir2.ly rename to test/test_songbook/datadir_datadir2/scores/datadir2.ly diff --git a/test/test_compilation/languages.sb b/test/test_songbook/languages.sb similarity index 100% rename from test/test_compilation/languages.sb rename to test/test_songbook/languages.sb diff --git a/test/test_compilation/languages.tex.control b/test/test_songbook/languages.tex.control similarity index 100% rename from test/test_compilation/languages.tex.control rename to test/test_songbook/languages.tex.control diff --git a/test/test_compilation/languages_datadir/songs/language.csg b/test/test_songbook/languages_datadir/songs/language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/language.csg rename to test/test_songbook/languages_datadir/songs/language.csg diff --git a/test/test_compilation/languages_datadir/songs/language_location.csg b/test/test_songbook/languages_datadir/songs/language_location.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/language_location.csg rename to test/test_songbook/languages_datadir/songs/language_location.csg diff --git a/test/test_compilation/languages_datadir/songs/no_language.csg b/test/test_songbook/languages_datadir/songs/no_language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/no_language.csg rename to test/test_songbook/languages_datadir/songs/no_language.csg diff --git a/test/test_compilation/languages_datadir/songs/wrong_language.csg b/test/test_songbook/languages_datadir/songs/wrong_language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/wrong_language.csg rename to test/test_songbook/languages_datadir/songs/wrong_language.csg diff --git a/test/test_compilation/languages_datadir/songs/wrong_location.csg b/test/test_songbook/languages_datadir/songs/wrong_location.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/wrong_location.csg rename to test/test_songbook/languages_datadir/songs/wrong_location.csg diff --git a/test/test_compilation/syntax.sb b/test/test_songbook/syntax.sb similarity index 100% rename from test/test_compilation/syntax.sb rename to test/test_songbook/syntax.sb diff --git a/test/test_compilation/syntax.tex.control b/test/test_songbook/syntax.tex.control similarity index 100% rename from test/test_compilation/syntax.tex.control rename to test/test_songbook/syntax.tex.control diff --git a/test/test_compilation/syntax_datadir/songs/musicnote.csg b/test/test_songbook/syntax_datadir/songs/musicnote.csg similarity index 100% rename from test/test_compilation/syntax_datadir/songs/musicnote.csg rename to test/test_songbook/syntax_datadir/songs/musicnote.csg diff --git a/test/test_compilation/test_compilation.py b/test/test_songbook/test_compilation.py similarity index 100% rename from test/test_compilation/test_compilation.py rename to test/test_songbook/test_compilation.py diff --git a/test/test_compilation/unicode.sb b/test/test_songbook/unicode.sb similarity index 100% rename from test/test_compilation/unicode.sb rename to test/test_songbook/unicode.sb diff --git a/test/test_compilation/unicode.tex.control b/test/test_songbook/unicode.tex.control similarity index 100% rename from test/test_compilation/unicode.tex.control rename to test/test_songbook/unicode.tex.control diff --git a/test/test_compilation/unicode_datadir/songs/nonbreak.csg b/test/test_songbook/unicode_datadir/songs/nonbreak.csg similarity index 100% rename from test/test_compilation/unicode_datadir/songs/nonbreak.csg rename to test/test_songbook/unicode_datadir/songs/nonbreak.csg From 3f51411943296e0b71c63fab59d60b247b4cd3db Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 18:16:52 +0100 Subject: [PATCH 05/41] Test tsg parsing --- test/test_song/greensleeves.tsg.source | 68 ++++++++++++++++++++++++++ test/test_song/test_parser.py | 7 ++- 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 test/test_song/greensleeves.tsg.source diff --git a/test/test_song/greensleeves.tsg.source b/test/test_song/greensleeves.tsg.source new file mode 100644 index 00000000..c4bc461d --- /dev/null +++ b/test/test_song/greensleeves.tsg.source @@ -0,0 +1,68 @@ +\selectlanguage{english} +\songcolumns{2} + +\beginsong{Greensleeves\\ +Un autre sous-titre\\ +Un sous titre}[ + by={ + Traditionnel }, + album={Angleterre}, + cover={img/traditionnel}, +] + +\cover + + + +\lilypond{scores/greensleeves.ly} + + + +\begin{verse} + A\[Am]las, my love, ye \[G]do me wrong + To \[Am]cast me oft dis\[E]curteously + And \[Am]I have loved \[G]you so long + De\[Am]lighting \[E]in your \[Am]companie +\end{verse} + + +\begin{chorus} + \[C]Green\[B]sleeves was \[G]all my joy + \[Am]Greensleeves was \[E]my delight + \[C]Greensleeves was my \[G]heart of gold + And \[Am]who but \[E]Ladie \[Am]Greensleeves +\end{chorus} + + +\begin{verse} + I \[Am]have been ready \[G]at your hand + To \[Am]grant what ever \[E]you would crave + I \[Am]have both waged \[G]life and land + Your \[Am]love and \[E]good will \[Am]for to have +\end{verse} + + +\begin{verse} + I \[Am]bought thee kerchers \[G]to thy head + That \[Am]were wrought fine and \[E]gallantly + I \[Am]kept thee both at \[G]boord and bed + Which \[Am]cost my \[E]purse well \[Am]favouredly +\end{verse} + + +\begin{verse} + I \[Am]bought thee peticotes \[G]of the best + The \[Am]cloth so fine as \[E]fine might be + I \[Am]gave thee jewels \[G]for thy chest + And \[Am]all this \[E]cost I \[Am]spent on thee +\end{verse} + + +\begin{verse} + Thy \[Am]smock of silke, both \[G]faire and white + With \[Am]gold embrodered \[E]gorgeously + Thy \[Am]peticote of \[G]sendall right + And \[Am]this I \[E]bought thee \[Am]gladly +\end{verse} + +\endsong diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index cd38afcd..11a8f30e 100644 --- a/test/test_song/test_parser.py +++ b/test/test_song/test_parser.py @@ -15,7 +15,10 @@ from patacrep.encoding import open_read from .. import disable_logging from .. import dynamic # pylint: disable=unused-import -OUTPUTS = ['csg', 'tsg', 'html'] +OUTPUTS = { + 'csg': ['csg', 'tsg', 'html'], + 'tsg': ['tsg'], +} class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of chorpro parser, and several renderers. @@ -81,7 +84,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): for source in sorted(glob.glob('*.*.source')): [*base, in_format, _] = source.split('.') base = '.'.join(base) - for out_format in OUTPUTS: + for out_format in OUTPUTS[in_format]: outname = "{}.{}".format(base, out_format) if not os.path.exists(outname): continue From 7bbbafa0e29aaaab42e4cabbe354c75bd9f00ae4 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 16 Nov 2015 08:27:47 +0100 Subject: [PATCH 06/41] newline fix --- patacrep/latex/lexer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/latex/lexer.py b/patacrep/latex/lexer.py index f76500f8..81679255 100644 --- a/patacrep/latex/lexer.py +++ b/patacrep/latex/lexer.py @@ -60,7 +60,7 @@ class SimpleLexer: # Define a rule so we can track line numbers @staticmethod def t_endofline(token): - r'\n+' + r'(\r?\n)+' token.lexer.lineno += len(token.value) @staticmethod From 8f1908d4deea81c9b591858ffcb72e795aef2261 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 16 Nov 2015 17:35:02 +0100 Subject: [PATCH 07/41] Allow trailing comma after dictionnay element --- patacrep/latex/syntax.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/patacrep/latex/syntax.py b/patacrep/latex/syntax.py index 8915816b..330f9eee 100644 --- a/patacrep/latex/syntax.py +++ b/patacrep/latex/syntax.py @@ -130,8 +130,11 @@ class LatexParser(Parser): def p_dictionary(symbols): """dictionary : identifier EQUAL braces dictionary_next | identifier EQUAL error dictionary_next + | empty """ - if isinstance(symbols[3], ast.Expression): + if len(symbols) == 2: + symbols[0] = {} + elif isinstance(symbols[3], ast.Expression): symbols[0] = {} symbols[0][symbols[1]] = symbols[3] symbols[0].update(symbols[4]) From ea1113d43d43fc62733b63e58c8a78997c408bdf Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 16 Nov 2015 17:45:37 +0100 Subject: [PATCH 08/41] Improve latex tests --- test/test_song/greensleeves_latex.crlf.tsg | 1 + test/test_song/greensleeves_latex.crlf.tsg.source | 2 ++ test/test_song/greensleeves_latex.tsg | 1 + ...reensleeves.tsg.source => greensleeves_latex.tsg.source} | 0 test/test_song/test_parser.py | 6 +++++- 5 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/test_song/greensleeves_latex.crlf.tsg create mode 100644 test/test_song/greensleeves_latex.crlf.tsg.source create mode 100644 test/test_song/greensleeves_latex.tsg rename test/test_song/{greensleeves.tsg.source => greensleeves_latex.tsg.source} (100%) diff --git a/test/test_song/greensleeves_latex.crlf.tsg b/test/test_song/greensleeves_latex.crlf.tsg new file mode 100644 index 00000000..5c2c33e3 --- /dev/null +++ b/test/test_song/greensleeves_latex.crlf.tsg @@ -0,0 +1 @@ +\import{@TEST_FOLDER@/}{greensleeves_latex.crlf.tsg.source} \ No newline at end of file diff --git a/test/test_song/greensleeves_latex.crlf.tsg.source b/test/test_song/greensleeves_latex.crlf.tsg.source new file mode 100644 index 00000000..ff805290 --- /dev/null +++ b/test/test_song/greensleeves_latex.crlf.tsg.source @@ -0,0 +1,2 @@ +# This content will be overwritten with `greensleeves_latex.tsg.source` content +# with windows line endings (CRLF) - for testing purposes diff --git a/test/test_song/greensleeves_latex.tsg b/test/test_song/greensleeves_latex.tsg new file mode 100644 index 00000000..0edd8826 --- /dev/null +++ b/test/test_song/greensleeves_latex.tsg @@ -0,0 +1 @@ +\import{@TEST_FOLDER@/}{greensleeves_latex.tsg.source} \ No newline at end of file diff --git a/test/test_song/greensleeves.tsg.source b/test/test_song/greensleeves_latex.tsg.source similarity index 100% rename from test/test_song/greensleeves.tsg.source rename to test/test_song/greensleeves_latex.tsg.source diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index 11a8f30e..1f995df0 100644 --- a/test/test_song/test_parser.py +++ b/test/test_song/test_parser.py @@ -61,9 +61,13 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with open_read(destname) as expectfile: with disable_logging(): song = self.song_plugins[out_format][in_format](sourcename, self.config) + expected = expectfile.read().strip().replace( + "@TEST_FOLDER@", + files.path2posix(resource_filename(__name__, "")), + ) self.assertMultiLineEqual( song.render().strip(), - expectfile.read().strip(), + expected, ) @classmethod From 31588e5ab1011dde2725cef7faf6ee86964ee792 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 16 Nov 2015 17:51:23 +0100 Subject: [PATCH 09/41] Forgotten gitignore --- test/test_songbook/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/test_songbook/.gitignore diff --git a/test/test_songbook/.gitignore b/test/test_songbook/.gitignore new file mode 100644 index 00000000..3f49c007 --- /dev/null +++ b/test/test_songbook/.gitignore @@ -0,0 +1,2 @@ +/*tex +.cache From d945277793ce23f047564b55f70a6ffad9ecdc54 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 10 Nov 2015 18:22:23 +0100 Subject: [PATCH 10/41] Move the DEFAULT_CONFIG --- patacrep/build.py | 10 +--------- patacrep/songs/__init__.py | 14 +++++++++++++- patacrep/songs/convert/__main__.py | 2 +- test/test_chordpro/test_parser.py | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index 0526d5c2..33a91eee 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -11,7 +11,7 @@ from subprocess import Popen, PIPE, call, check_call from patacrep import authors, content, errors, files from patacrep.index import process_sxd from patacrep.templates import TexBookRenderer -from patacrep.songs import DataSubpath +from patacrep.songs import DataSubpath, DEFAULT_CONFIG LOGGER = logging.getLogger(__name__) EOL = "\n" @@ -27,14 +27,6 @@ GENERATED_EXTENSIONS = [ "_title.sbx", "_title.sxd", ] -DEFAULT_CONFIG = { - 'template': "default.tex", - 'lang': 'en', - 'content': [], - 'titleprefixwords': [], - 'encoding': None, - 'datadir': [], - } diff --git a/patacrep/songs/__init__.py b/patacrep/songs/__init__.py index 2b1a5768..d7619096 100644 --- a/patacrep/songs/__init__.py +++ b/patacrep/songs/__init__.py @@ -12,6 +12,15 @@ from patacrep.authors import process_listauthors LOGGER = logging.getLogger(__name__) +DEFAULT_CONFIG = { + 'template': "default.tex", + 'lang': 'en', + 'content': [], + 'titleprefixwords': [], + 'encoding': None, + 'datadir': [], + } + def cached_name(datadir, filename): """Return the filename of the cache version of the file.""" fullpath = os.path.abspath(os.path.join(datadir, '.cache', filename)) @@ -93,7 +102,10 @@ class Song: "_version", ] - def __init__(self, subpath, config, *, datadir=None): + def __init__(self, subpath, config=None, *, datadir=None): + if config is None: + config = DEFAULT_CONFIG.copy() + if datadir is None: self.datadir = "" # Only songs in datadirs may be cached diff --git a/patacrep/songs/convert/__main__.py b/patacrep/songs/convert/__main__.py index 90276f7b..19d7041e 100644 --- a/patacrep/songs/convert/__main__.py +++ b/patacrep/songs/convert/__main__.py @@ -8,7 +8,7 @@ import logging import sys from patacrep import files -from patacrep.build import DEFAULT_CONFIG +from patacrep.songs import DEFAULT_CONFIG from patacrep.utils import yesno LOGGER = logging.getLogger(__name__) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index cd38afcd..a0b5a288 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -9,7 +9,7 @@ import unittest from pkg_resources import resource_filename from patacrep import files -from patacrep.build import DEFAULT_CONFIG +from patacrep.songs import DEFAULT_CONFIG from patacrep.encoding import open_read from .. import disable_logging From bebe153dfd336b0ca84d734a2a7887fb7de51416 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 09:00:40 +0100 Subject: [PATCH 11/41] useless branch --- patacrep/content/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index 040adbad..f6e81454 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -180,8 +180,6 @@ def process_content(content, config=None): for elem in content: if isinstance(elem, str): elem = ["song", elem] - if len(content) == 0: - content = ["song"] try: match = keyword_re.match(elem[0]).groupdict() except AttributeError: From 50e521ea18c1b5d0496b0fc4e130ebbe610d906e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 09:06:07 +0100 Subject: [PATCH 12/41] Typo --- test/test_songbook/test_compilation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_songbook/test_compilation.py b/test/test_songbook/test_compilation.py index a095dbfb..b225756e 100644 --- a/test/test_songbook/test_compilation.py +++ b/test/test_songbook/test_compilation.py @@ -1,4 +1,4 @@ -"""Tests for the chordpro parser.""" +"""Tests for the songbook compilation.""" # pylint: disable=too-few-public-methods From 7c8653d8b2194538974966e77b44adc922c77cd5 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 09:43:31 +0100 Subject: [PATCH 13/41] Create content tests --- test/test_content/__init__.py | 0 test/test_content/datadir/songs/chordpro.csg | 51 +++++++++ test/test_content/datadir/songs/exsong.sg | 10 ++ test/test_content/datadir/songs/intersong.is | 6 + test/test_content/datadir/songs/jsonlist.json | 0 .../datadir/songs/subdir/chordpro.csg | 51 +++++++++ test/test_content/datadir/songs/texfile.tex | 70 ++++++++++++ test/test_content/datadir/songs/texsong.tsg | 70 ++++++++++++ test/test_content/sections.control | 1 + test/test_content/sections.source | 6 + test/test_content/songs.control | 1 + test/test_content/songs.source | 1 + test/test_content/sorted.control | 1 + test/test_content/sorted.source | 1 + test/test_content/test_content.py | 106 ++++++++++++++++++ 15 files changed, 375 insertions(+) create mode 100644 test/test_content/__init__.py create mode 100644 test/test_content/datadir/songs/chordpro.csg create mode 100644 test/test_content/datadir/songs/exsong.sg create mode 100644 test/test_content/datadir/songs/intersong.is create mode 100644 test/test_content/datadir/songs/jsonlist.json create mode 100644 test/test_content/datadir/songs/subdir/chordpro.csg create mode 100644 test/test_content/datadir/songs/texfile.tex create mode 100644 test/test_content/datadir/songs/texsong.tsg create mode 100644 test/test_content/sections.control create mode 100644 test/test_content/sections.source create mode 100644 test/test_content/songs.control create mode 100644 test/test_content/songs.source create mode 100644 test/test_content/sorted.control create mode 100644 test/test_content/sorted.source create mode 100644 test/test_content/test_content.py diff --git a/test/test_content/__init__.py b/test/test_content/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/test/test_content/datadir/songs/chordpro.csg b/test/test_content/datadir/songs/chordpro.csg new file mode 100644 index 00000000..c1295968 --- /dev/null +++ b/test/test_content/datadir/songs/chordpro.csg @@ -0,0 +1,51 @@ +{lang : en} +{columns : 2} +{ title : Greensleeves} +{subtitle: Test of the chordpro format} +{artist: Traditionnel} +{artist: Prénom Nom} +{cover : traditionnel.jpg } +{album :Angleterre} + +{partition : greensleeves.ly} + + +A[Am]las, my love, ye [G]do me wrong +To [Am]cast me oft dis[E]curteously +And [Am]I have loved [G]you so long +De[Am]lighting [E]in your [Am]companie + +{start_of_chorus} + [C]Greensleeves was [G]all my joy + [Am]Greensleeves was [E]my delight + [C]Greensleeves was my [G]heart of gold + And [Am]who but [E]Ladie [Am]Greensleeves +{end_of_chorus} + +I [Am]have been ready [G]at your hand +To [Am]grant what ever [E]you would crave +I [Am]have both waged [G]life and land +Your [Am]love and [E]good will [Am]for to have + +I [Am]bought thee kerchers [G]to thy head +That [Am]were wrought fine and [E]gallantly +I [Am]kept thee both at [G]boord and bed +Which [Am]cost my [E]purse well [Am]favouredly + +I [Am]bought thee peticotes [G]of the best +The [Am]cloth so fine as [E]fine might be +I [Am]gave thee jewels [G]for thy chest +And [Am]all this [E]cost I [Am]spent on thee + +{c:test of comment} + +{gc: test of guitar comment} + +{image: traditionnel.jpg} + +Thy [Am]smock of silke, both [G]faire and white +With [Am]gold embrodered [E]gorgeously +Thy [Am]peticote of [G]sendall right +And [Am]this I [E]bought thee [Am]gladly + + diff --git a/test/test_content/datadir/songs/exsong.sg b/test/test_content/datadir/songs/exsong.sg new file mode 100644 index 00000000..f37f351f --- /dev/null +++ b/test/test_content/datadir/songs/exsong.sg @@ -0,0 +1,10 @@ +\beginsong{Image included from a different datadir\\\LaTeX} + [cover={img/datadir2}] + + \cover + + \lilypond{scores/datadir2.ly} + + \image{img/datadir2} + +\endsong diff --git a/test/test_content/datadir/songs/intersong.is b/test/test_content/datadir/songs/intersong.is new file mode 100644 index 00000000..dbeeb547 --- /dev/null +++ b/test/test_content/datadir/songs/intersong.is @@ -0,0 +1,6 @@ +\selectlanguage{french} +\sortassong{}[by={QQ}] +\begin{intersong} + +Lorem ipsum +\end{intersong} diff --git a/test/test_content/datadir/songs/jsonlist.json b/test/test_content/datadir/songs/jsonlist.json new file mode 100644 index 00000000..e69de29b diff --git a/test/test_content/datadir/songs/subdir/chordpro.csg b/test/test_content/datadir/songs/subdir/chordpro.csg new file mode 100644 index 00000000..c1295968 --- /dev/null +++ b/test/test_content/datadir/songs/subdir/chordpro.csg @@ -0,0 +1,51 @@ +{lang : en} +{columns : 2} +{ title : Greensleeves} +{subtitle: Test of the chordpro format} +{artist: Traditionnel} +{artist: Prénom Nom} +{cover : traditionnel.jpg } +{album :Angleterre} + +{partition : greensleeves.ly} + + +A[Am]las, my love, ye [G]do me wrong +To [Am]cast me oft dis[E]curteously +And [Am]I have loved [G]you so long +De[Am]lighting [E]in your [Am]companie + +{start_of_chorus} + [C]Greensleeves was [G]all my joy + [Am]Greensleeves was [E]my delight + [C]Greensleeves was my [G]heart of gold + And [Am]who but [E]Ladie [Am]Greensleeves +{end_of_chorus} + +I [Am]have been ready [G]at your hand +To [Am]grant what ever [E]you would crave +I [Am]have both waged [G]life and land +Your [Am]love and [E]good will [Am]for to have + +I [Am]bought thee kerchers [G]to thy head +That [Am]were wrought fine and [E]gallantly +I [Am]kept thee both at [G]boord and bed +Which [Am]cost my [E]purse well [Am]favouredly + +I [Am]bought thee peticotes [G]of the best +The [Am]cloth so fine as [E]fine might be +I [Am]gave thee jewels [G]for thy chest +And [Am]all this [E]cost I [Am]spent on thee + +{c:test of comment} + +{gc: test of guitar comment} + +{image: traditionnel.jpg} + +Thy [Am]smock of silke, both [G]faire and white +With [Am]gold embrodered [E]gorgeously +Thy [Am]peticote of [G]sendall right +And [Am]this I [E]bought thee [Am]gladly + + diff --git a/test/test_content/datadir/songs/texfile.tex b/test/test_content/datadir/songs/texfile.tex new file mode 100644 index 00000000..81a725ef --- /dev/null +++ b/test/test_content/datadir/songs/texfile.tex @@ -0,0 +1,70 @@ +\selectlanguage{french} +\songcolumns{2} +\beginsong{Chevaliers de la table ronde} + [by={Traditionnel},cover={traditionnel},album={France}] + + \cover + \gtab{C}{X32010} + \gtab{G7}{320001} + \gtab{F}{1:022100} + + \begin{verse} + Cheva\[C]liers de la Table Ronde + Goûtons \[G7]voir si le vin est \[C]bon + \rep{2} + \end{verse} + + \begin{chorus} + Goûtons \[F]voir, \echo{oui, oui, oui} + Goûtons \[C]voir, \echo{non, non, non} + Goûtons \[G7]voir si le vin est bon + \rep{2} + \end{chorus} + + \begin{verse} + S'il est bon, s'il est agréable + J'en boirai jusqu'à mon plaisir + \end{verse} + + \begin{verse} + J'en boirai cinq à six bouteilles + Et encore, ce n'est pas beaucoup + \end{verse} + + \begin{verse} + Si je meurs, je veux qu'on m'enterre + Dans une cave où il y a du bon vin + \end{verse} + + \begin{verse} + Les deux pieds contre la muraille + Et la tête sous le robinet + \end{verse} + + \begin{verse} + Et les quatre plus grands ivrognes + Porteront les quatre coins du drap + \end{verse} + + \begin{verse} + Pour donner le discours d'usage + On prendra le bistrot du coin + \end{verse} + + \begin{verse} + Et si le tonneau se débouche + J'en boirai jusqu'à mon plaisir + \end{verse} + + \begin{verse} + Et s'il en reste quelques gouttes + Ce sera pour nous rafraîchir + \end{verse} + + \begin{verse} + Sur ma tombe, je veux qu'on inscrive + \emph{Ici gît le roi des buveurs} + \end{verse} + +\endsong + diff --git a/test/test_content/datadir/songs/texsong.tsg b/test/test_content/datadir/songs/texsong.tsg new file mode 100644 index 00000000..81a725ef --- /dev/null +++ b/test/test_content/datadir/songs/texsong.tsg @@ -0,0 +1,70 @@ +\selectlanguage{french} +\songcolumns{2} +\beginsong{Chevaliers de la table ronde} + [by={Traditionnel},cover={traditionnel},album={France}] + + \cover + \gtab{C}{X32010} + \gtab{G7}{320001} + \gtab{F}{1:022100} + + \begin{verse} + Cheva\[C]liers de la Table Ronde + Goûtons \[G7]voir si le vin est \[C]bon + \rep{2} + \end{verse} + + \begin{chorus} + Goûtons \[F]voir, \echo{oui, oui, oui} + Goûtons \[C]voir, \echo{non, non, non} + Goûtons \[G7]voir si le vin est bon + \rep{2} + \end{chorus} + + \begin{verse} + S'il est bon, s'il est agréable + J'en boirai jusqu'à mon plaisir + \end{verse} + + \begin{verse} + J'en boirai cinq à six bouteilles + Et encore, ce n'est pas beaucoup + \end{verse} + + \begin{verse} + Si je meurs, je veux qu'on m'enterre + Dans une cave où il y a du bon vin + \end{verse} + + \begin{verse} + Les deux pieds contre la muraille + Et la tête sous le robinet + \end{verse} + + \begin{verse} + Et les quatre plus grands ivrognes + Porteront les quatre coins du drap + \end{verse} + + \begin{verse} + Pour donner le discours d'usage + On prendra le bistrot du coin + \end{verse} + + \begin{verse} + Et si le tonneau se débouche + J'en boirai jusqu'à mon plaisir + \end{verse} + + \begin{verse} + Et s'il en reste quelques gouttes + Ce sera pour nous rafraîchir + \end{verse} + + \begin{verse} + Sur ma tombe, je veux qu'on inscrive + \emph{Ici gît le roi des buveurs} + \end{verse} + +\endsong + diff --git a/test/test_content/sections.control b/test/test_content/sections.control new file mode 100644 index 00000000..3666bbce --- /dev/null +++ b/test/test_content/sections.control @@ -0,0 +1 @@ +["section:Traditional", "exsong.sg", "section:Example", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/sections.source b/test/test_content/sections.source new file mode 100644 index 00000000..339815be --- /dev/null +++ b/test/test_content/sections.source @@ -0,0 +1,6 @@ +[["section", "Traditional"], + "exsong.sg", + ["section", "Example"], + "texsong.tsg", + "chordpro.csg", + "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/songs.control b/test/test_content/songs.control new file mode 100644 index 00000000..e85dfea7 --- /dev/null +++ b/test/test_content/songs.control @@ -0,0 +1 @@ +["exsong.sg", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/songs.source b/test/test_content/songs.source new file mode 100644 index 00000000..dcd19323 --- /dev/null +++ b/test/test_content/songs.source @@ -0,0 +1 @@ +["exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/sorted.control b/test/test_content/sorted.control new file mode 100644 index 00000000..5cfaa29d --- /dev/null +++ b/test/test_content/sorted.control @@ -0,0 +1 @@ +["chordpro.csg", "exsong.sg", "subdir/chordpro.csg", "texsong.tsg"] \ No newline at end of file diff --git a/test/test_content/sorted.source b/test/test_content/sorted.source new file mode 100644 index 00000000..5b2bbf3a --- /dev/null +++ b/test/test_content/sorted.source @@ -0,0 +1 @@ +[["sorted(fullpath)"]] \ No newline at end of file diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py new file mode 100644 index 00000000..c396ccf5 --- /dev/null +++ b/test/test_content/test_content.py @@ -0,0 +1,106 @@ +"""Tests for the content plugins.""" + +# pylint: disable=too-few-public-methods + +import glob +import os +import unittest +import json + +from patacrep.songs import DataSubpath, DEFAULT_CONFIG +from patacrep import content, files +from patacrep.content.song import SongRenderer +from patacrep.content.section import Section + +from .. import dynamic # pylint: disable=unused-import + +class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): + """Test of the content plugins. + + For any given `foo.source`, it parses the content as a json "content" + argument of a .sb file. + It controls that the generated file list is equal to the one in `foo.control`. + """ + + maxDiff = None + config = None + + @classmethod + def setUpClass(cls): + cls._generate_config() + + @classmethod + def _iter_testmethods(cls): + """Iterate over dynamically generated test methods""" + for source in sorted(glob.glob(os.path.join( + os.path.dirname(__file__), + '*.source', + ))): + base = source[:-len(".source")] + yield ( + "test_content_{}".format(os.path.basename(base)), + cls._create_content_test(base), + ) + + @classmethod + def _create_content_test(cls, base): + """Return a function that `base.source` produces the correct file list""" + + def test_content(self): + """Test that `base.source` produces the correct file list""" + sourcename = "{}.source".format(base) + with open(sourcename, mode="r", encoding="utf8") as sourcefile: + sbcontent = json.load(sourcefile) + + expandedlist = content.process_content(sbcontent, cls.config.copy()) + sourcelist = list(map(cls._clean_path, expandedlist)) + + controlname = "{}.control".format(base) + if not os.path.exists(controlname): + raise Exception("Missing control:" + str(sourcelist).replace("'",'"')) + with open(controlname, mode="r", encoding="utf8") as controlfile: + controllist = json.load(controlfile) + + self.assertEqual(controllist, sourcelist) + + test_content.__doc__ = ( + "Test that '{base}.source' produces the correct file list""" + ).format(base=os.path.basename(base)) + return test_content + + @classmethod + def _clean_path(cls, elem): + """Shorten the path relative to the `songs` directory""" + if isinstance(elem, SongRenderer): + songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') + return files.relpath(elem.song.fullpath, songpath) + elif isinstance(elem, Section): + return "{}:{}".format(elem.keyword, elem.name) + else: + raise Exception(elem) + + @classmethod + def _generate_config(cls): + """Generate the config to process the content""" + + config = DEFAULT_CONFIG.copy() + + datadirpath = os.path.join(os.path.dirname(__file__), 'datadir') + + config['datadir'] = [datadirpath] + + config['_songdir'] = [ + DataSubpath(path, 'songs') + for path in config['datadir'] + ] + config['_content_plugins'] = files.load_plugins( + datadirs=config.get('datadir', []), + root_modules=['content'], + keyword='CONTENT_PLUGINS', + ) + config['_song_plugins'] = files.load_plugins( + datadirs=config.get('datadir', []), + root_modules=['songs'], + keyword='SONG_RENDERERS', + )['tsg'] + cls.config = config From aee562c15c7a65277b62f169545015f5cec7c4d9 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 10:08:14 +0100 Subject: [PATCH 14/41] Let 'sorted' content be recursive --- patacrep/content/sorted.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patacrep/content/sorted.py b/patacrep/content/sorted.py index 4fac210d..95a1a07f 100755 --- a/patacrep/content/sorted.py +++ b/patacrep/content/sorted.py @@ -9,8 +9,8 @@ import logging import unidecode from patacrep import files -from patacrep.content import ContentError -from patacrep.content.song import OnlySongsError, process_songs +from patacrep.content import ContentError, process_content +from patacrep.content.song import OnlySongsError LOGGER = logging.getLogger(__name__) @@ -83,7 +83,7 @@ def parse(keyword, config, argument, contentlist): else: sort = DEFAULT_SORT try: - songlist = process_songs(contentlist, config) + songlist = process_content(contentlist, config) except OnlySongsError as error: raise ContentError(keyword, ( "Content list of this keyword can be only songs (or content " From 87d49c6666e38b4790e314777dcb8c2874f8265c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 10:13:27 +0100 Subject: [PATCH 15/41] pylint --- test/test_content/test_content.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index c396ccf5..69d3b7ce 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -53,11 +53,11 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): sbcontent = json.load(sourcefile) expandedlist = content.process_content(sbcontent, cls.config.copy()) - sourcelist = list(map(cls._clean_path, expandedlist)) + sourcelist = [cls._clean_path(elem) for elem in expandedlist] controlname = "{}.control".format(base) if not os.path.exists(controlname): - raise Exception("Missing control:" + str(sourcelist).replace("'",'"')) + raise Exception("Missing control:" + str(sourcelist).replace("'", '"')) with open(controlname, mode="r", encoding="utf8") as controlfile: controllist = json.load(controlfile) From 6eb75caeebf34819bd6e5fc23cfb83d7b83b6a3d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 10:15:34 +0100 Subject: [PATCH 16/41] pylint (bis) --- test/test_content/test_content.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 69d3b7ce..1cdea14c 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -85,21 +85,21 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): config = DEFAULT_CONFIG.copy() - datadirpath = os.path.join(os.path.dirname(__file__), 'datadir') + datadirpaths = [os.path.join(os.path.dirname(__file__), 'datadir')] - config['datadir'] = [datadirpath] + config['datadir'] = datadirpaths config['_songdir'] = [ DataSubpath(path, 'songs') - for path in config['datadir'] + for path in datadirpaths ] config['_content_plugins'] = files.load_plugins( - datadirs=config.get('datadir', []), + datadirs=datadirpaths, root_modules=['content'], keyword='CONTENT_PLUGINS', ) config['_song_plugins'] = files.load_plugins( - datadirs=config.get('datadir', []), + datadirs=datadirpaths, root_modules=['songs'], keyword='SONG_RENDERERS', )['tsg'] From c7a55b5bc6793074717c769979116cb47ac5492c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 10:26:42 +0100 Subject: [PATCH 17/41] Normalize path for windows --- test/test_content/test_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 1cdea14c..191cbee1 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -73,7 +73,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Shorten the path relative to the `songs` directory""" if isinstance(elem, SongRenderer): songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') - return files.relpath(elem.song.fullpath, songpath) + return os.path.normpath(files.relpath(elem.song.fullpath, songpath)) elif isinstance(elem, Section): return "{}:{}".format(elem.keyword, elem.name) else: From e562282cbc060dfadbc7f78f6b1c3db40263f938 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 19 Nov 2015 10:39:50 +0100 Subject: [PATCH 18/41] Path must be posix for comparaison --- test/test_content/test_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 191cbee1..3cec60b9 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -73,7 +73,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Shorten the path relative to the `songs` directory""" if isinstance(elem, SongRenderer): songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') - return os.path.normpath(files.relpath(elem.song.fullpath, songpath)) + return files.path2posix(files.relpath(elem.song.fullpath, songpath)) elif isinstance(elem, Section): return "{}:{}".format(elem.keyword, elem.name) else: From 6135ea8c3e483ff2e87134df48989db53ebd540d Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 13:49:22 +0100 Subject: [PATCH 19/41] Add test and correct cwd --- patacrep/content/cwd.py | 3 +-- test/test_content/cwd.control | 1 + test/test_content/cwd.source | 1 + test/test_content/cwd_list.control | 1 + test/test_content/cwd_list.source | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 test/test_content/cwd.control create mode 100644 test/test_content/cwd.source create mode 100644 test/test_content/cwd_list.control create mode 100644 test/test_content/cwd_list.source diff --git a/patacrep/content/cwd.py b/patacrep/content/cwd.py index b4d9c2de..9ba6fddb 100755 --- a/patacrep/content/cwd.py +++ b/patacrep/content/cwd.py @@ -25,8 +25,7 @@ def parse(keyword, config, argument, contentlist): old_songdir = config['_songdir'] config['_songdir'] = ( [DataSubpath("", argument)] + - [path.clone().join(argument) for path in config['_songdir']] + - config['_songdir'] + [path.clone().join(argument) for path in config['_songdir']] ) processed_content = process_content(contentlist, config) config['_songdir'] = old_songdir diff --git a/test/test_content/cwd.control b/test/test_content/cwd.control new file mode 100644 index 00000000..c0a741d2 --- /dev/null +++ b/test/test_content/cwd.control @@ -0,0 +1 @@ +["subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/cwd.source b/test/test_content/cwd.source new file mode 100644 index 00000000..4dfc53e6 --- /dev/null +++ b/test/test_content/cwd.source @@ -0,0 +1 @@ +[["cwd(subdir)"]] \ No newline at end of file diff --git a/test/test_content/cwd_list.control b/test/test_content/cwd_list.control new file mode 100644 index 00000000..c0a741d2 --- /dev/null +++ b/test/test_content/cwd_list.control @@ -0,0 +1 @@ +["subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/cwd_list.source b/test/test_content/cwd_list.source new file mode 100644 index 00000000..837f22eb --- /dev/null +++ b/test/test_content/cwd_list.source @@ -0,0 +1 @@ +[["cwd(subdir)", "exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"]] \ No newline at end of file From ca9f542e0a08dce6a4c0c5a3b7d3c38a5e0c66bc Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 13:54:13 +0100 Subject: [PATCH 20/41] Add include test --- test/test_content/datadir/custom_list.json | 1 + test/test_content/include.control | 1 + test/test_content/include.source | 1 + 3 files changed, 3 insertions(+) create mode 100644 test/test_content/datadir/custom_list.json create mode 100644 test/test_content/include.control create mode 100644 test/test_content/include.source diff --git a/test/test_content/datadir/custom_list.json b/test/test_content/datadir/custom_list.json new file mode 100644 index 00000000..5ba82a4c --- /dev/null +++ b/test/test_content/datadir/custom_list.json @@ -0,0 +1 @@ +["exsong.sg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/include.control b/test/test_content/include.control new file mode 100644 index 00000000..5ba82a4c --- /dev/null +++ b/test/test_content/include.control @@ -0,0 +1 @@ +["exsong.sg", "chordpro.csg", "subdir/chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/include.source b/test/test_content/include.source new file mode 100644 index 00000000..ccd69aa1 --- /dev/null +++ b/test/test_content/include.source @@ -0,0 +1 @@ +[["include" , "custom_list.json"]] \ No newline at end of file From 3314525d9b077d7c0c12425afe7362280ec5f793 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:16:09 +0100 Subject: [PATCH 21/41] Improve section content test --- patacrep/content/section.py | 4 ++-- test/test_content/sections_short.control | 1 + test/test_content/sections_short.source | 6 ++++++ test/test_content/test_content.py | 5 ++++- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 test/test_content/sections_short.control create mode 100644 test/test_content/sections_short.source diff --git a/patacrep/content/section.py b/patacrep/content/section.py index e2ecfd32..2b56975e 100755 --- a/patacrep/content/section.py +++ b/patacrep/content/section.py @@ -37,8 +37,8 @@ def parse(keyword, argument, contentlist, config): their starred versions "part*", "chapter*", ... , "subparagraph*"): the section to use; - argument: unused; - - contentlist: a list of one or two strings, which are the names (short - and long) of the section; + - contentlist: a list of one or two strings, which are the names (long + and short) of the section; - config: configuration dictionary of the current songbook. """ if (keyword not in KEYWORDS) and (len(contentlist) != 1): diff --git a/test/test_content/sections_short.control b/test/test_content/sections_short.control new file mode 100644 index 00000000..a0dd3600 --- /dev/null +++ b/test/test_content/sections_short.control @@ -0,0 +1 @@ +["section:(tradi)Traditional", "exsong.sg", "section:Example", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/sections_short.source b/test/test_content/sections_short.source new file mode 100644 index 00000000..38693929 --- /dev/null +++ b/test/test_content/sections_short.source @@ -0,0 +1,6 @@ +[["section", "Traditional", "tradi"], + "exsong.sg", + ["section", "Example"], + "texsong.tsg", + "chordpro.csg", + "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 3cec60b9..8b279793 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -75,7 +75,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') return files.path2posix(files.relpath(elem.song.fullpath, songpath)) elif isinstance(elem, Section): - return "{}:{}".format(elem.keyword, elem.name) + if elem.short is None: + return "{}:{}".format(elem.keyword, elem.name) + else: + return "{}:({}){}".format(elem.keyword, elem.short, elem.name) else: raise Exception(elem) From 1c47a23e57187ae46dd2c7970af84ebf6076160e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:19:37 +0100 Subject: [PATCH 22/41] Correct starred sections and add test --- patacrep/content/__init__.py | 2 +- test/test_content/sections_short.control | 2 +- test/test_content/sections_short.source | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index f6e81454..31407113 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -174,7 +174,7 @@ def process_content(content, config=None): """ contentlist = [] plugins = config.get('_content_plugins', {}) - keyword_re = re.compile(r'^ *(?P\w*) *(\((?P.*)\))? *$') + keyword_re = re.compile(r'^ *(?P[\w\*]*) *(\((?P.*)\))? *$') if not content: content = [["song"]] for elem in content: diff --git a/test/test_content/sections_short.control b/test/test_content/sections_short.control index a0dd3600..706e86b8 100644 --- a/test/test_content/sections_short.control +++ b/test/test_content/sections_short.control @@ -1 +1 @@ -["section:(tradi)Traditional", "exsong.sg", "section:Example", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file +["section:(tradi)Traditional", "exsong.sg", "section*:Example", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/sections_short.source b/test/test_content/sections_short.source index 38693929..fe70d510 100644 --- a/test/test_content/sections_short.source +++ b/test/test_content/sections_short.source @@ -1,6 +1,6 @@ [["section", "Traditional", "tradi"], "exsong.sg", - ["section", "Example"], + ["section*", "Example"], "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file From 6c46368d31f2fde1962d3a8a48791ba1cf257c5e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:25:53 +0100 Subject: [PATCH 23/41] Add SongSection tests --- test/test_content/songsection.control | 1 + test/test_content/songsection.source | 6 ++++++ test/test_content/test_content.py | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/test_content/songsection.control create mode 100644 test/test_content/songsection.source diff --git a/test/test_content/songsection.control b/test/test_content/songsection.control new file mode 100644 index 00000000..69dd034b --- /dev/null +++ b/test/test_content/songsection.control @@ -0,0 +1 @@ +["songsection:Traditional", "exsong.sg", "songchapter:English", "texsong.tsg", "chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/songsection.source b/test/test_content/songsection.source new file mode 100644 index 00000000..089322c4 --- /dev/null +++ b/test/test_content/songsection.source @@ -0,0 +1,6 @@ +[["songsection", "Traditional"], + "exsong.sg", + ["songchapter", "English"], + "texsong.tsg", + "chordpro.csg", + "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 8b279793..ec164a52 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -9,8 +9,7 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files -from patacrep.content.song import SongRenderer -from patacrep.content.section import Section +from patacrep.content import song, section, songsection from .. import dynamic # pylint: disable=unused-import @@ -71,14 +70,19 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _clean_path(cls, elem): """Shorten the path relative to the `songs` directory""" - if isinstance(elem, SongRenderer): + if isinstance(elem, song.SongRenderer): songpath = os.path.join(os.path.dirname(__file__), 'datadir', 'songs') return files.path2posix(files.relpath(elem.song.fullpath, songpath)) - elif isinstance(elem, Section): + + elif isinstance(elem, section.Section): if elem.short is None: return "{}:{}".format(elem.keyword, elem.name) else: return "{}:({}){}".format(elem.keyword, elem.short, elem.name) + + elif isinstance(elem, songsection.SongSection): + return "{}:{}".format(elem.keyword, elem.name) + else: raise Exception(elem) From 2b062360760dd9518e7cdb869696b26e5494a272 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:30:13 +0100 Subject: [PATCH 24/41] Add LaTeX content test --- test/test_content/test_content.py | 5 ++++- test/test_content/tex.control | 1 + test/test_content/tex.source | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/test_content/tex.control create mode 100644 test/test_content/tex.source diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index ec164a52..3c8b8b62 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -9,7 +9,7 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files -from patacrep.content import song, section, songsection +from patacrep.content import song, section, songsection, tex from .. import dynamic # pylint: disable=unused-import @@ -83,6 +83,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): elif isinstance(elem, songsection.SongSection): return "{}:{}".format(elem.keyword, elem.name) + elif isinstance(elem, tex.LaTeX): + return elem.filename + else: raise Exception(elem) diff --git a/test/test_content/tex.control b/test/test_content/tex.control new file mode 100644 index 00000000..85eeb47e --- /dev/null +++ b/test/test_content/tex.control @@ -0,0 +1 @@ +["test/test_content/datadir/songs/texfile.tex"] \ No newline at end of file diff --git a/test/test_content/tex.source b/test/test_content/tex.source new file mode 100644 index 00000000..56852196 --- /dev/null +++ b/test/test_content/tex.source @@ -0,0 +1 @@ +[["tex", "texfile.tex", "chordpro.csg"]] \ No newline at end of file From 8d6661f9dcf221d51c48749cc136a2e5caf5d4ab Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 14:39:15 +0100 Subject: [PATCH 25/41] Correct path verification for windows --- test/test_content/test_content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 3c8b8b62..2ba42590 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -84,7 +84,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): return "{}:{}".format(elem.keyword, elem.name) elif isinstance(elem, tex.LaTeX): - return elem.filename + return files.path2posix(elem.filename) else: raise Exception(elem) From 36df563835c6ec2e03cf37caae748168d5c97448 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 20 Nov 2015 15:07:17 +0100 Subject: [PATCH 26/41] Check that cwd is reversed after use --- test/test_content/cwd_list.control | 2 +- test/test_content/cwd_list.source | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_content/cwd_list.control b/test/test_content/cwd_list.control index c0a741d2..465f29df 100644 --- a/test/test_content/cwd_list.control +++ b/test/test_content/cwd_list.control @@ -1 +1 @@ -["subdir/chordpro.csg"] \ No newline at end of file +["subdir/chordpro.csg", "exsong.sg"] \ No newline at end of file diff --git a/test/test_content/cwd_list.source b/test/test_content/cwd_list.source index 837f22eb..c5700449 100644 --- a/test/test_content/cwd_list.source +++ b/test/test_content/cwd_list.source @@ -1 +1 @@ -[["cwd(subdir)", "exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"]] \ No newline at end of file +[["cwd(subdir)", "exsong.sg", "intersong.is", "jsonlist.json", "texfile.tex", "texsong.tsg", "chordpro.csg", "subdir/chordpro.csg"], "exsong.sg"] \ No newline at end of file From bb707a866bb0b0e529fb752944e0f875a8fa5cc7 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 21 Nov 2015 02:11:06 +0100 Subject: [PATCH 27/41] `super()` arguments are useless with Python3 --- patacrep/build.py | 2 +- patacrep/content/__init__.py | 2 +- patacrep/errors.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index 33a91eee..5724d48a 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -40,7 +40,7 @@ class Songbook(object): """ def __init__(self, raw_songbook, basename): - super(Songbook, self).__init__() + super().__init__() self.config = raw_songbook self.basename = basename # Some special keys have their value processed. diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index 040adbad..588aaee1 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -123,7 +123,7 @@ class Content(object): class ContentError(SongbookError): """Error in a content plugin.""" def __init__(self, keyword, message): - super(ContentError, self).__init__() + super().__init__() self.keyword = keyword self.message = message diff --git a/patacrep/errors.py b/patacrep/errors.py index d1d3a74f..9a5785cb 100644 --- a/patacrep/errors.py +++ b/patacrep/errors.py @@ -11,7 +11,7 @@ class SBFileError(SongbookError): """Error during songbook file decoding""" def __init__(self, message=None): - super(SBFileError, self).__init__() + super().__init__() self.message = message def __str__(self): @@ -21,7 +21,7 @@ class TemplateError(SongbookError): """Error during template generation""" def __init__(self, original, message=None): - super(TemplateError, self).__init__() + super().__init__() self.original = original self.message = message @@ -35,7 +35,7 @@ class ExecutableNotFound(SongbookError): """Couldn't find a LaTeX executable.""" def __init__(self, executable): - super(ExecutableNotFound, self).__init__( + super().__init__( ( """Could not find the following executable: {executable}""" ).format(executable=executable) @@ -45,7 +45,7 @@ class StepError(SongbookError): """Error during execution of one compilation step.""" def __init__(self, message): - super(StepError, self).__init__() + super().__init__() self.message = message def __str__(self): @@ -55,7 +55,7 @@ class LatexCompilationError(StepError): """Error during LaTeX compilation.""" def __init__(self, basename): - super(LatexCompilationError, self).__init__( + super().__init__( ( """Error while LaTeX compilation of "{basename}.tex" """ """(see {basename}.log for more information).""" @@ -66,7 +66,7 @@ class StepCommandError(StepError): """Error during custom command compilation.""" def __init__(self, command, code): - super(StepCommandError, self).__init__(( + super().__init__(( """Error while running custom command "{command}": got return""" " code {code}." ).format(command=command, code=code)) @@ -76,7 +76,7 @@ class CleaningError(SongbookError): """Error during cleaning of LaTeX auxiliary files.""" def __init__(self, filename, exception): - super(CleaningError, self).__init__() + super().__init__() self.filename = filename self.exception = exception @@ -90,7 +90,7 @@ class UnknownStep(StepError): """Unknown compilation step.""" def __init__(self, step): - super(UnknownStep, self).__init__( + super().__init__( """Compilation step "{step}" unknown.""".format(step=step) ) From 0ebf52a9c9ac68a4a4d4f4b1ed5a41d2e363eff3 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 21 Nov 2015 02:12:50 +0100 Subject: [PATCH 28/41] More precise exception handling --- patacrep/build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patacrep/build.py b/patacrep/build.py index baa335fb..f61a5dae 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -228,7 +228,7 @@ class SongbookBuilder(object): stderr=PIPE, universal_newlines=True, ) - except Exception as error: + except FileNotFoundError as error: raise errors.ExecutableNotFound(compiler) # Test if lilypond compiler is accessible @@ -242,7 +242,7 @@ class SongbookBuilder(object): stderr=PIPE, universal_newlines=True, ) - except Exception as error: + except FileNotFoundError as error: raise errors.ExecutableNotFound(lilypond_compiler) # Perform compilation From 93c0c8844c09a892f94c359ecb2ecd8c3c8688b5 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:15:50 +0100 Subject: [PATCH 29/41] Prepare for recursivity on filename content --- patacrep/content/song.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index 45bbfeac..b2a47a6b 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -78,7 +78,7 @@ def parse(keyword, argument, contentlist, config): if not os.path.isdir(songdir.datadir): continue with files.chdir(songdir.datadir): - for filename in glob.iglob(os.path.join(songdir.subpath, elem)): + for filename in glob.iglob(os.path.join(songdir.subpath, elem), recursive=True): LOGGER.debug('Parsing file "{}"…'.format(filename)) extension = filename.split(".")[-1] if extension not in plugins: From 03afd62d4abc07f2dd81ee4f61eded3e5f3034af Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:18:33 +0100 Subject: [PATCH 30/41] Support starting with python 3.4 --- patacrep/content/song.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patacrep/content/song.py b/patacrep/content/song.py index b2a47a6b..eaef5663 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -78,7 +78,9 @@ def parse(keyword, argument, contentlist, config): if not os.path.isdir(songdir.datadir): continue with files.chdir(songdir.datadir): - for filename in glob.iglob(os.path.join(songdir.subpath, elem), recursive=True): + # Starting with Python 3.5 glog can be recursive: **/*.csg for instance + # for filename in glob.iglob(os.path.join(songdir.subpath, elem), recursive=True): + for filename in glob.iglob(os.path.join(songdir.subpath, elem)): LOGGER.debug('Parsing file "{}"…'.format(filename)) extension = filename.split(".")[-1] if extension not in plugins: From a1c41f4333698beb01cb19406af96eded0221227 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:20:43 +0100 Subject: [PATCH 31/41] Reduce logging for test_content --- patacrep/utils.py | 11 +++++++++++ test/test_content/test_content.py | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/patacrep/utils.py b/patacrep/utils.py index 998fe738..c096ac01 100644 --- a/patacrep/utils.py +++ b/patacrep/utils.py @@ -1,5 +1,8 @@ """Some utility functions""" +import contextlib +import logging + from collections import UserDict class DictOfDict(UserDict): @@ -75,3 +78,11 @@ def yesno(string): string, ", ".join(["'{}'".format(string) for string in yes_strings + no_strings]), )) + +@contextlib.contextmanager +def logging_reduced(module_name): + logger = logging.getLogger(module_name) + previous_loglevel = logger.getEffectiveLevel() + logger.setLevel(logging.CRITICAL) + yield + logger.setLevel(previous_loglevel) diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 2ba42590..7532450e 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -10,6 +10,7 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files from patacrep.content import song, section, songsection, tex +from patacrep.utils import logging_reduced from .. import dynamic # pylint: disable=unused-import @@ -51,7 +52,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with open(sourcename, mode="r", encoding="utf8") as sourcefile: sbcontent = json.load(sourcefile) - expandedlist = content.process_content(sbcontent, cls.config.copy()) + with logging_reduced('patacrep.content.song'): + expandedlist = content.process_content(sbcontent, cls.config.copy()) sourcelist = [cls._clean_path(elem) for elem in expandedlist] controlname = "{}.control".format(base) From 3790bc979bf52af51e14aab337abde05eec0cef5 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:23:37 +0100 Subject: [PATCH 32/41] Correct typo and improve flexibility --- patacrep/content/song.py | 2 +- patacrep/utils.py | 8 ++++---- test/test_content/glob.control | 1 + test/test_content/glob.source | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 test/test_content/glob.control create mode 100644 test/test_content/glob.source diff --git a/patacrep/content/song.py b/patacrep/content/song.py index eaef5663..c7925354 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -78,7 +78,7 @@ def parse(keyword, argument, contentlist, config): if not os.path.isdir(songdir.datadir): continue with files.chdir(songdir.datadir): - # Starting with Python 3.5 glog can be recursive: **/*.csg for instance + # Starting with Python 3.5 glob can be recursive: **/*.csg for instance # for filename in glob.iglob(os.path.join(songdir.subpath, elem), recursive=True): for filename in glob.iglob(os.path.join(songdir.subpath, elem)): LOGGER.debug('Parsing file "{}"…'.format(filename)) diff --git a/patacrep/utils.py b/patacrep/utils.py index c096ac01..1b95b398 100644 --- a/patacrep/utils.py +++ b/patacrep/utils.py @@ -80,9 +80,9 @@ def yesno(string): )) @contextlib.contextmanager -def logging_reduced(module_name): +def logging_reduced(module_name, tmp_level=logging.CRITICAL): logger = logging.getLogger(module_name) - previous_loglevel = logger.getEffectiveLevel() - logger.setLevel(logging.CRITICAL) + old_level = logger.getEffectiveLevel() + logger.setLevel(tmp_level) yield - logger.setLevel(previous_loglevel) + logger.setLevel(old_level) diff --git a/test/test_content/glob.control b/test/test_content/glob.control new file mode 100644 index 00000000..a30583cc --- /dev/null +++ b/test/test_content/glob.control @@ -0,0 +1 @@ +["chordpro.csg"] \ No newline at end of file diff --git a/test/test_content/glob.source b/test/test_content/glob.source new file mode 100644 index 00000000..167ab6ab --- /dev/null +++ b/test/test_content/glob.source @@ -0,0 +1 @@ +["*.csg"] \ No newline at end of file From 903bad9ff21c494d9047957a1a465ae74c00d653 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:26:27 +0100 Subject: [PATCH 33/41] (pylint) missing docstring --- patacrep/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patacrep/utils.py b/patacrep/utils.py index 1b95b398..e3c18db9 100644 --- a/patacrep/utils.py +++ b/patacrep/utils.py @@ -81,6 +81,8 @@ def yesno(string): @contextlib.contextmanager def logging_reduced(module_name, tmp_level=logging.CRITICAL): + """Temporarly reduce the logging level of a specific module + """ logger = logging.getLogger(module_name) old_level = logger.getEffectiveLevel() logger.setLevel(tmp_level) From 1a54b29233d7ad468cdf7ebf1341b7ff51c676bd Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 22 Nov 2015 14:43:04 +0100 Subject: [PATCH 34/41] Merge disable_logging and logging_reduced --- patacrep/utils.py | 13 ------------- test/__init__.py | 19 ++++++++++++++----- test/test_content/test_content.py | 2 +- test/test_song/test_parser.py | 4 ++-- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/patacrep/utils.py b/patacrep/utils.py index e3c18db9..998fe738 100644 --- a/patacrep/utils.py +++ b/patacrep/utils.py @@ -1,8 +1,5 @@ """Some utility functions""" -import contextlib -import logging - from collections import UserDict class DictOfDict(UserDict): @@ -78,13 +75,3 @@ def yesno(string): string, ", ".join(["'{}'".format(string) for string in yes_strings + no_strings]), )) - -@contextlib.contextmanager -def logging_reduced(module_name, tmp_level=logging.CRITICAL): - """Temporarly reduce the logging level of a specific module - """ - logger = logging.getLogger(module_name) - old_level = logger.getEffectiveLevel() - logger.setLevel(tmp_level) - yield - logger.setLevel(old_level) diff --git a/test/__init__.py b/test/__init__.py index aa4a5a18..41fb4a66 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -9,11 +9,20 @@ import unittest import patacrep @contextlib.contextmanager -def disable_logging(): - """Context locally disabling logging.""" - logging.disable(logging.CRITICAL) - yield - logging.disable(logging.NOTSET) +def logging_reduced(module_name=None, tmp_level=logging.CRITICAL): + """Temporarly reduce the logging level of a specific module + or globally if None + """ + if module_name: + logger = logging.getLogger(module_name) + old_level = logger.getEffectiveLevel() + logger.setLevel(tmp_level) + yield + logger.setLevel(old_level) + else: + logging.disable(logging.CRITICAL) + yield + logging.disable(logging.NOTSET) def suite(): """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`. diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 7532450e..5857506c 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -10,8 +10,8 @@ import json from patacrep.songs import DataSubpath, DEFAULT_CONFIG from patacrep import content, files from patacrep.content import song, section, songsection, tex -from patacrep.utils import logging_reduced +from .. import logging_reduced from .. import dynamic # pylint: disable=unused-import class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): diff --git a/test/test_song/test_parser.py b/test/test_song/test_parser.py index ae122bdd..0ea602a2 100644 --- a/test/test_song/test_parser.py +++ b/test/test_song/test_parser.py @@ -12,7 +12,7 @@ from patacrep import files from patacrep.songs import DEFAULT_CONFIG from patacrep.encoding import open_read -from .. import disable_logging +from .. import logging_reduced from .. import dynamic # pylint: disable=unused-import OUTPUTS = { @@ -59,7 +59,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): destname = "{}.{}".format(base, out_format) with self.chdir(): with open_read(destname) as expectfile: - with disable_logging(): + with logging_reduced(): song = self.song_plugins[out_format][in_format](sourcename, self.config) expected = expectfile.read().strip().replace( "@TEST_FOLDER@", From d654dbf2b2c67ca76227bcb9032fe8723f353f07 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 23 Nov 2015 22:34:59 +0100 Subject: [PATCH 35/41] [test] Simplify `logging_reduced` function --- test/__init__.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/test/__init__.py b/test/__init__.py index 41fb4a66..d77a9c27 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -9,20 +9,15 @@ import unittest import patacrep @contextlib.contextmanager -def logging_reduced(module_name=None, tmp_level=logging.CRITICAL): - """Temporarly reduce the logging level of a specific module - or globally if None +def logging_reduced(module_name=None, level=logging.CRITICAL): + """Temporarly reduce the logging level of a specific module or globally if None """ - if module_name: - logger = logging.getLogger(module_name) - old_level = logger.getEffectiveLevel() - logger.setLevel(tmp_level) - yield - logger.setLevel(old_level) - else: - logging.disable(logging.CRITICAL) - yield - logging.disable(logging.NOTSET) + logger = logging.getLogger(module_name) + old_level = logger.getEffectiveLevel() + + logger.setLevel(level) + yield + logger.setLevel(old_level) def suite(): """Return a :class:`TestSuite` object, testing all module :mod:`patacrep`. From 77c491dcc4327576fa56bde0d571a9ffd4297de4 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:25:12 +0100 Subject: [PATCH 36/41] Add pyyaml dependency --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 63fbbcc8..fd1b48a5 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ setup( packages=find_packages(exclude=["test*"]), license="GPLv2 or any later version", install_requires=[ - "unidecode", "jinja2", "ply", + "unidecode", "jinja2", "ply", "pyyaml", ], entry_points={ 'console_scripts': [ From 7556c99703e1c34fa13781aba549b30bb74e65f1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:33:25 +0100 Subject: [PATCH 37/41] Replace json parser by yaml --- examples/example-all.yaml.sb | 17 +++++++++++++++++ patacrep/songbook/__main__.py | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 examples/example-all.yaml.sb diff --git a/examples/example-all.yaml.sb b/examples/example-all.yaml.sb new file mode 100644 index 00000000..3a167565 --- /dev/null +++ b/examples/example-all.yaml.sb @@ -0,0 +1,17 @@ +bookoptions: + - "diagram" + - "repeatchords" + - "lilypond" + - "pictures" +booktype: "chorded" +datadir: "." +template: "patacrep.tex" +lang: "fr" +encoding: "utf8" +authwords: + sep: + - "and" + - "et" +content: + - + - "sorted" \ No newline at end of file diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index cc56311b..b972b04c 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -1,7 +1,7 @@ """Command line tool to compile songbooks using the songbook library.""" import argparse -import json +import yaml import locale import logging import os.path @@ -135,13 +135,13 @@ def main(): try: with patacrep.encoding.open_read(songbook_path) as songbook_file: - songbook = json.load(songbook_file) + songbook = yaml.load(songbook_file) if 'encoding' in songbook: with patacrep.encoding.open_read( songbook_path, encoding=songbook['encoding'] ) as songbook_file: - songbook = json.load(songbook_file) + songbook = yaml.load(songbook_file) except Exception as error: # pylint: disable=broad-except LOGGER.error(error) LOGGER.error("Error while loading file '{}'.".format(songbook_path)) From 2d6298c301327b257efceb3b0401cb48d9fd8ffe Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:43:54 +0100 Subject: [PATCH 38/41] [pylint] Correct import order --- patacrep/content/__init__.py | 3 ++- patacrep/content/song.py | 3 ++- patacrep/songbook/__main__.py | 2 +- patacrep/songs/chordpro/__init__.py | 5 +++-- patacrep/songs/chordpro/syntax.py | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/patacrep/content/__init__.py b/patacrep/content/__init__.py index db7d0514..a0c84361 100755 --- a/patacrep/content/__init__.py +++ b/patacrep/content/__init__.py @@ -66,12 +66,13 @@ More documentation in the docstring of Content. """ import glob -import jinja2 import logging import os import re import sys +import jinja2 + from patacrep import files from patacrep.errors import SongbookError diff --git a/patacrep/content/song.py b/patacrep/content/song.py index c7925354..ad193c02 100755 --- a/patacrep/content/song.py +++ b/patacrep/content/song.py @@ -1,11 +1,12 @@ """Plugin to include songs to the songbook.""" import glob -import jinja2 import logging import os import textwrap +import jinja2 + from patacrep.content import process_content, ContentError, Content from patacrep import files, errors diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index b972b04c..b62dcf73 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -1,12 +1,12 @@ """Command line tool to compile songbooks using the songbook library.""" import argparse -import yaml import locale import logging import os.path import textwrap import sys +import yaml from patacrep.build import SongbookBuilder, DEFAULT_STEPS from patacrep.utils import yesno diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 5777b170..a01c31f4 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -1,11 +1,12 @@ """Chordpro parser""" -from jinja2 import Environment, FileSystemLoader, contextfunction, ChoiceLoader -import jinja2 import logging import operator import os +from jinja2 import Environment, FileSystemLoader, contextfunction, ChoiceLoader +import jinja2 + from patacrep import encoding, files, pkg_datapath from patacrep.songs import Song from patacrep.songs.chordpro.syntax import parse_song diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index 999d31a5..66b9b571 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -1,9 +1,10 @@ """ChordPro parser""" import logging -import ply.yacc as yacc import re +import ply.yacc as yacc + from patacrep.songs.syntax import Parser from patacrep.songs.chordpro import ast from patacrep.songs.chordpro.lexer import tokens, ChordProLexer From 0176cf8720aad94d79dc2e35c4a6308d9059515e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:50:19 +0100 Subject: [PATCH 39/41] Fix other import orders --- patacrep/__init__.py | 5 +++-- patacrep/index.py | 2 +- patacrep/templates.py | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/patacrep/__init__.py b/patacrep/__init__.py index 60e4cd6a..0158a1f6 100644 --- a/patacrep/__init__.py +++ b/patacrep/__init__.py @@ -1,10 +1,11 @@ """Global variables.""" -from pkg_resources import resource_filename import os +import sys + +from pkg_resources import resource_filename # Check Python version -import sys if sys.version_info < (3, 3): print("ERROR: Your Python version is too old. Please use a Python version > 3.3.") sys.exit(1) diff --git a/patacrep/index.py b/patacrep/index.py index b67897f3..920e1138 100644 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -6,8 +6,8 @@ from a file generated by the latex compilation of the songbook (.sxd). """ import locale -import unidecode import re +import unidecode from patacrep import authors from patacrep import encoding diff --git a/patacrep/templates.py b/patacrep/templates.py index b329cc71..8e4e32fd 100644 --- a/patacrep/templates.py +++ b/patacrep/templates.py @@ -1,11 +1,12 @@ """Template for .tex generation settings and utilities""" +import re +import json + from jinja2 import Environment, FileSystemLoader, ChoiceLoader, \ TemplateNotFound, nodes from jinja2.ext import Extension from jinja2.meta import find_referenced_templates as find_templates -import re -import json from patacrep import errors, files from patacrep.latex import lang2babel From 2e70273d93baae6b4563306dfb458db8acaf1dc1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:53:22 +0100 Subject: [PATCH 40/41] [pylint] Rewrite 'not xxx in' into 'xxx not in' --- patacrep/index.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patacrep/index.py b/patacrep/index.py index 920e1138..716a344a 100644 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -77,7 +77,7 @@ class Index(object): def add_keyword(self, key, word): """Add 'word' to self.keywords[key].""" - if not key in self.keywords: + if key not in self.keywords: self.keywords[key] = [] self.keywords[key].append(word) @@ -101,9 +101,9 @@ class Index(object): similar method with processing. """ first = self.get_first_letter(key[0]) - if not first in self.data: + if first not in self.data: self.data[first] = dict() - if not key in self.data[first]: + if key not in self.data[first]: self.data[first][key] = { 'sortingkey': [ unidecode.unidecode(tex2plain(item)).lower() From 720d7a7f084fac3b0830edc969a4c45be081b95e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 14 Dec 2015 17:56:49 +0100 Subject: [PATCH 41/41] Convert test songbooks to YAML Using http://www.json2yaml.com/ --- test/test_songbook/datadir.sb | 13 ++++++------- test/test_songbook/languages.sb | 5 ++--- test/test_songbook/syntax.sb | 7 +++---- test/test_songbook/unicode.sb | 7 +++---- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/test/test_songbook/datadir.sb b/test/test_songbook/datadir.sb index 357c28d7..f44c3dba 100644 --- a/test/test_songbook/datadir.sb +++ b/test/test_songbook/datadir.sb @@ -1,7 +1,6 @@ -{ -"bookoptions" : [ - "pictures" - ], -"datadir": ["datadir_datadir", "datadir_datadir2"], -"lang": "en" -} +bookoptions: +- pictures +datadir: +- datadir_datadir +- datadir_datadir2 +lang: en diff --git a/test/test_songbook/languages.sb b/test/test_songbook/languages.sb index e0c55f92..ff589a74 100644 --- a/test/test_songbook/languages.sb +++ b/test/test_songbook/languages.sb @@ -1,3 +1,2 @@ -{ -"datadir": ["languages_datadir"] -} +datadir: +- languages_datadir diff --git a/test/test_songbook/syntax.sb b/test/test_songbook/syntax.sb index fb16ce10..4b1f4ef2 100644 --- a/test/test_songbook/syntax.sb +++ b/test/test_songbook/syntax.sb @@ -1,4 +1,3 @@ -{ -"datadir": ["syntax_datadir"], -"lang": "en" -} +datadir: +- syntax_datadir +lang: en diff --git a/test/test_songbook/unicode.sb b/test/test_songbook/unicode.sb index fffed7cc..19392a88 100644 --- a/test/test_songbook/unicode.sb +++ b/test/test_songbook/unicode.sb @@ -1,4 +1,3 @@ -{ -"datadir": ["unicode_datadir"], -"lang": "en" -} +datadir: +- unicode_datadir +lang: en