Browse Source

Merge branch 'master' into lineno

pull/175/head
Louis 9 years ago
parent
commit
d0e7bf287f
  1. 0
      examples/songs/chevaliers_de_la_table_ronde.tsg
  2. 0
      examples/songs/example-en.tsg
  3. 0
      examples/songs/example-fr.tsg
  4. 0
      examples/songs/greensleeves.csg
  5. 0
      examples/songs/greensleeves.tsg
  6. 0
      examples/songs/tests/chords.csg
  7. 0
      examples/songs/tests/errors.csg
  8. 0
      examples/songs/tests/newline.csg
  9. 0
      examples/songs/tests/nolyrics.csg
  10. 0
      examples/songs/vent_frais.tsg
  11. 2
      patacrep/build.py
  12. 6
      patacrep/files.py
  13. 1
      patacrep/songbook/__main__.py
  14. 10
      patacrep/songs/chordpro/__init__.py
  15. 14
      patacrep/songs/chordpro/syntax.py
  16. 4
      patacrep/songs/convert/__main__.py
  17. 7
      patacrep/songs/latex/__init__.py
  18. 0
      test/test_chordpro/00.csg
  19. 0
      test/test_chordpro/00.csg.source
  20. 0
      test/test_chordpro/00.tsg
  21. 0
      test/test_chordpro/01.csg
  22. 0
      test/test_chordpro/01.csg.source
  23. 0
      test/test_chordpro/01.tsg
  24. 0
      test/test_chordpro/02.csg
  25. 0
      test/test_chordpro/02.csg.source
  26. 0
      test/test_chordpro/02.tsg
  27. 0
      test/test_chordpro/03.csg
  28. 0
      test/test_chordpro/03.csg.source
  29. 0
      test/test_chordpro/03.tsg
  30. 0
      test/test_chordpro/04.csg
  31. 0
      test/test_chordpro/04.csg.source
  32. 0
      test/test_chordpro/04.tsg
  33. 0
      test/test_chordpro/05.csg
  34. 0
      test/test_chordpro/05.csg.source
  35. 0
      test/test_chordpro/05.tsg
  36. 0
      test/test_chordpro/06.csg
  37. 0
      test/test_chordpro/06.csg.source
  38. 0
      test/test_chordpro/06.tsg
  39. 0
      test/test_chordpro/07.csg
  40. 0
      test/test_chordpro/07.csg.source
  41. 0
      test/test_chordpro/07.tsg
  42. 0
      test/test_chordpro/08.csg
  43. 0
      test/test_chordpro/08.csg.source
  44. 0
      test/test_chordpro/08.tsg
  45. 0
      test/test_chordpro/09.csg
  46. 0
      test/test_chordpro/09.csg.source
  47. 0
      test/test_chordpro/09.tsg
  48. 0
      test/test_chordpro/10.csg
  49. 0
      test/test_chordpro/10.csg.source
  50. 0
      test/test_chordpro/10.tsg
  51. 0
      test/test_chordpro/11.csg
  52. 0
      test/test_chordpro/11.csg.source
  53. 0
      test/test_chordpro/11.tsg
  54. 0
      test/test_chordpro/12.csg
  55. 0
      test/test_chordpro/12.csg.source
  56. 0
      test/test_chordpro/12.tsg
  57. 0
      test/test_chordpro/13.csg
  58. 0
      test/test_chordpro/13.csg.source
  59. 0
      test/test_chordpro/13.tsg
  60. 0
      test/test_chordpro/21.csg
  61. 0
      test/test_chordpro/21.csg.source
  62. 0
      test/test_chordpro/21.tsg
  63. 0
      test/test_chordpro/22.csg
  64. 0
      test/test_chordpro/22.csg.source
  65. 0
      test/test_chordpro/22.tsg
  66. 0
      test/test_chordpro/23.csg
  67. 0
      test/test_chordpro/23.csg.source
  68. 0
      test/test_chordpro/23.tsg
  69. 0
      test/test_chordpro/24.csg
  70. 0
      test/test_chordpro/24.csg.source
  71. 0
      test/test_chordpro/24.tsg
  72. 0
      test/test_chordpro/25.csg
  73. 0
      test/test_chordpro/25.csg.source
  74. 0
      test/test_chordpro/25.tsg
  75. 0
      test/test_chordpro/26.csg
  76. 0
      test/test_chordpro/26.csg.source
  77. 0
      test/test_chordpro/26.tsg
  78. 0
      test/test_chordpro/27.csg
  79. 0
      test/test_chordpro/27.csg.source
  80. 0
      test/test_chordpro/27.tsg
  81. 0
      test/test_chordpro/28.csg
  82. 0
      test/test_chordpro/28.csg.source
  83. 0
      test/test_chordpro/28.tsg
  84. 0
      test/test_chordpro/29.csg
  85. 0
      test/test_chordpro/29.csg.source
  86. 0
      test/test_chordpro/29.tsg
  87. 0
      test/test_chordpro/author_names.csg
  88. 0
      test/test_chordpro/author_names.csg.source
  89. 0
      test/test_chordpro/author_names.tsg
  90. 0
      test/test_chordpro/chords.csg
  91. 0
      test/test_chordpro/chords.csg.source
  92. 0
      test/test_chordpro/chords.tsg
  93. 0
      test/test_chordpro/customchords.csg
  94. 0
      test/test_chordpro/customchords.csg.source
  95. 0
      test/test_chordpro/customchords.tsg
  96. 3
      test/test_chordpro/errors/invalid_content.csg.source
  97. 0
      test/test_chordpro/greensleeves.csg
  98. 0
      test/test_chordpro/greensleeves.csg.source
  99. 0
      test/test_chordpro/greensleeves.tsg
  100. 0
      test/test_chordpro/invalid_chord.csg

0
examples/songs/chevaliers_de_la_table_ronde.sg → examples/songs/chevaliers_de_la_table_ronde.tsg

0
examples/songs/example-en.sg → examples/songs/example-en.tsg

0
examples/songs/example-fr.sg → examples/songs/example-fr.tsg

0
examples/songs/greensleeves.sgc → examples/songs/greensleeves.csg

0
examples/songs/greensleeves.sg → examples/songs/greensleeves.tsg

0
examples/songs/tests/chords.sgc → examples/songs/tests/chords.csg

0
examples/songs/tests/errors.sgc → examples/songs/tests/errors.csg

0
examples/songs/tests/newline.sgc → examples/songs/tests/newline.csg

0
examples/songs/tests/nolyrics.sgc → examples/songs/tests/nolyrics.csg

0
examples/songs/vent_frais.sg → examples/songs/vent_frais.tsg

2
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

6
patacrep/files.py

@ -62,17 +62,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:

1
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:
# .sg file
if isinstance(songbook['datadir'], str):
songbook['datadir'] = [songbook['datadir']]
datadirs += [

10
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,
},
}

14
patacrep/songs/chordpro/syntax.py

@ -27,7 +27,7 @@ class ChordproParser(Parser):
write_tables=0,
)
def parse(self, content):
def parse(self, content, *, lexer):
"""Parse file
This is a shortcut to `yacc.yacc(...).parse()`. The arguments are
@ -309,9 +309,17 @@ class ChordproParser(Parser):
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):
"""Parse song and return its metadata."""
return ChordproParser(filename).parse(content)
parser = ChordproParser(filename)
parsed_content = parser.parse(
content,
lexer=ChordProLexer(filename=filename).lexer,
)
if parsed_content is None:
raise SyntaxError('Fatal error during song parsing: {}'.format(filename))
return parsed_content

4
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())
except NotImplementedError:
LOGGER.error("Cannot convert to format '%s'.", dest)

7
patacrep/songs/latex/__init__.py

@ -49,8 +49,11 @@ class Latex2LatexSong(Song):
self.lang = custom_lang
SONG_RENDERERS = {
"latex": {
'is': Latex2LatexSong,
"tsg": {
'tis': Latex2LatexSong,
'tsg': Latex2LatexSong,
# For backward compatibility
'sg': Latex2LatexSong,
},
}

0
test/test_chordpro/00.sgc → test/test_chordpro/00.csg

0
test/test_chordpro/00.source → test/test_chordpro/00.csg.source

0
test/test_chordpro/00.tex → test/test_chordpro/00.tsg

0
test/test_chordpro/01.sgc → test/test_chordpro/01.csg

0
test/test_chordpro/01.source → test/test_chordpro/01.csg.source

0
test/test_chordpro/01.tex → test/test_chordpro/01.tsg

0
test/test_chordpro/02.sgc → test/test_chordpro/02.csg

0
test/test_chordpro/02.source → test/test_chordpro/02.csg.source

0
test/test_chordpro/02.tex → test/test_chordpro/02.tsg

0
test/test_chordpro/03.sgc → test/test_chordpro/03.csg

0
test/test_chordpro/03.source → test/test_chordpro/03.csg.source

0
test/test_chordpro/03.tex → test/test_chordpro/03.tsg

0
test/test_chordpro/04.sgc → test/test_chordpro/04.csg

0
test/test_chordpro/04.source → test/test_chordpro/04.csg.source

0
test/test_chordpro/04.tex → test/test_chordpro/04.tsg

0
test/test_chordpro/05.sgc → test/test_chordpro/05.csg

0
test/test_chordpro/05.source → test/test_chordpro/05.csg.source

0
test/test_chordpro/05.tex → test/test_chordpro/05.tsg

0
test/test_chordpro/06.sgc → test/test_chordpro/06.csg

0
test/test_chordpro/06.source → test/test_chordpro/06.csg.source

0
test/test_chordpro/06.tex → test/test_chordpro/06.tsg

0
test/test_chordpro/07.sgc → test/test_chordpro/07.csg

0
test/test_chordpro/07.source → test/test_chordpro/07.csg.source

0
test/test_chordpro/07.tex → test/test_chordpro/07.tsg

0
test/test_chordpro/08.sgc → test/test_chordpro/08.csg

0
test/test_chordpro/08.source → test/test_chordpro/08.csg.source

0
test/test_chordpro/08.tex → test/test_chordpro/08.tsg

0
test/test_chordpro/09.sgc → test/test_chordpro/09.csg

0
test/test_chordpro/09.source → test/test_chordpro/09.csg.source

0
test/test_chordpro/09.tex → test/test_chordpro/09.tsg

0
test/test_chordpro/10.sgc → test/test_chordpro/10.csg

0
test/test_chordpro/10.source → test/test_chordpro/10.csg.source

0
test/test_chordpro/10.tex → test/test_chordpro/10.tsg

0
test/test_chordpro/11.sgc → test/test_chordpro/11.csg

0
test/test_chordpro/11.source → test/test_chordpro/11.csg.source

0
test/test_chordpro/11.tex → test/test_chordpro/11.tsg

0
test/test_chordpro/12.sgc → test/test_chordpro/12.csg

0
test/test_chordpro/12.source → test/test_chordpro/12.csg.source

0
test/test_chordpro/12.tex → test/test_chordpro/12.tsg

0
test/test_chordpro/13.sgc → test/test_chordpro/13.csg

0
test/test_chordpro/13.source → test/test_chordpro/13.csg.source

0
test/test_chordpro/13.tex → test/test_chordpro/13.tsg

0
test/test_chordpro/21.sgc → test/test_chordpro/21.csg

0
test/test_chordpro/21.source → test/test_chordpro/21.csg.source

0
test/test_chordpro/21.tex → test/test_chordpro/21.tsg

0
test/test_chordpro/22.sgc → test/test_chordpro/22.csg

0
test/test_chordpro/22.source → test/test_chordpro/22.csg.source

0
test/test_chordpro/22.tex → test/test_chordpro/22.tsg

0
test/test_chordpro/23.sgc → test/test_chordpro/23.csg

0
test/test_chordpro/23.source → test/test_chordpro/23.csg.source

0
test/test_chordpro/23.tex → test/test_chordpro/23.tsg

0
test/test_chordpro/24.sgc → test/test_chordpro/24.csg

0
test/test_chordpro/24.source → test/test_chordpro/24.csg.source

0
test/test_chordpro/24.tex → test/test_chordpro/24.tsg

0
test/test_chordpro/25.sgc → test/test_chordpro/25.csg

0
test/test_chordpro/25.source → test/test_chordpro/25.csg.source

0
test/test_chordpro/25.tex → test/test_chordpro/25.tsg

0
test/test_chordpro/26.sgc → test/test_chordpro/26.csg

0
test/test_chordpro/26.source → test/test_chordpro/26.csg.source

0
test/test_chordpro/26.tex → test/test_chordpro/26.tsg

0
test/test_chordpro/27.sgc → test/test_chordpro/27.csg

0
test/test_chordpro/27.source → test/test_chordpro/27.csg.source

0
test/test_chordpro/27.tex → test/test_chordpro/27.tsg

0
test/test_chordpro/28.sgc → test/test_chordpro/28.csg

0
test/test_chordpro/28.source → test/test_chordpro/28.csg.source

0
test/test_chordpro/28.tex → test/test_chordpro/28.tsg

0
test/test_chordpro/29.sgc → test/test_chordpro/29.csg

0
test/test_chordpro/29.source → test/test_chordpro/29.csg.source

0
test/test_chordpro/29.tex → test/test_chordpro/29.tsg

0
test/test_chordpro/author_names.sgc → test/test_chordpro/author_names.csg

0
test/test_chordpro/author_names.source → test/test_chordpro/author_names.csg.source

0
test/test_chordpro/author_names.tex → test/test_chordpro/author_names.tsg

0
test/test_chordpro/chords.sgc → test/test_chordpro/chords.csg

0
test/test_chordpro/chords.source → test/test_chordpro/chords.csg.source

0
test/test_chordpro/chords.tex → test/test_chordpro/chords.tsg

0
test/test_chordpro/customchords.sgc → test/test_chordpro/customchords.csg

0
test/test_chordpro/customchords.source → test/test_chordpro/customchords.csg.source

0
test/test_chordpro/customchords.tex → test/test_chordpro/customchords.tsg

3
test/test_chordpro/errors/invalid_content.csg.source

@ -0,0 +1,3 @@
{soc}
Chorus
{eoc

0
test/test_chordpro/greensleeves.sgc → test/test_chordpro/greensleeves.csg

0
test/test_chordpro/greensleeves.source → test/test_chordpro/greensleeves.csg.source

0
test/test_chordpro/greensleeves.tex → test/test_chordpro/greensleeves.tsg

0
test/test_chordpro/invalid_chord.sgc → test/test_chordpro/invalid_chord.csg

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save