From b612ec9f67534818c655756fabece9fdfcb44baa Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 20:52:43 +0100 Subject: [PATCH 01/20] Parsing hangs when file is inconsistent --- test/test_chordpro/invalid_content.sgc | 1 + test/test_chordpro/invalid_content.source | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 test/test_chordpro/invalid_content.sgc create mode 100644 test/test_chordpro/invalid_content.source diff --git a/test/test_chordpro/invalid_content.sgc b/test/test_chordpro/invalid_content.sgc new file mode 100644 index 00000000..768ee9ee --- /dev/null +++ b/test/test_chordpro/invalid_content.sgc @@ -0,0 +1 @@ +{lang: en} diff --git a/test/test_chordpro/invalid_content.source b/test/test_chordpro/invalid_content.source new file mode 100644 index 00000000..4dba23a7 --- /dev/null +++ b/test/test_chordpro/invalid_content.source @@ -0,0 +1,3 @@ +{soc} +Chorus +{eoc From 9dca42bc16293d2390add54b71be0d68330371a8 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Mon, 9 Nov 2015 21:23:30 +0100 Subject: [PATCH 02/20] Problem localization? --- patacrep/songs/chordpro/syntax.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index e88d7360..d765b79a 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -303,6 +303,10 @@ class ChordproParser(Parser): def p_error(self, token): super().p_error(token) + if not token: + # End of file + # Maybe it should raise an error ? + return token while True: token = self.parser.token() if not token or token.type == "ENDOFLINE": From db1a19a8733b8c7b9b32164ff16d85e958761f1b Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 10 Nov 2015 19:02:52 +0100 Subject: [PATCH 03/20] Only skip the erro if the end of the file wasn't reached --- patacrep/songs/chordpro/syntax.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index d765b79a..37af7192 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -303,15 +303,12 @@ class ChordproParser(Parser): def p_error(self, token): super().p_error(token) - if not token: - # End of file - # Maybe it should raise an error ? - return token while True: token = self.parser.token() if not token or token.type == "ENDOFLINE": break - self.parser.errok() + if token: + self.parser.errok() return token def parse_song(content, filename=None): From 4cbbe29d28ac15d5d0220e5b61740ac4ac014f18 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Tue, 10 Nov 2015 19:06:24 +0100 Subject: [PATCH 04/20] Localize were the error parsing should be made --- patacrep/songs/chordpro/syntax.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index 37af7192..6c8d2540 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -313,7 +313,13 @@ class ChordproParser(Parser): def parse_song(content, filename=None): """Parse song and return its metadata.""" - return ChordproParser(filename).parse( + parser = ChordproParser(filename) + parsed_content = parser.parse( content, lexer=ChordProLexer(filename=filename).lexer, ) + if parsed_content is None: + # There was a fatal error parsing the content + # TODO: implement error handling by looking into parser + raise Exception('The song could not be parsed') + return parsed_content From f70df32d6dd68dca4882c1718ed3b4447b5a7089 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 12 Nov 2015 11:16:41 +0100 Subject: [PATCH 05/20] Use files.chdir --- test/test_chordpro/test_parser.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 6834af4b..692eaa28 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -47,10 +47,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def chdir(): """Context to temporarry change current directory to this file directory """ - olddir = os.getcwd() - os.chdir(resource_filename(__name__, "")) - yield - os.chdir(olddir) + with files.chdir(resource_filename(__name__, "")): + yield def assertRender(self, base, destformat): # pylint: disable=invalid-name """Assert that `{base}.source` is correctly rendered in the `destformat`. From 90c77201a9a20c0aadc54aff43c3d3c1fa58021e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 12 Nov 2015 11:23:10 +0100 Subject: [PATCH 06/20] Useless existence test --- test/test_chordpro/test_parser.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 692eaa28..4315e241 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -98,8 +98,6 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def test_parse_render(self): """Test that `base` is correctly parsed and rendered.""" - if base is None or dest is None: - return self.assertRender(base, dest) test_parse_render.__doc__ = ( From 5eae2230b2a0aec212f546a9c4dc4351401755fc Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 12 Nov 2015 11:30:44 +0100 Subject: [PATCH 07/20] Implement test for parsing failures --- patacrep/songs/chordpro/syntax.py | 3 +-- .../{ => errors}/invalid_content.source | 0 test/test_chordpro/invalid_content.sgc | 1 - test/test_chordpro/test_parser.py | 26 +++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) rename test/test_chordpro/{ => errors}/invalid_content.source (100%) delete mode 100644 test/test_chordpro/invalid_content.sgc diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index 6c8d2540..6379ca62 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -320,6 +320,5 @@ def parse_song(content, filename=None): ) if parsed_content is None: # There was a fatal error parsing the content - # TODO: implement error handling by looking into parser - raise Exception('The song could not be parsed') + raise SyntaxError('Fatal error during song parsing: {}'.format(filename)) return parsed_content diff --git a/test/test_chordpro/invalid_content.source b/test/test_chordpro/errors/invalid_content.source similarity index 100% rename from test/test_chordpro/invalid_content.source rename to test/test_chordpro/errors/invalid_content.source diff --git a/test/test_chordpro/invalid_content.sgc b/test/test_chordpro/invalid_content.sgc deleted file mode 100644 index 768ee9ee..00000000 --- a/test/test_chordpro/invalid_content.sgc +++ /dev/null @@ -1 +0,0 @@ -{lang: en} diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 4315e241..d14bcb4d 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -91,6 +91,14 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): cls._create_test(base, dest), ) + with files.chdir('errors'): + for source in sorted(glob.glob('*.source')): + base = source[:-len(".source")] + yield ( + "test_{}_failure".format(base), + cls._create_failure(base), + ) + @classmethod def _create_test(cls, base, dest): """Return a function testing that `base` compilation in `dest` format. @@ -105,6 +113,24 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): ).format(base=os.path.basename(base), format=dest) return test_parse_render + @classmethod + def _create_failure(cls, base): + """Return a function testing that `base` fails. + """ + + def test_parse_render(self): + """Test that `base` parsing fails.""" + sourcename = "{}.source".format(base) + with self.chdir(): + with files.chdir('errors'): + parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] + self.assertRaises(SyntaxError, parser, sourcename, self.config) + + test_parse_render.__doc__ = ( + "Test that '{base}' parsing fails." + ).format(base=os.path.basename(base)) + return test_parse_render + @classmethod def _overwrite_clrf(cls): """Overwrite `*.crlf.source` files to force the CRLF line endings. From 46ab0b047f372219af74acc9e91e7604eff7c393 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 12 Nov 2015 11:39:50 +0100 Subject: [PATCH 08/20] Code cleaning --- patacrep/songs/chordpro/syntax.py | 1 - test/test_chordpro/test_parser.py | 8 ++------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/patacrep/songs/chordpro/syntax.py b/patacrep/songs/chordpro/syntax.py index 6379ca62..a1c69983 100644 --- a/patacrep/songs/chordpro/syntax.py +++ b/patacrep/songs/chordpro/syntax.py @@ -319,6 +319,5 @@ def parse_song(content, filename=None): lexer=ChordProLexer(filename=filename).lexer, ) if parsed_content is None: - # There was a fatal error parsing the content raise SyntaxError('Fatal error during song parsing: {}'.format(filename)) return parsed_content diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index d14bcb4d..f369748c 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -103,11 +103,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def _create_test(cls, base, dest): """Return a function testing that `base` compilation in `dest` format. """ - - def test_parse_render(self): - """Test that `base` is correctly parsed and rendered.""" - self.assertRender(base, dest) - + test_parse_render = lambda self: self.assertRender(base, dest) test_parse_render.__doc__ = ( "Test that '{base}' is correctly parsed and rendererd into '{format}' format." ).format(base=os.path.basename(base), format=dest) @@ -115,7 +111,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @classmethod def _create_failure(cls, base): - """Return a function testing that `base` fails. + """Return a function testing that `base` parsing fails. """ def test_parse_render(self): From 1f09d6af780f9db39beb5dddb40aaf70679c1f6e Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Thu, 12 Nov 2015 11:51:33 +0100 Subject: [PATCH 09/20] Rename parse_failure test function --- test/test_chordpro/test_parser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index f369748c..6de149ac 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -114,7 +114,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Return a function testing that `base` parsing fails. """ - def test_parse_render(self): + def test_parse_failure(self): """Test that `base` parsing fails.""" sourcename = "{}.source".format(base) with self.chdir(): @@ -122,10 +122,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] self.assertRaises(SyntaxError, parser, sourcename, self.config) - test_parse_render.__doc__ = ( + test_parse_failure.__doc__ = ( "Test that '{base}' parsing fails." ).format(base=os.path.basename(base)) - return test_parse_render + return test_parse_failure @classmethod def _overwrite_clrf(cls): From b1eb5a0f879f73c6294672961645eed71fd41b06 Mon Sep 17 00:00:00 2001 From: Louis Date: Thu, 12 Nov 2015 21:02:03 +0100 Subject: [PATCH 10/20] Use variable number of arguments for `chdir` --- patacrep/files.py | 6 +++--- test/test_chordpro/test_parser.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/patacrep/files.py b/patacrep/files.py index a204f8e7..08d7b473 100644 --- a/patacrep/files.py +++ b/patacrep/files.py @@ -61,17 +61,17 @@ def path2posix(string): ) @contextmanager -def chdir(path): +def chdir(*path): """Locally change dir Can be used as: - with chdir("some/directory"): + with chdir("some", "directory"): do_stuff() """ olddir = os.getcwd() if path: - os.chdir(path) + os.chdir(os.path.join(*path)) yield os.chdir(olddir) else: diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 6de149ac..fe6dc7c5 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -44,10 +44,10 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): @staticmethod @contextlib.contextmanager - def chdir(): - """Context to temporarry change current directory to this file directory + def chdir(*path): + """Context to temporarry change current directory, relative to this file directory """ - with files.chdir(resource_filename(__name__, "")): + with files.chdir(resource_filename(__name__, ""), *path): yield def assertRender(self, base, destformat): # pylint: disable=invalid-name @@ -91,7 +91,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): cls._create_test(base, dest), ) - with files.chdir('errors'): + with cls.chdir('errors'): for source in sorted(glob.glob('*.source')): base = source[:-len(".source")] yield ( @@ -117,10 +117,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): def test_parse_failure(self): """Test that `base` parsing fails.""" sourcename = "{}.source".format(base) - with self.chdir(): - with files.chdir('errors'): - parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] - self.assertRaises(SyntaxError, parser, sourcename, self.config) + with self.chdir('errors'): + parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] + self.assertRaises(SyntaxError, parser, sourcename, self.config) test_parse_failure.__doc__ = ( "Test that '{base}' parsing fails." From 11f49258d3a39c91d62879c00597ff552b9bb9e2 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 10:46:31 +0100 Subject: [PATCH 11/20] Change test_parser extensions --- patacrep/songs/chordpro/__init__.py | 10 +-- test/test_chordpro/{00.sgc => 00.csg} | 0 .../{00.source => 00.csg.source} | 0 test/test_chordpro/{00.tex => 00.tsg} | 0 test/test_chordpro/{01.sgc => 01.csg} | 0 .../{01.source => 01.csg.source} | 0 test/test_chordpro/{01.tex => 01.tsg} | 0 test/test_chordpro/{02.sgc => 02.csg} | 0 .../{02.source => 02.csg.source} | 0 test/test_chordpro/{02.tex => 02.tsg} | 0 test/test_chordpro/{03.sgc => 03.csg} | 0 .../{03.source => 03.csg.source} | 0 test/test_chordpro/{03.tex => 03.tsg} | 0 test/test_chordpro/{04.sgc => 04.csg} | 0 .../{04.source => 04.csg.source} | 0 test/test_chordpro/{04.tex => 04.tsg} | 0 test/test_chordpro/{05.sgc => 05.csg} | 0 .../{05.source => 05.csg.source} | 0 test/test_chordpro/{05.tex => 05.tsg} | 0 test/test_chordpro/{06.sgc => 06.csg} | 0 .../{06.source => 06.csg.source} | 0 test/test_chordpro/{06.tex => 06.tsg} | 0 test/test_chordpro/{07.sgc => 07.csg} | 0 .../{07.source => 07.csg.source} | 0 test/test_chordpro/{07.tex => 07.tsg} | 0 test/test_chordpro/{08.sgc => 08.csg} | 0 .../{08.source => 08.csg.source} | 0 test/test_chordpro/{08.tex => 08.tsg} | 0 test/test_chordpro/{09.sgc => 09.csg} | 0 .../{09.source => 09.csg.source} | 0 test/test_chordpro/{09.tex => 09.tsg} | 0 test/test_chordpro/{10.sgc => 10.csg} | 0 .../{10.source => 10.csg.source} | 0 test/test_chordpro/{10.tex => 10.tsg} | 0 test/test_chordpro/{11.sgc => 11.csg} | 0 .../{11.source => 11.csg.source} | 0 test/test_chordpro/{11.tex => 11.tsg} | 0 test/test_chordpro/{12.sgc => 12.csg} | 0 .../{12.source => 12.csg.source} | 0 test/test_chordpro/{12.tex => 12.tsg} | 0 test/test_chordpro/{13.sgc => 13.csg} | 0 .../{13.source => 13.csg.source} | 0 test/test_chordpro/{13.tex => 13.tsg} | 0 test/test_chordpro/{21.sgc => 21.csg} | 0 .../{21.source => 21.csg.source} | 0 test/test_chordpro/{21.tex => 21.tsg} | 0 test/test_chordpro/{22.sgc => 22.csg} | 0 .../{22.source => 22.csg.source} | 0 test/test_chordpro/{22.tex => 22.tsg} | 0 test/test_chordpro/{23.sgc => 23.csg} | 0 .../{23.source => 23.csg.source} | 0 test/test_chordpro/{23.tex => 23.tsg} | 0 test/test_chordpro/{24.sgc => 24.csg} | 0 .../{24.source => 24.csg.source} | 0 test/test_chordpro/{24.tex => 24.tsg} | 0 test/test_chordpro/{25.sgc => 25.csg} | 0 .../{25.source => 25.csg.source} | 0 test/test_chordpro/{25.tex => 25.tsg} | 0 test/test_chordpro/{26.sgc => 26.csg} | 0 .../{26.source => 26.csg.source} | 0 test/test_chordpro/{26.tex => 26.tsg} | 0 test/test_chordpro/{27.sgc => 27.csg} | 0 .../{27.source => 27.csg.source} | 0 test/test_chordpro/{27.tex => 27.tsg} | 0 test/test_chordpro/{28.sgc => 28.csg} | 0 .../{28.source => 28.csg.source} | 0 test/test_chordpro/{28.tex => 28.tsg} | 0 test/test_chordpro/{29.sgc => 29.csg} | 0 .../{29.source => 29.csg.source} | 0 test/test_chordpro/{29.tex => 29.tsg} | 0 .../{author_names.sgc => author_names.csg} | 0 ...r_names.source => author_names.csg.source} | 0 .../{author_names.tex => author_names.tsg} | 0 test/test_chordpro/{chords.sgc => chords.csg} | 0 .../{chords.source => chords.csg.source} | 0 test/test_chordpro/{chords.tex => chords.tsg} | 0 .../{customchords.sgc => customchords.csg} | 0 ...mchords.source => customchords.csg.source} | 0 .../{customchords.tex => customchords.tsg} | 0 ...tent.source => invalid_content.csg.source} | 0 .../{greensleeves.sgc => greensleeves.csg} | 0 ...sleeves.source => greensleeves.csg.source} | 0 .../{greensleeves.tex => greensleeves.tsg} | 0 .../{invalid_chord.sgc => invalid_chord.csg} | 0 ..._chord.source => invalid_chord.csg.source} | 0 .../{invalid_chord.tex => invalid_chord.tsg} | 0 ...ustomchord.sgc => invalid_customchord.csg} | 0 ....source => invalid_customchord.csg.source} | 0 ...ustomchord.tex => invalid_customchord.tsg} | 0 ...id_directive.sgc => invalid_directive.csg} | 0 ...ve.source => invalid_directive.csg.source} | 0 ...id_directive.tex => invalid_directive.tsg} | 0 test/test_chordpro/{lang.sgc => lang.csg} | 0 .../{lang.source => lang.csg.source} | 0 .../{metadata.sgc => metadata.csg} | 0 .../{metadata.source => metadata.csg.source} | 0 .../{metadata.tex => metadata.tsg} | 0 .../{newline.crlf.sgc => newline.crlf.csg} | 0 test/test_chordpro/newline.crlf.csg.source | 2 + test/test_chordpro/newline.crlf.source | 2 - .../{newline.crlf.tex => newline.crlf.tsg} | 0 .../{newline.sgc => newline.csg} | 0 .../{newline.source => newline.csg.source} | 0 .../{newline.tex => newline.tsg} | 0 .../{nolyrics.sgc => nolyrics.csg} | 0 .../{nolyrics.source => nolyrics.csg.source} | 0 .../{nolyrics.tex => nolyrics.tsg} | 0 test/test_chordpro/{tags.sgc => tags.csg} | 0 .../{tags.source => tags.csg.source} | 0 test/test_chordpro/{tags.tex => tags.tsg} | 0 test/test_chordpro/test_parser.py | 69 +++++++++---------- .../{ukulelechords.sgc => ukulelechords.csg} | 0 ...chords.source => ukulelechords.csg.source} | 0 .../{ukulelechords.tex => ukulelechords.tsg} | 0 114 files changed, 41 insertions(+), 42 deletions(-) rename test/test_chordpro/{00.sgc => 00.csg} (100%) rename test/test_chordpro/{00.source => 00.csg.source} (100%) rename test/test_chordpro/{00.tex => 00.tsg} (100%) rename test/test_chordpro/{01.sgc => 01.csg} (100%) rename test/test_chordpro/{01.source => 01.csg.source} (100%) rename test/test_chordpro/{01.tex => 01.tsg} (100%) rename test/test_chordpro/{02.sgc => 02.csg} (100%) rename test/test_chordpro/{02.source => 02.csg.source} (100%) rename test/test_chordpro/{02.tex => 02.tsg} (100%) rename test/test_chordpro/{03.sgc => 03.csg} (100%) rename test/test_chordpro/{03.source => 03.csg.source} (100%) rename test/test_chordpro/{03.tex => 03.tsg} (100%) rename test/test_chordpro/{04.sgc => 04.csg} (100%) rename test/test_chordpro/{04.source => 04.csg.source} (100%) rename test/test_chordpro/{04.tex => 04.tsg} (100%) rename test/test_chordpro/{05.sgc => 05.csg} (100%) rename test/test_chordpro/{05.source => 05.csg.source} (100%) rename test/test_chordpro/{05.tex => 05.tsg} (100%) rename test/test_chordpro/{06.sgc => 06.csg} (100%) rename test/test_chordpro/{06.source => 06.csg.source} (100%) rename test/test_chordpro/{06.tex => 06.tsg} (100%) rename test/test_chordpro/{07.sgc => 07.csg} (100%) rename test/test_chordpro/{07.source => 07.csg.source} (100%) rename test/test_chordpro/{07.tex => 07.tsg} (100%) rename test/test_chordpro/{08.sgc => 08.csg} (100%) rename test/test_chordpro/{08.source => 08.csg.source} (100%) rename test/test_chordpro/{08.tex => 08.tsg} (100%) rename test/test_chordpro/{09.sgc => 09.csg} (100%) rename test/test_chordpro/{09.source => 09.csg.source} (100%) rename test/test_chordpro/{09.tex => 09.tsg} (100%) rename test/test_chordpro/{10.sgc => 10.csg} (100%) rename test/test_chordpro/{10.source => 10.csg.source} (100%) rename test/test_chordpro/{10.tex => 10.tsg} (100%) rename test/test_chordpro/{11.sgc => 11.csg} (100%) rename test/test_chordpro/{11.source => 11.csg.source} (100%) rename test/test_chordpro/{11.tex => 11.tsg} (100%) rename test/test_chordpro/{12.sgc => 12.csg} (100%) rename test/test_chordpro/{12.source => 12.csg.source} (100%) rename test/test_chordpro/{12.tex => 12.tsg} (100%) rename test/test_chordpro/{13.sgc => 13.csg} (100%) rename test/test_chordpro/{13.source => 13.csg.source} (100%) rename test/test_chordpro/{13.tex => 13.tsg} (100%) rename test/test_chordpro/{21.sgc => 21.csg} (100%) rename test/test_chordpro/{21.source => 21.csg.source} (100%) rename test/test_chordpro/{21.tex => 21.tsg} (100%) rename test/test_chordpro/{22.sgc => 22.csg} (100%) rename test/test_chordpro/{22.source => 22.csg.source} (100%) rename test/test_chordpro/{22.tex => 22.tsg} (100%) rename test/test_chordpro/{23.sgc => 23.csg} (100%) rename test/test_chordpro/{23.source => 23.csg.source} (100%) rename test/test_chordpro/{23.tex => 23.tsg} (100%) rename test/test_chordpro/{24.sgc => 24.csg} (100%) rename test/test_chordpro/{24.source => 24.csg.source} (100%) rename test/test_chordpro/{24.tex => 24.tsg} (100%) rename test/test_chordpro/{25.sgc => 25.csg} (100%) rename test/test_chordpro/{25.source => 25.csg.source} (100%) rename test/test_chordpro/{25.tex => 25.tsg} (100%) rename test/test_chordpro/{26.sgc => 26.csg} (100%) rename test/test_chordpro/{26.source => 26.csg.source} (100%) rename test/test_chordpro/{26.tex => 26.tsg} (100%) rename test/test_chordpro/{27.sgc => 27.csg} (100%) rename test/test_chordpro/{27.source => 27.csg.source} (100%) rename test/test_chordpro/{27.tex => 27.tsg} (100%) rename test/test_chordpro/{28.sgc => 28.csg} (100%) rename test/test_chordpro/{28.source => 28.csg.source} (100%) rename test/test_chordpro/{28.tex => 28.tsg} (100%) rename test/test_chordpro/{29.sgc => 29.csg} (100%) rename test/test_chordpro/{29.source => 29.csg.source} (100%) rename test/test_chordpro/{29.tex => 29.tsg} (100%) rename test/test_chordpro/{author_names.sgc => author_names.csg} (100%) rename test/test_chordpro/{author_names.source => author_names.csg.source} (100%) rename test/test_chordpro/{author_names.tex => author_names.tsg} (100%) rename test/test_chordpro/{chords.sgc => chords.csg} (100%) rename test/test_chordpro/{chords.source => chords.csg.source} (100%) rename test/test_chordpro/{chords.tex => chords.tsg} (100%) rename test/test_chordpro/{customchords.sgc => customchords.csg} (100%) rename test/test_chordpro/{customchords.source => customchords.csg.source} (100%) rename test/test_chordpro/{customchords.tex => customchords.tsg} (100%) rename test/test_chordpro/errors/{invalid_content.source => invalid_content.csg.source} (100%) rename test/test_chordpro/{greensleeves.sgc => greensleeves.csg} (100%) rename test/test_chordpro/{greensleeves.source => greensleeves.csg.source} (100%) rename test/test_chordpro/{greensleeves.tex => greensleeves.tsg} (100%) rename test/test_chordpro/{invalid_chord.sgc => invalid_chord.csg} (100%) rename test/test_chordpro/{invalid_chord.source => invalid_chord.csg.source} (100%) rename test/test_chordpro/{invalid_chord.tex => invalid_chord.tsg} (100%) rename test/test_chordpro/{invalid_customchord.sgc => invalid_customchord.csg} (100%) rename test/test_chordpro/{invalid_customchord.source => invalid_customchord.csg.source} (100%) rename test/test_chordpro/{invalid_customchord.tex => invalid_customchord.tsg} (100%) rename test/test_chordpro/{invalid_directive.sgc => invalid_directive.csg} (100%) rename test/test_chordpro/{invalid_directive.source => invalid_directive.csg.source} (100%) rename test/test_chordpro/{invalid_directive.tex => invalid_directive.tsg} (100%) rename test/test_chordpro/{lang.sgc => lang.csg} (100%) rename test/test_chordpro/{lang.source => lang.csg.source} (100%) rename test/test_chordpro/{metadata.sgc => metadata.csg} (100%) rename test/test_chordpro/{metadata.source => metadata.csg.source} (100%) rename test/test_chordpro/{metadata.tex => metadata.tsg} (100%) rename test/test_chordpro/{newline.crlf.sgc => newline.crlf.csg} (100%) create mode 100644 test/test_chordpro/newline.crlf.csg.source delete mode 100644 test/test_chordpro/newline.crlf.source rename test/test_chordpro/{newline.crlf.tex => newline.crlf.tsg} (100%) rename test/test_chordpro/{newline.sgc => newline.csg} (100%) rename test/test_chordpro/{newline.source => newline.csg.source} (100%) rename test/test_chordpro/{newline.tex => newline.tsg} (100%) rename test/test_chordpro/{nolyrics.sgc => nolyrics.csg} (100%) rename test/test_chordpro/{nolyrics.source => nolyrics.csg.source} (100%) rename test/test_chordpro/{nolyrics.tex => nolyrics.tsg} (100%) rename test/test_chordpro/{tags.sgc => tags.csg} (100%) rename test/test_chordpro/{tags.source => tags.csg.source} (100%) rename test/test_chordpro/{tags.tex => tags.tsg} (100%) rename test/test_chordpro/{ukulelechords.sgc => ukulelechords.csg} (100%) rename test/test_chordpro/{ukulelechords.source => ukulelechords.csg.source} (100%) rename test/test_chordpro/{ukulelechords.tex => ukulelechords.tsg} (100%) diff --git a/patacrep/songs/chordpro/__init__.py b/patacrep/songs/chordpro/__init__.py index 330b2f3e..5777b170 100644 --- a/patacrep/songs/chordpro/__init__.py +++ b/patacrep/songs/chordpro/__init__.py @@ -131,13 +131,13 @@ class Chordpro2ChordproSong(ChordproSong): return filename SONG_RENDERERS = { - "latex": { - 'sgc': Chordpro2LatexSong, + "tsg": { + 'csg': Chordpro2LatexSong, }, "html": { - 'sgc': Chordpro2HtmlSong, + 'csg': Chordpro2HtmlSong, }, - "chordpro": { - 'sgc': Chordpro2ChordproSong, + "csg": { + 'csg': Chordpro2ChordproSong, }, } diff --git a/test/test_chordpro/00.sgc b/test/test_chordpro/00.csg similarity index 100% rename from test/test_chordpro/00.sgc rename to test/test_chordpro/00.csg diff --git a/test/test_chordpro/00.source b/test/test_chordpro/00.csg.source similarity index 100% rename from test/test_chordpro/00.source rename to test/test_chordpro/00.csg.source diff --git a/test/test_chordpro/00.tex b/test/test_chordpro/00.tsg similarity index 100% rename from test/test_chordpro/00.tex rename to test/test_chordpro/00.tsg diff --git a/test/test_chordpro/01.sgc b/test/test_chordpro/01.csg similarity index 100% rename from test/test_chordpro/01.sgc rename to test/test_chordpro/01.csg diff --git a/test/test_chordpro/01.source b/test/test_chordpro/01.csg.source similarity index 100% rename from test/test_chordpro/01.source rename to test/test_chordpro/01.csg.source diff --git a/test/test_chordpro/01.tex b/test/test_chordpro/01.tsg similarity index 100% rename from test/test_chordpro/01.tex rename to test/test_chordpro/01.tsg diff --git a/test/test_chordpro/02.sgc b/test/test_chordpro/02.csg similarity index 100% rename from test/test_chordpro/02.sgc rename to test/test_chordpro/02.csg diff --git a/test/test_chordpro/02.source b/test/test_chordpro/02.csg.source similarity index 100% rename from test/test_chordpro/02.source rename to test/test_chordpro/02.csg.source diff --git a/test/test_chordpro/02.tex b/test/test_chordpro/02.tsg similarity index 100% rename from test/test_chordpro/02.tex rename to test/test_chordpro/02.tsg diff --git a/test/test_chordpro/03.sgc b/test/test_chordpro/03.csg similarity index 100% rename from test/test_chordpro/03.sgc rename to test/test_chordpro/03.csg diff --git a/test/test_chordpro/03.source b/test/test_chordpro/03.csg.source similarity index 100% rename from test/test_chordpro/03.source rename to test/test_chordpro/03.csg.source diff --git a/test/test_chordpro/03.tex b/test/test_chordpro/03.tsg similarity index 100% rename from test/test_chordpro/03.tex rename to test/test_chordpro/03.tsg diff --git a/test/test_chordpro/04.sgc b/test/test_chordpro/04.csg similarity index 100% rename from test/test_chordpro/04.sgc rename to test/test_chordpro/04.csg diff --git a/test/test_chordpro/04.source b/test/test_chordpro/04.csg.source similarity index 100% rename from test/test_chordpro/04.source rename to test/test_chordpro/04.csg.source diff --git a/test/test_chordpro/04.tex b/test/test_chordpro/04.tsg similarity index 100% rename from test/test_chordpro/04.tex rename to test/test_chordpro/04.tsg diff --git a/test/test_chordpro/05.sgc b/test/test_chordpro/05.csg similarity index 100% rename from test/test_chordpro/05.sgc rename to test/test_chordpro/05.csg diff --git a/test/test_chordpro/05.source b/test/test_chordpro/05.csg.source similarity index 100% rename from test/test_chordpro/05.source rename to test/test_chordpro/05.csg.source diff --git a/test/test_chordpro/05.tex b/test/test_chordpro/05.tsg similarity index 100% rename from test/test_chordpro/05.tex rename to test/test_chordpro/05.tsg diff --git a/test/test_chordpro/06.sgc b/test/test_chordpro/06.csg similarity index 100% rename from test/test_chordpro/06.sgc rename to test/test_chordpro/06.csg diff --git a/test/test_chordpro/06.source b/test/test_chordpro/06.csg.source similarity index 100% rename from test/test_chordpro/06.source rename to test/test_chordpro/06.csg.source diff --git a/test/test_chordpro/06.tex b/test/test_chordpro/06.tsg similarity index 100% rename from test/test_chordpro/06.tex rename to test/test_chordpro/06.tsg diff --git a/test/test_chordpro/07.sgc b/test/test_chordpro/07.csg similarity index 100% rename from test/test_chordpro/07.sgc rename to test/test_chordpro/07.csg diff --git a/test/test_chordpro/07.source b/test/test_chordpro/07.csg.source similarity index 100% rename from test/test_chordpro/07.source rename to test/test_chordpro/07.csg.source diff --git a/test/test_chordpro/07.tex b/test/test_chordpro/07.tsg similarity index 100% rename from test/test_chordpro/07.tex rename to test/test_chordpro/07.tsg diff --git a/test/test_chordpro/08.sgc b/test/test_chordpro/08.csg similarity index 100% rename from test/test_chordpro/08.sgc rename to test/test_chordpro/08.csg diff --git a/test/test_chordpro/08.source b/test/test_chordpro/08.csg.source similarity index 100% rename from test/test_chordpro/08.source rename to test/test_chordpro/08.csg.source diff --git a/test/test_chordpro/08.tex b/test/test_chordpro/08.tsg similarity index 100% rename from test/test_chordpro/08.tex rename to test/test_chordpro/08.tsg diff --git a/test/test_chordpro/09.sgc b/test/test_chordpro/09.csg similarity index 100% rename from test/test_chordpro/09.sgc rename to test/test_chordpro/09.csg diff --git a/test/test_chordpro/09.source b/test/test_chordpro/09.csg.source similarity index 100% rename from test/test_chordpro/09.source rename to test/test_chordpro/09.csg.source diff --git a/test/test_chordpro/09.tex b/test/test_chordpro/09.tsg similarity index 100% rename from test/test_chordpro/09.tex rename to test/test_chordpro/09.tsg diff --git a/test/test_chordpro/10.sgc b/test/test_chordpro/10.csg similarity index 100% rename from test/test_chordpro/10.sgc rename to test/test_chordpro/10.csg diff --git a/test/test_chordpro/10.source b/test/test_chordpro/10.csg.source similarity index 100% rename from test/test_chordpro/10.source rename to test/test_chordpro/10.csg.source diff --git a/test/test_chordpro/10.tex b/test/test_chordpro/10.tsg similarity index 100% rename from test/test_chordpro/10.tex rename to test/test_chordpro/10.tsg diff --git a/test/test_chordpro/11.sgc b/test/test_chordpro/11.csg similarity index 100% rename from test/test_chordpro/11.sgc rename to test/test_chordpro/11.csg diff --git a/test/test_chordpro/11.source b/test/test_chordpro/11.csg.source similarity index 100% rename from test/test_chordpro/11.source rename to test/test_chordpro/11.csg.source diff --git a/test/test_chordpro/11.tex b/test/test_chordpro/11.tsg similarity index 100% rename from test/test_chordpro/11.tex rename to test/test_chordpro/11.tsg diff --git a/test/test_chordpro/12.sgc b/test/test_chordpro/12.csg similarity index 100% rename from test/test_chordpro/12.sgc rename to test/test_chordpro/12.csg diff --git a/test/test_chordpro/12.source b/test/test_chordpro/12.csg.source similarity index 100% rename from test/test_chordpro/12.source rename to test/test_chordpro/12.csg.source diff --git a/test/test_chordpro/12.tex b/test/test_chordpro/12.tsg similarity index 100% rename from test/test_chordpro/12.tex rename to test/test_chordpro/12.tsg diff --git a/test/test_chordpro/13.sgc b/test/test_chordpro/13.csg similarity index 100% rename from test/test_chordpro/13.sgc rename to test/test_chordpro/13.csg diff --git a/test/test_chordpro/13.source b/test/test_chordpro/13.csg.source similarity index 100% rename from test/test_chordpro/13.source rename to test/test_chordpro/13.csg.source diff --git a/test/test_chordpro/13.tex b/test/test_chordpro/13.tsg similarity index 100% rename from test/test_chordpro/13.tex rename to test/test_chordpro/13.tsg diff --git a/test/test_chordpro/21.sgc b/test/test_chordpro/21.csg similarity index 100% rename from test/test_chordpro/21.sgc rename to test/test_chordpro/21.csg diff --git a/test/test_chordpro/21.source b/test/test_chordpro/21.csg.source similarity index 100% rename from test/test_chordpro/21.source rename to test/test_chordpro/21.csg.source diff --git a/test/test_chordpro/21.tex b/test/test_chordpro/21.tsg similarity index 100% rename from test/test_chordpro/21.tex rename to test/test_chordpro/21.tsg diff --git a/test/test_chordpro/22.sgc b/test/test_chordpro/22.csg similarity index 100% rename from test/test_chordpro/22.sgc rename to test/test_chordpro/22.csg diff --git a/test/test_chordpro/22.source b/test/test_chordpro/22.csg.source similarity index 100% rename from test/test_chordpro/22.source rename to test/test_chordpro/22.csg.source diff --git a/test/test_chordpro/22.tex b/test/test_chordpro/22.tsg similarity index 100% rename from test/test_chordpro/22.tex rename to test/test_chordpro/22.tsg diff --git a/test/test_chordpro/23.sgc b/test/test_chordpro/23.csg similarity index 100% rename from test/test_chordpro/23.sgc rename to test/test_chordpro/23.csg diff --git a/test/test_chordpro/23.source b/test/test_chordpro/23.csg.source similarity index 100% rename from test/test_chordpro/23.source rename to test/test_chordpro/23.csg.source diff --git a/test/test_chordpro/23.tex b/test/test_chordpro/23.tsg similarity index 100% rename from test/test_chordpro/23.tex rename to test/test_chordpro/23.tsg diff --git a/test/test_chordpro/24.sgc b/test/test_chordpro/24.csg similarity index 100% rename from test/test_chordpro/24.sgc rename to test/test_chordpro/24.csg diff --git a/test/test_chordpro/24.source b/test/test_chordpro/24.csg.source similarity index 100% rename from test/test_chordpro/24.source rename to test/test_chordpro/24.csg.source diff --git a/test/test_chordpro/24.tex b/test/test_chordpro/24.tsg similarity index 100% rename from test/test_chordpro/24.tex rename to test/test_chordpro/24.tsg diff --git a/test/test_chordpro/25.sgc b/test/test_chordpro/25.csg similarity index 100% rename from test/test_chordpro/25.sgc rename to test/test_chordpro/25.csg diff --git a/test/test_chordpro/25.source b/test/test_chordpro/25.csg.source similarity index 100% rename from test/test_chordpro/25.source rename to test/test_chordpro/25.csg.source diff --git a/test/test_chordpro/25.tex b/test/test_chordpro/25.tsg similarity index 100% rename from test/test_chordpro/25.tex rename to test/test_chordpro/25.tsg diff --git a/test/test_chordpro/26.sgc b/test/test_chordpro/26.csg similarity index 100% rename from test/test_chordpro/26.sgc rename to test/test_chordpro/26.csg diff --git a/test/test_chordpro/26.source b/test/test_chordpro/26.csg.source similarity index 100% rename from test/test_chordpro/26.source rename to test/test_chordpro/26.csg.source diff --git a/test/test_chordpro/26.tex b/test/test_chordpro/26.tsg similarity index 100% rename from test/test_chordpro/26.tex rename to test/test_chordpro/26.tsg diff --git a/test/test_chordpro/27.sgc b/test/test_chordpro/27.csg similarity index 100% rename from test/test_chordpro/27.sgc rename to test/test_chordpro/27.csg diff --git a/test/test_chordpro/27.source b/test/test_chordpro/27.csg.source similarity index 100% rename from test/test_chordpro/27.source rename to test/test_chordpro/27.csg.source diff --git a/test/test_chordpro/27.tex b/test/test_chordpro/27.tsg similarity index 100% rename from test/test_chordpro/27.tex rename to test/test_chordpro/27.tsg diff --git a/test/test_chordpro/28.sgc b/test/test_chordpro/28.csg similarity index 100% rename from test/test_chordpro/28.sgc rename to test/test_chordpro/28.csg diff --git a/test/test_chordpro/28.source b/test/test_chordpro/28.csg.source similarity index 100% rename from test/test_chordpro/28.source rename to test/test_chordpro/28.csg.source diff --git a/test/test_chordpro/28.tex b/test/test_chordpro/28.tsg similarity index 100% rename from test/test_chordpro/28.tex rename to test/test_chordpro/28.tsg diff --git a/test/test_chordpro/29.sgc b/test/test_chordpro/29.csg similarity index 100% rename from test/test_chordpro/29.sgc rename to test/test_chordpro/29.csg diff --git a/test/test_chordpro/29.source b/test/test_chordpro/29.csg.source similarity index 100% rename from test/test_chordpro/29.source rename to test/test_chordpro/29.csg.source diff --git a/test/test_chordpro/29.tex b/test/test_chordpro/29.tsg similarity index 100% rename from test/test_chordpro/29.tex rename to test/test_chordpro/29.tsg diff --git a/test/test_chordpro/author_names.sgc b/test/test_chordpro/author_names.csg similarity index 100% rename from test/test_chordpro/author_names.sgc rename to test/test_chordpro/author_names.csg diff --git a/test/test_chordpro/author_names.source b/test/test_chordpro/author_names.csg.source similarity index 100% rename from test/test_chordpro/author_names.source rename to test/test_chordpro/author_names.csg.source diff --git a/test/test_chordpro/author_names.tex b/test/test_chordpro/author_names.tsg similarity index 100% rename from test/test_chordpro/author_names.tex rename to test/test_chordpro/author_names.tsg diff --git a/test/test_chordpro/chords.sgc b/test/test_chordpro/chords.csg similarity index 100% rename from test/test_chordpro/chords.sgc rename to test/test_chordpro/chords.csg diff --git a/test/test_chordpro/chords.source b/test/test_chordpro/chords.csg.source similarity index 100% rename from test/test_chordpro/chords.source rename to test/test_chordpro/chords.csg.source diff --git a/test/test_chordpro/chords.tex b/test/test_chordpro/chords.tsg similarity index 100% rename from test/test_chordpro/chords.tex rename to test/test_chordpro/chords.tsg diff --git a/test/test_chordpro/customchords.sgc b/test/test_chordpro/customchords.csg similarity index 100% rename from test/test_chordpro/customchords.sgc rename to test/test_chordpro/customchords.csg diff --git a/test/test_chordpro/customchords.source b/test/test_chordpro/customchords.csg.source similarity index 100% rename from test/test_chordpro/customchords.source rename to test/test_chordpro/customchords.csg.source diff --git a/test/test_chordpro/customchords.tex b/test/test_chordpro/customchords.tsg similarity index 100% rename from test/test_chordpro/customchords.tex rename to test/test_chordpro/customchords.tsg diff --git a/test/test_chordpro/errors/invalid_content.source b/test/test_chordpro/errors/invalid_content.csg.source similarity index 100% rename from test/test_chordpro/errors/invalid_content.source rename to test/test_chordpro/errors/invalid_content.csg.source diff --git a/test/test_chordpro/greensleeves.sgc b/test/test_chordpro/greensleeves.csg similarity index 100% rename from test/test_chordpro/greensleeves.sgc rename to test/test_chordpro/greensleeves.csg diff --git a/test/test_chordpro/greensleeves.source b/test/test_chordpro/greensleeves.csg.source similarity index 100% rename from test/test_chordpro/greensleeves.source rename to test/test_chordpro/greensleeves.csg.source diff --git a/test/test_chordpro/greensleeves.tex b/test/test_chordpro/greensleeves.tsg similarity index 100% rename from test/test_chordpro/greensleeves.tex rename to test/test_chordpro/greensleeves.tsg diff --git a/test/test_chordpro/invalid_chord.sgc b/test/test_chordpro/invalid_chord.csg similarity index 100% rename from test/test_chordpro/invalid_chord.sgc rename to test/test_chordpro/invalid_chord.csg diff --git a/test/test_chordpro/invalid_chord.source b/test/test_chordpro/invalid_chord.csg.source similarity index 100% rename from test/test_chordpro/invalid_chord.source rename to test/test_chordpro/invalid_chord.csg.source diff --git a/test/test_chordpro/invalid_chord.tex b/test/test_chordpro/invalid_chord.tsg similarity index 100% rename from test/test_chordpro/invalid_chord.tex rename to test/test_chordpro/invalid_chord.tsg diff --git a/test/test_chordpro/invalid_customchord.sgc b/test/test_chordpro/invalid_customchord.csg similarity index 100% rename from test/test_chordpro/invalid_customchord.sgc rename to test/test_chordpro/invalid_customchord.csg diff --git a/test/test_chordpro/invalid_customchord.source b/test/test_chordpro/invalid_customchord.csg.source similarity index 100% rename from test/test_chordpro/invalid_customchord.source rename to test/test_chordpro/invalid_customchord.csg.source diff --git a/test/test_chordpro/invalid_customchord.tex b/test/test_chordpro/invalid_customchord.tsg similarity index 100% rename from test/test_chordpro/invalid_customchord.tex rename to test/test_chordpro/invalid_customchord.tsg diff --git a/test/test_chordpro/invalid_directive.sgc b/test/test_chordpro/invalid_directive.csg similarity index 100% rename from test/test_chordpro/invalid_directive.sgc rename to test/test_chordpro/invalid_directive.csg diff --git a/test/test_chordpro/invalid_directive.source b/test/test_chordpro/invalid_directive.csg.source similarity index 100% rename from test/test_chordpro/invalid_directive.source rename to test/test_chordpro/invalid_directive.csg.source diff --git a/test/test_chordpro/invalid_directive.tex b/test/test_chordpro/invalid_directive.tsg similarity index 100% rename from test/test_chordpro/invalid_directive.tex rename to test/test_chordpro/invalid_directive.tsg diff --git a/test/test_chordpro/lang.sgc b/test/test_chordpro/lang.csg similarity index 100% rename from test/test_chordpro/lang.sgc rename to test/test_chordpro/lang.csg diff --git a/test/test_chordpro/lang.source b/test/test_chordpro/lang.csg.source similarity index 100% rename from test/test_chordpro/lang.source rename to test/test_chordpro/lang.csg.source diff --git a/test/test_chordpro/metadata.sgc b/test/test_chordpro/metadata.csg similarity index 100% rename from test/test_chordpro/metadata.sgc rename to test/test_chordpro/metadata.csg diff --git a/test/test_chordpro/metadata.source b/test/test_chordpro/metadata.csg.source similarity index 100% rename from test/test_chordpro/metadata.source rename to test/test_chordpro/metadata.csg.source diff --git a/test/test_chordpro/metadata.tex b/test/test_chordpro/metadata.tsg similarity index 100% rename from test/test_chordpro/metadata.tex rename to test/test_chordpro/metadata.tsg diff --git a/test/test_chordpro/newline.crlf.sgc b/test/test_chordpro/newline.crlf.csg similarity index 100% rename from test/test_chordpro/newline.crlf.sgc rename to test/test_chordpro/newline.crlf.csg diff --git a/test/test_chordpro/newline.crlf.csg.source b/test/test_chordpro/newline.crlf.csg.source new file mode 100644 index 00000000..2071e66d --- /dev/null +++ b/test/test_chordpro/newline.crlf.csg.source @@ -0,0 +1,2 @@ +# This content will be overwritten with `newline.csg.source` content +# with windows line endings (CRLF) - for testing purposes diff --git a/test/test_chordpro/newline.crlf.source b/test/test_chordpro/newline.crlf.source deleted file mode 100644 index bd45d5ce..00000000 --- a/test/test_chordpro/newline.crlf.source +++ /dev/null @@ -1,2 +0,0 @@ -# This content will be overwritten with `newline.source` content -# with windows line endings (CRLF) - for testing purposes diff --git a/test/test_chordpro/newline.crlf.tex b/test/test_chordpro/newline.crlf.tsg similarity index 100% rename from test/test_chordpro/newline.crlf.tex rename to test/test_chordpro/newline.crlf.tsg diff --git a/test/test_chordpro/newline.sgc b/test/test_chordpro/newline.csg similarity index 100% rename from test/test_chordpro/newline.sgc rename to test/test_chordpro/newline.csg diff --git a/test/test_chordpro/newline.source b/test/test_chordpro/newline.csg.source similarity index 100% rename from test/test_chordpro/newline.source rename to test/test_chordpro/newline.csg.source diff --git a/test/test_chordpro/newline.tex b/test/test_chordpro/newline.tsg similarity index 100% rename from test/test_chordpro/newline.tex rename to test/test_chordpro/newline.tsg diff --git a/test/test_chordpro/nolyrics.sgc b/test/test_chordpro/nolyrics.csg similarity index 100% rename from test/test_chordpro/nolyrics.sgc rename to test/test_chordpro/nolyrics.csg diff --git a/test/test_chordpro/nolyrics.source b/test/test_chordpro/nolyrics.csg.source similarity index 100% rename from test/test_chordpro/nolyrics.source rename to test/test_chordpro/nolyrics.csg.source diff --git a/test/test_chordpro/nolyrics.tex b/test/test_chordpro/nolyrics.tsg similarity index 100% rename from test/test_chordpro/nolyrics.tex rename to test/test_chordpro/nolyrics.tsg diff --git a/test/test_chordpro/tags.sgc b/test/test_chordpro/tags.csg similarity index 100% rename from test/test_chordpro/tags.sgc rename to test/test_chordpro/tags.csg diff --git a/test/test_chordpro/tags.source b/test/test_chordpro/tags.csg.source similarity index 100% rename from test/test_chordpro/tags.source rename to test/test_chordpro/tags.csg.source diff --git a/test/test_chordpro/tags.tex b/test/test_chordpro/tags.tsg similarity index 100% rename from test/test_chordpro/tags.tex rename to test/test_chordpro/tags.tsg diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 5d8a64da..9ebe3e00 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -15,17 +15,13 @@ from patacrep.encoding import open_read from .. import disable_logging from .. import dynamic # pylint: disable=unused-import -LANGUAGES = { - 'tex': 'latex', - 'sgc': 'chordpro', - 'html': 'html', -} +OUTPUTS = ['csg', 'tsg', 'html'] class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of chorpro parser, and several renderers. For any given `foo.source`, it is parsed as a chordpro file, and should be - rendered as `foo.sgc` with the chordpro renderer, and `foo.tex` with the + rendered as `foo.csg` with the chordpro renderer, and `foo.tsg` with the latex renderer. This class does nothing by itself, but its metaclass populates it with test @@ -50,15 +46,15 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): with files.chdir(resource_filename(__name__, ""), *path): yield - def assertRender(self, base, destformat): # pylint: disable=invalid-name - """Assert that `{base}.source` is correctly rendered in the `destformat`. + def assertRender(self, base, in_format, out_format): # pylint: disable=invalid-name + """Assert that `{base}.source` is correctly rendered in the `out_format`. """ - sourcename = "{}.source".format(base) - destname = "{}.{}".format(base, destformat) + sourcename = "{}.{}.source".format(base, in_format) + destname = "{}.{}".format(base, out_format) with self.chdir(): with open_read(destname) as expectfile: with disable_logging(): - song = self.song_plugins[LANGUAGES[destformat]]['sgc'](sourcename, self.config) + song = self.song_plugins[out_format][in_format](sourcename, self.config) self.assertMultiLineEqual( song.render().strip(), expectfile.read().strip(), @@ -79,45 +75,47 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): keyword='SONG_RENDERERS', ) with cls.chdir(): - for source in sorted(glob.glob('*.source')): - base = source[:-len(".source")] - for dest in LANGUAGES: - destname = "{}.{}".format(base, dest) - if not os.path.exists(destname): + for source in sorted(glob.glob('*.*.source')): + [*base, in_format, _] = source.split('.') + base = '.'.join(base) + for out_format in OUTPUTS: + outname = "{}.{}".format(base, out_format) + if not os.path.exists(outname): continue yield ( - "test_{}_{}".format(base, dest), - cls._create_test(base, dest), + "test_{}_{}_2_{}".format(base, in_format, out_format), + cls._create_test(base, in_format, out_format), ) with cls.chdir('errors'): - for source in sorted(glob.glob('*.source')): - base = source[:-len(".source")] + for source in sorted(glob.glob('*.*.source')): + [*base, in_format, _] = source.split('.') + base = '.'.join(base) yield ( - "test_{}_failure".format(base), - cls._create_failure(base), + "test_{}_{}_failure".format(base, in_format), + cls._create_failure(base, in_format), ) @classmethod - def _create_test(cls, base, dest): - """Return a function testing that `base` compilation in `dest` format. + def _create_test(cls, base, in_format, out_format): + """Return a function testing that `base` compilation in `out_format` format. """ - test_parse_render = lambda self: self.assertRender(base, dest) + test_parse_render = lambda self: self.assertRender(base, in_format, out_format) test_parse_render.__doc__ = ( - "Test that '{base}' is correctly parsed and rendererd into '{format}' format." - ).format(base=os.path.basename(base), format=dest) + "Test that '{base}.{in_format}' is correctly parsed and rendererd into '{out_format}'." + ).format(base=os.path.basename(base), in_format=in_format, out_format=out_format) return test_parse_render @classmethod - def _create_failure(cls, base): + def _create_failure(cls, base, in_format, out_format='tsg'): """Return a function testing that `base` parsing fails. """ def test_parse_failure(self): """Test that `base` parsing fails.""" - sourcename = "{}.source".format(base) + sourcename = "{}.{}.source".format(base, in_format) with self.chdir('errors'): - parser = self.song_plugins[LANGUAGES['sgc']]['sgc'] + parser = self.song_plugins[out_format][in_format] self.assertRaises(SyntaxError, parser, sourcename, self.config) test_parse_failure.__doc__ = ( @@ -130,9 +128,9 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Overwrite `*.crlf.source` files to force the CRLF line endings. """ with cls.chdir(): - for crlfname in sorted(glob.glob('*.crlf.source')): - base = crlfname[:-len(".crlf.source")] - sourcename = base + ".source" + for crlfname in sorted(glob.glob('*.crlf.*.source')): + [*base, _, in_format, source] = crlfname.split('.') + sourcename = '.'.join(base + [in_format, source]) with open_read(sourcename) as sourcefile: with open(crlfname, 'w') as crlffile: for line in sourcefile: @@ -146,7 +144,8 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): # with windows line endings (CRLF) - for testing purposes """ with cls.chdir(): - for crlfname in sorted(glob.glob('*.crlf.source')): - base = crlfname[:-len(".crlf.source")] + for crlfname in sorted(glob.glob('*.crlf.*.source')): + [*base, crlf, in_format, _] = crlfname.split('.') + base = '.'.join(base + [in_format]) with open(crlfname, 'w') as crlffile: crlffile.write(crlf_msg.format(base)) diff --git a/test/test_chordpro/ukulelechords.sgc b/test/test_chordpro/ukulelechords.csg similarity index 100% rename from test/test_chordpro/ukulelechords.sgc rename to test/test_chordpro/ukulelechords.csg diff --git a/test/test_chordpro/ukulelechords.source b/test/test_chordpro/ukulelechords.csg.source similarity index 100% rename from test/test_chordpro/ukulelechords.source rename to test/test_chordpro/ukulelechords.csg.source diff --git a/test/test_chordpro/ukulelechords.tex b/test/test_chordpro/ukulelechords.tsg similarity index 100% rename from test/test_chordpro/ukulelechords.tex rename to test/test_chordpro/ukulelechords.tsg From 312b63df60320bc3f96a83d6022d9483011da83c Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 11:10:42 +0100 Subject: [PATCH 12/20] Change test_compilation extensions --- patacrep/build.py | 2 +- patacrep/content/tex.py | 4 +-- patacrep/songbook/__main__.py | 2 +- patacrep/songs/latex/__init__.py | 6 ++-- test/test_compilation/datadir.tex.control | 30 +++++++++---------- .../songs/{datadir.sgc => datadir.csg} | 0 .../songs/{datadir.sg => datadir.tsg} | 0 .../songs/{datadir2.sgc => datadir2.csg} | 0 .../songs/{datadir2.sg => datadir2.tsg} | 0 .../songs/{relative.sgc => relative.csg} | 0 .../songs/{relative.sg => relative.tsg} | 0 .../songs/subdir/{subdir.sgc => subdir.csg} | 0 .../songs/subdir/{subdir.sg => subdir.tsg} | 0 test/test_compilation/languages.tex.control | 10 +++---- .../songs/{language.sgc => language.csg} | 0 ...age_location.sgc => language_location.csg} | 0 .../{no_language.sgc => no_language.csg} | 0 ...{wrong_language.sgc => wrong_language.csg} | 0 ...{wrong_location.sgc => wrong_location.csg} | 0 test/test_compilation/syntax.tex.control | 2 +- .../songs/{musicnote.sgc => musicnote.csg} | 0 test/test_compilation/unicode.tex.control | 2 +- .../songs/{nonbreak.sgc => nonbreak.csg} | 0 23 files changed, 29 insertions(+), 29 deletions(-) rename test/test_compilation/datadir_datadir/songs/{datadir.sgc => datadir.csg} (100%) rename test/test_compilation/datadir_datadir/songs/{datadir.sg => datadir.tsg} (100%) rename test/test_compilation/datadir_datadir/songs/{datadir2.sgc => datadir2.csg} (100%) rename test/test_compilation/datadir_datadir/songs/{datadir2.sg => datadir2.tsg} (100%) rename test/test_compilation/datadir_datadir/songs/{relative.sgc => relative.csg} (100%) rename test/test_compilation/datadir_datadir/songs/{relative.sg => relative.tsg} (100%) rename test/test_compilation/datadir_datadir/songs/subdir/{subdir.sgc => subdir.csg} (100%) rename test/test_compilation/datadir_datadir/songs/subdir/{subdir.sg => subdir.tsg} (100%) rename test/test_compilation/languages_datadir/songs/{language.sgc => language.csg} (100%) rename test/test_compilation/languages_datadir/songs/{language_location.sgc => language_location.csg} (100%) rename test/test_compilation/languages_datadir/songs/{no_language.sgc => no_language.csg} (100%) rename test/test_compilation/languages_datadir/songs/{wrong_language.sgc => wrong_language.csg} (100%) rename test/test_compilation/languages_datadir/songs/{wrong_location.sgc => wrong_location.csg} (100%) rename test/test_compilation/syntax_datadir/songs/{musicnote.sgc => musicnote.csg} (100%) rename test/test_compilation/unicode_datadir/songs/{nonbreak.sgc => nonbreak.csg} (100%) diff --git a/patacrep/build.py b/patacrep/build.py index 0342959b..0526d5c2 100644 --- a/patacrep/build.py +++ b/patacrep/build.py @@ -109,7 +109,7 @@ class Songbook(object): datadirs=config.get('datadir', []), root_modules=['songs'], keyword='SONG_RENDERERS', - )['latex'] + )['tsg'] # Configuration set config['render'] = content.render diff --git a/patacrep/content/tex.py b/patacrep/content/tex.py index 0f520c19..badf58e6 100755 --- a/patacrep/content/tex.py +++ b/patacrep/content/tex.py @@ -33,7 +33,7 @@ def parse(keyword, argument, contentlist, config): """ if not contentlist: LOGGER.warning( - "Useless 'tex' content: list of files to include is empty." + "Useless 'tsg' content: list of files to include is empty." ) filelist = [] basefolders = itertools.chain( @@ -62,4 +62,4 @@ def parse(keyword, argument, contentlist, config): return filelist -CONTENT_PLUGINS = {'tex': parse} +CONTENT_PLUGINS = {'tsg': parse} diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index 004f3e95..d049cccb 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -153,7 +153,7 @@ def main(): # Command line options datadirs += [item[0] for item in options.datadir] if 'datadir' in songbook: - # .sg file + # .tsg file if isinstance(songbook['datadir'], str): songbook['datadir'] = [songbook['datadir']] datadirs += [ diff --git a/patacrep/songs/latex/__init__.py b/patacrep/songs/latex/__init__.py index d19cd10e..c9359f1c 100644 --- a/patacrep/songs/latex/__init__.py +++ b/patacrep/songs/latex/__init__.py @@ -49,9 +49,9 @@ class Latex2LatexSong(Song): self.lang = custom_lang SONG_RENDERERS = { - "latex": { - 'is': Latex2LatexSong, - 'sg': Latex2LatexSong, + "tsg": { + 'tis': Latex2LatexSong, + 'tsg': Latex2LatexSong, }, } diff --git a/test/test_compilation/datadir.tex.control b/test/test_compilation/datadir.tex.control index 14b11cb1..1df14c15 100644 --- a/test/test_compilation/datadir.tex.control +++ b/test/test_compilation/datadir.tex.control @@ -90,12 +90,7 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sg - -\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir.sg} - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir.sgc +%% songs/./datadir.csg \selectlanguage{english} @@ -117,12 +112,12 @@ Chordpro}[ \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir2.sg +%% songs/./datadir.tsg -\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir2.sg} +\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir.tsg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir2.sgc +%% songs/./datadir2.csg \selectlanguage{english} @@ -144,12 +139,12 @@ Chordpro}[ \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sg +%% songs/./datadir2.tsg -\import{@TEST_FOLDER@/datadir_datadir/songs/}{relative.sg} +\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir2.tsg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./relative.sgc +%% songs/./relative.csg \selectlanguage{english} @@ -171,12 +166,12 @@ Chordpro}[ \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./subdir/subdir.sg +%% songs/./relative.tsg -\import{@TEST_FOLDER@/datadir_datadir/songs/subdir/}{subdir.sg} +\import{@TEST_FOLDER@/datadir_datadir/songs/}{relative.tsg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./subdir/subdir.sgc +%% songs/./subdir/subdir.csg \selectlanguage{english} @@ -197,6 +192,11 @@ Chordpro}[ \endsong +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% songs/./subdir/subdir.tsg + +\import{@TEST_FOLDER@/datadir_datadir/songs/subdir/}{subdir.tsg} + \end{songs} diff --git a/test/test_compilation/datadir_datadir/songs/datadir.sgc b/test/test_compilation/datadir_datadir/songs/datadir.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir.sgc rename to test/test_compilation/datadir_datadir/songs/datadir.csg diff --git a/test/test_compilation/datadir_datadir/songs/datadir.sg b/test/test_compilation/datadir_datadir/songs/datadir.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir.sg rename to test/test_compilation/datadir_datadir/songs/datadir.tsg diff --git a/test/test_compilation/datadir_datadir/songs/datadir2.sgc b/test/test_compilation/datadir_datadir/songs/datadir2.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir2.sgc rename to test/test_compilation/datadir_datadir/songs/datadir2.csg diff --git a/test/test_compilation/datadir_datadir/songs/datadir2.sg b/test/test_compilation/datadir_datadir/songs/datadir2.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir2.sg rename to test/test_compilation/datadir_datadir/songs/datadir2.tsg diff --git a/test/test_compilation/datadir_datadir/songs/relative.sgc b/test/test_compilation/datadir_datadir/songs/relative.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.sgc rename to test/test_compilation/datadir_datadir/songs/relative.csg diff --git a/test/test_compilation/datadir_datadir/songs/relative.sg b/test/test_compilation/datadir_datadir/songs/relative.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/relative.sg rename to test/test_compilation/datadir_datadir/songs/relative.tsg diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.sgc b/test/test_compilation/datadir_datadir/songs/subdir/subdir.csg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.sgc rename to test/test_compilation/datadir_datadir/songs/subdir/subdir.csg diff --git a/test/test_compilation/datadir_datadir/songs/subdir/subdir.sg b/test/test_compilation/datadir_datadir/songs/subdir/subdir.tsg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/subdir/subdir.sg rename to test/test_compilation/datadir_datadir/songs/subdir/subdir.tsg diff --git a/test/test_compilation/languages.tex.control b/test/test_compilation/languages.tex.control index 59c233a7..6f08614f 100644 --- a/test/test_compilation/languages.tex.control +++ b/test/test_compilation/languages.tex.control @@ -91,7 +91,7 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./language.sgc +%% songs/./language.csg \selectlanguage{english} @@ -110,7 +110,7 @@ guitar, \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./language_location.sgc +%% songs/./language_location.csg \selectlanguage{french} @@ -129,7 +129,7 @@ guitar, \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./no_language.sgc +%% songs/./no_language.csg \selectlanguage{english} @@ -148,7 +148,7 @@ guitar, \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./wrong_language.sgc +%% songs/./wrong_language.csg \selectlanguage{english} @@ -167,7 +167,7 @@ guitar, \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./wrong_location.sgc +%% songs/./wrong_location.csg \selectlanguage{spanish} diff --git a/test/test_compilation/languages_datadir/songs/language.sgc b/test/test_compilation/languages_datadir/songs/language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/language.sgc rename to test/test_compilation/languages_datadir/songs/language.csg diff --git a/test/test_compilation/languages_datadir/songs/language_location.sgc b/test/test_compilation/languages_datadir/songs/language_location.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/language_location.sgc rename to test/test_compilation/languages_datadir/songs/language_location.csg diff --git a/test/test_compilation/languages_datadir/songs/no_language.sgc b/test/test_compilation/languages_datadir/songs/no_language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/no_language.sgc rename to test/test_compilation/languages_datadir/songs/no_language.csg diff --git a/test/test_compilation/languages_datadir/songs/wrong_language.sgc b/test/test_compilation/languages_datadir/songs/wrong_language.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/wrong_language.sgc rename to test/test_compilation/languages_datadir/songs/wrong_language.csg diff --git a/test/test_compilation/languages_datadir/songs/wrong_location.sgc b/test/test_compilation/languages_datadir/songs/wrong_location.csg similarity index 100% rename from test/test_compilation/languages_datadir/songs/wrong_location.sgc rename to test/test_compilation/languages_datadir/songs/wrong_location.csg diff --git a/test/test_compilation/syntax.tex.control b/test/test_compilation/syntax.tex.control index 6f213ef2..b2147b06 100644 --- a/test/test_compilation/syntax.tex.control +++ b/test/test_compilation/syntax.tex.control @@ -88,7 +88,7 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./musicnote.sgc +%% songs/./musicnote.csg \selectlanguage{english} diff --git a/test/test_compilation/syntax_datadir/songs/musicnote.sgc b/test/test_compilation/syntax_datadir/songs/musicnote.csg similarity index 100% rename from test/test_compilation/syntax_datadir/songs/musicnote.sgc rename to test/test_compilation/syntax_datadir/songs/musicnote.csg diff --git a/test/test_compilation/unicode.tex.control b/test/test_compilation/unicode.tex.control index 9c8e946d..759a15d8 100644 --- a/test/test_compilation/unicode.tex.control +++ b/test/test_compilation/unicode.tex.control @@ -88,7 +88,7 @@ guitar, \begin{songs}{titleidx,authidx} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./nonbreak.sgc +%% songs/./nonbreak.csg \selectlanguage{english} diff --git a/test/test_compilation/unicode_datadir/songs/nonbreak.sgc b/test/test_compilation/unicode_datadir/songs/nonbreak.csg similarity index 100% rename from test/test_compilation/unicode_datadir/songs/nonbreak.sgc rename to test/test_compilation/unicode_datadir/songs/nonbreak.csg From e1e024d2ce9f102909e03b26125dc51eedbc03d1 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 11:14:37 +0100 Subject: [PATCH 13/20] Convert example extensions --- ...iers_de_la_table_ronde.sg => chevaliers_de_la_table_ronde.tsg} | 0 examples/songs/{example-en.sg => example-en.tsg} | 0 examples/songs/{example-fr.sg => example-fr.tsg} | 0 examples/songs/{greensleeves.sgc => greensleeves.csg} | 0 examples/songs/{greensleeves.sg => greensleeves.tsg} | 0 examples/songs/tests/{chords.sgc => chords.csg} | 0 examples/songs/tests/{errors.sgc => errors.csg} | 0 examples/songs/tests/{newline.sgc => newline.csg} | 0 examples/songs/tests/{nolyrics.sgc => nolyrics.csg} | 0 examples/songs/{vent_frais.sg => vent_frais.tsg} | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename examples/songs/{chevaliers_de_la_table_ronde.sg => chevaliers_de_la_table_ronde.tsg} (100%) rename examples/songs/{example-en.sg => example-en.tsg} (100%) rename examples/songs/{example-fr.sg => example-fr.tsg} (100%) rename examples/songs/{greensleeves.sgc => greensleeves.csg} (100%) rename examples/songs/{greensleeves.sg => greensleeves.tsg} (100%) rename examples/songs/tests/{chords.sgc => chords.csg} (100%) rename examples/songs/tests/{errors.sgc => errors.csg} (100%) rename examples/songs/tests/{newline.sgc => newline.csg} (100%) rename examples/songs/tests/{nolyrics.sgc => nolyrics.csg} (100%) rename examples/songs/{vent_frais.sg => vent_frais.tsg} (100%) diff --git a/examples/songs/chevaliers_de_la_table_ronde.sg b/examples/songs/chevaliers_de_la_table_ronde.tsg similarity index 100% rename from examples/songs/chevaliers_de_la_table_ronde.sg rename to examples/songs/chevaliers_de_la_table_ronde.tsg diff --git a/examples/songs/example-en.sg b/examples/songs/example-en.tsg similarity index 100% rename from examples/songs/example-en.sg rename to examples/songs/example-en.tsg diff --git a/examples/songs/example-fr.sg b/examples/songs/example-fr.tsg similarity index 100% rename from examples/songs/example-fr.sg rename to examples/songs/example-fr.tsg diff --git a/examples/songs/greensleeves.sgc b/examples/songs/greensleeves.csg similarity index 100% rename from examples/songs/greensleeves.sgc rename to examples/songs/greensleeves.csg diff --git a/examples/songs/greensleeves.sg b/examples/songs/greensleeves.tsg similarity index 100% rename from examples/songs/greensleeves.sg rename to examples/songs/greensleeves.tsg diff --git a/examples/songs/tests/chords.sgc b/examples/songs/tests/chords.csg similarity index 100% rename from examples/songs/tests/chords.sgc rename to examples/songs/tests/chords.csg diff --git a/examples/songs/tests/errors.sgc b/examples/songs/tests/errors.csg similarity index 100% rename from examples/songs/tests/errors.sgc rename to examples/songs/tests/errors.csg diff --git a/examples/songs/tests/newline.sgc b/examples/songs/tests/newline.csg similarity index 100% rename from examples/songs/tests/newline.sgc rename to examples/songs/tests/newline.csg diff --git a/examples/songs/tests/nolyrics.sgc b/examples/songs/tests/nolyrics.csg similarity index 100% rename from examples/songs/tests/nolyrics.sgc rename to examples/songs/tests/nolyrics.csg diff --git a/examples/songs/vent_frais.sg b/examples/songs/vent_frais.tsg similarity index 100% rename from examples/songs/vent_frais.sg rename to examples/songs/vent_frais.tsg From 85da39dac63e4c5ae632c9aa3e8e32d153eb68eb Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 11:21:36 +0100 Subject: [PATCH 14/20] Syntax error in converter --- patacrep/songs/convert/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patacrep/songs/convert/__main__.py b/patacrep/songs/convert/__main__.py index 2880cdab..9826ba0d 100644 --- a/patacrep/songs/convert/__main__.py +++ b/patacrep/songs/convert/__main__.py @@ -17,7 +17,7 @@ def __usage(): return "python3 -m patacrep.songs.convert INPUTFORMAT OUTPUTFORMAT FILES" def confirm(destname): - while True + while True: try: return yesno(input("File '{}' already exist. Overwrite? [yn] ".format(destname))) except ValueError: @@ -62,7 +62,7 @@ if __name__ == "__main__": if not confirm(destname): continue with open(destname, "w") as destfile: - destfile.write(song.render(dest)) + destfile.write(song.render('song')) except NotImplementedError: LOGGER.error("Cannot convert to format '%s'.", dest) From 7e8f69483bb6d0010fe69f7349d5390d53ce97bf Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 11:25:10 +0100 Subject: [PATCH 15/20] Simplify converter --- patacrep/songs/convert/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patacrep/songs/convert/__main__.py b/patacrep/songs/convert/__main__.py index 9826ba0d..90276f7b 100644 --- a/patacrep/songs/convert/__main__.py +++ b/patacrep/songs/convert/__main__.py @@ -62,7 +62,7 @@ if __name__ == "__main__": if not confirm(destname): continue with open(destname, "w") as destfile: - destfile.write(song.render('song')) + destfile.write(song.render()) except NotImplementedError: LOGGER.error("Cannot convert to format '%s'.", dest) From 20aeae8003b54820618ad95776aa3dd5408f23fd Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 11:31:55 +0100 Subject: [PATCH 16/20] (pylint) unused variable --- test/test_chordpro/test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 9ebe3e00..7b7db4b3 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -145,7 +145,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """ with cls.chdir(): for crlfname in sorted(glob.glob('*.crlf.*.source')): - [*base, crlf, in_format, _] = crlfname.split('.') + [*base, _crlf, in_format, _] = crlfname.split('.') base = '.'.join(base + [in_format]) with open(crlfname, 'w') as crlffile: crlffile.write(crlf_msg.format(base)) From 7ee17760cde8bc9296c2314e09a7771d98ced618 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 13:02:34 +0100 Subject: [PATCH 17/20] Keep backward compatibility with .sg songs --- patacrep/songs/latex/__init__.py | 3 +++ test/test_compilation/datadir.tex.control | 4 ++-- .../datadir_datadir/songs/{datadir2.tsg => datadir2.sg} | 0 3 files changed, 5 insertions(+), 2 deletions(-) rename test/test_compilation/datadir_datadir/songs/{datadir2.tsg => datadir2.sg} (100%) diff --git a/patacrep/songs/latex/__init__.py b/patacrep/songs/latex/__init__.py index c9359f1c..1054f7da 100644 --- a/patacrep/songs/latex/__init__.py +++ b/patacrep/songs/latex/__init__.py @@ -52,6 +52,9 @@ SONG_RENDERERS = { "tsg": { 'tis': Latex2LatexSong, 'tsg': Latex2LatexSong, + + # For backward compatibility + 'sg': Latex2LatexSong, }, } diff --git a/test/test_compilation/datadir.tex.control b/test/test_compilation/datadir.tex.control index 1df14c15..afc99160 100644 --- a/test/test_compilation/datadir.tex.control +++ b/test/test_compilation/datadir.tex.control @@ -139,9 +139,9 @@ Chordpro}[ \endsong %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% songs/./datadir2.tsg +%% songs/./datadir2.sg -\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir2.tsg} +\import{@TEST_FOLDER@/datadir_datadir/songs/}{datadir2.sg} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% songs/./relative.csg diff --git a/test/test_compilation/datadir_datadir/songs/datadir2.tsg b/test/test_compilation/datadir_datadir/songs/datadir2.sg similarity index 100% rename from test/test_compilation/datadir_datadir/songs/datadir2.tsg rename to test/test_compilation/datadir_datadir/songs/datadir2.sg From 3b0ec365c389efeaf446ced32dc9835082085cff Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 13:05:13 +0100 Subject: [PATCH 18/20] Keep .tex extension for templates --- patacrep/content/tex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patacrep/content/tex.py b/patacrep/content/tex.py index badf58e6..0f520c19 100755 --- a/patacrep/content/tex.py +++ b/patacrep/content/tex.py @@ -33,7 +33,7 @@ def parse(keyword, argument, contentlist, config): """ if not contentlist: LOGGER.warning( - "Useless 'tsg' content: list of files to include is empty." + "Useless 'tex' content: list of files to include is empty." ) filelist = [] basefolders = itertools.chain( @@ -62,4 +62,4 @@ def parse(keyword, argument, contentlist, config): return filelist -CONTENT_PLUGINS = {'tsg': parse} +CONTENT_PLUGINS = {'tex': parse} From cd25a0795653337d099e49d70de82f0e63a648d7 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 13:05:20 +0100 Subject: [PATCH 19/20] remove useless comment --- patacrep/songbook/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/patacrep/songbook/__main__.py b/patacrep/songbook/__main__.py index d049cccb..cc56311b 100644 --- a/patacrep/songbook/__main__.py +++ b/patacrep/songbook/__main__.py @@ -153,7 +153,6 @@ def main(): # Command line options datadirs += [item[0] for item in options.datadir] if 'datadir' in songbook: - # .tsg file if isinstance(songbook['datadir'], str): songbook['datadir'] = [songbook['datadir']] datadirs += [ From 9d74a41f5352a80a8554d5cb453e05279411d9df Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Fri, 13 Nov 2015 13:10:13 +0100 Subject: [PATCH 20/20] improve test_parser docstring --- test/test_chordpro/test_parser.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/test_chordpro/test_parser.py b/test/test_chordpro/test_parser.py index 7b7db4b3..cd38afcd 100644 --- a/test/test_chordpro/test_parser.py +++ b/test/test_chordpro/test_parser.py @@ -20,9 +20,12 @@ OUTPUTS = ['csg', 'tsg', 'html'] class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): """Test of chorpro parser, and several renderers. - For any given `foo.source`, it is parsed as a chordpro file, and should be - rendered as `foo.csg` with the chordpro renderer, and `foo.tsg` with the - latex renderer. + For any given `foo.input_format.source`, the file is parsed as `input_format` and + rendered as many times as a `foo.out_format` exists (if `out_format` is a supported + output format). + + For instance `foo.csg.source` (chordpro song) will be rendered as LaTeX, if a file + `foo.tsg` exitsts. The result of the rendering will be compared with the `foo.tsg` file. This class does nothing by itself, but its metaclass populates it with test methods testing parser and renderers. @@ -47,7 +50,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): yield def assertRender(self, base, in_format, out_format): # pylint: disable=invalid-name - """Assert that `{base}.source` is correctly rendered in the `out_format`. + """Assert that `{base}.{in_format}.source` is correctly rendered in the `out_format`. """ sourcename = "{}.{}.source".format(base, in_format) destname = "{}.{}".format(base, out_format)