Browse Source

Merge branch 'master' into tag

pull/148/head
Louis 9 years ago
parent
commit
e07ad75b7d
  1. 2
      examples/songs/chevaliers_de_la_table_ronde.sg
  2. 2
      examples/songs/example-en.sg
  3. 2
      examples/songs/example-fr.sg
  4. 2
      examples/songs/greensleeves.sg
  5. 2
      examples/songs/vent_frais.sg
  6. 2
      patacrep/data/latex/patacrep.sty
  7. 2
      patacrep/songs/chordpro/__init__.py
  8. 30
      patacrep/songs/chordpro/ast.py
  9. 4
      patacrep/songs/chordpro/data/chordpro/song_header
  10. 12
      patacrep/songs/chordpro/data/latex/song
  11. 2
      test/test_chordpro/greensleeves.sgc
  12. 2
      test/test_chordpro/greensleeves.tex
  13. 1
      test/test_chordpro/invalid_directive.sgc
  14. 2
      test/test_chordpro/invalid_directive.source
  15. 10
      test/test_chordpro/invalid_directive.tex
  16. 2
      test/test_chordpro/metadata.sgc
  17. 2
      test/test_chordpro/metadata.tex
  18. 8
      test/test_compilation/datadir.tex.control
  19. 2
      test/test_compilation/datadir_datadir/songs/datadir.sg
  20. 2
      test/test_compilation/datadir_datadir/songs/datadir2.sg
  21. 2
      test/test_compilation/datadir_datadir/songs/relative.sg
  22. 2
      test/test_compilation/datadir_datadir/songs/subdir/subdir.sg

2
examples/songs/chevaliers_de_la_table_ronde.sg

@ -1,7 +1,7 @@
\selectlanguage{french}
\songcolumns{2}
\beginsong{Chevaliers de la table ronde}
[by={Traditionnel},cov={traditionnel},album={France}]
[by={Traditionnel},cover={traditionnel},album={France}]
\cover
\gtab{C}{X32010}

2
examples/songs/example-en.sg

@ -24,7 +24,7 @@
% traditionnel : the file "8-bit-lagerfeuer.jpg" that corresponds to the album art
% 8 bit lagerfeuer : the album whose song is extracted from
\beginsong{Sad robot}
[by={Pornophonique},cov={traditionnel},album={8 bit lagerfeuer}]
[by={Pornophonique},cover={traditionnel},album={8 bit lagerfeuer}]
% inserts the album art (8-bit-lagerfeuer.jpg)
\cover

2
examples/songs/example-fr.sg

@ -26,7 +26,7 @@
% traditionnel : le fichier "8-bit-lagerfeuer.jpg" correspondant à la pochette de l'album
% 8 bit lagerfeuer : le nom de l'album dont la chanson est extraite
\beginsong{Sad robot}
[by={Pornophonique},cov={traditionnel},album={8 bit lagerfeuer}]
[by={Pornophonique},cover={traditionnel},album={8 bit lagerfeuer}]
% insère la pochette de l'album (8-bit-lagerfeuer.jpg)
\cover

2
examples/songs/greensleeves.sg

@ -1,7 +1,7 @@
\selectlanguage{english}
\songcolumns{2}
\beginsong{Greensleeves}
[by={Traditionnel},cov={traditionnel},album={Angleterre}]
[by={Traditionnel},cover={traditionnel},album={Angleterre}]
\cover
\gtab{Am}{X02210}

2
examples/songs/vent_frais.sg

@ -1,7 +1,7 @@
\selectlanguage{french}
\songcolumns{2}
\beginsong{Vent frais}
[by={Traditionnel},cov={traditionnel},album={France}]
[by={Traditionnel},cover={traditionnel},album={France}]
\cover
\gtab{Dm}{XX0231}

2
patacrep/data/latex/patacrep.sty

@ -139,7 +139,7 @@
\setlength{\coverspace}{0.1cm}
\newcommand{\songcover}{}
\newcommand{\songalbum}{}
\newsongkey{cov}{\let\songcover\@empty}{\def\songcover{#1}}
\newsongkey{cover}{\let\songcover\@empty}{\def\songcover{#1}}
\newsongkey{album}{\let\songalbum\@empty}{\def\songalbum{#1}}
\newsongkey{url}{\let\songurl\@empty}{\def\songurl{#1}}
\newsongkey{original}{\let\songoriginal\@empty}{\def\songoriginal{#1}}

2
patacrep/songs/chordpro/__init__.py

@ -31,7 +31,7 @@ class ChordproSong(Song):
song = parse_song(song.read(), self.fullpath)
self.authors = song.authors
self.titles = song.titles
self.lang = song.get_data_argument('lang', self.config['lang'])
self.lang = song.get_data_argument('language', self.config['lang'])
self.data = song.meta
self.cached = {
'song': song,

30
patacrep/songs/chordpro/ast.py

@ -11,6 +11,27 @@ def _indent(string):
"""Return and indented version of argument."""
return "\n".join([" {}".format(line) for line in string.split('\n')])
#: Available directives, that is, directives that we know how to deal with
AVAILABLE_DIRECTIVES = [
"album",
"artist",
"capo",
"comment",
"copyright",
"columns",
"cov",
"define",
"guitar_comment",
"image",
"key",
"language",
"newline",
"partition",
"subtitle",
"tag",
"title",
]
#: List of properties that are to be displayed in the flow of the song (not as
#: metadata at the beginning or end of song.
INLINE_DIRECTIVES = {
@ -30,8 +51,8 @@ DIRECTIVE_SHORTCUTS = {
"by": "artist",
"c": "comment",
"gc": "guitar_comment",
"cover": "cov",
"language": "lang",
"cov": "cover",
"lang": "language",
}
def directive_name(text):
@ -208,6 +229,7 @@ class Song(AST):
def add(self, data):
"""Add an element to the song"""
# pylint: disable=too-many-branches
if isinstance(data, Error):
pass
elif data is None:
@ -222,6 +244,8 @@ class Song(AST):
self.content[0].prepend(data.strip())
elif isinstance(data, Directive) and data.inline:
# Add a directive in the content of the song.
# It is useless to check if directive is in AVAILABLE_DIRECTIVES,
# since it is in INLINE_DIRECTIVES.
self.content.append(data)
elif data.inline:
# Add an object in the content of the song.
@ -229,6 +253,8 @@ class Song(AST):
elif isinstance(data, Directive):
# Add a metadata directive. Some of them are added using special
# methods listed in ``METADATA_ADD``.
if data.keyword not in AVAILABLE_DIRECTIVES:
LOGGER.warning("Ignoring unknown directive '{}'.".format(data.keyword))
if data.keyword in self.METADATA_ADD:
getattr(self, self.METADATA_ADD[data.keyword])(data)
else:

4
patacrep/songs/chordpro/data/chordpro/song_header

@ -21,8 +21,8 @@
{(( key )): (( metadata[key] ))}
(* endif *)
(* endfor *)
(* if 'cov' in metadata -*)
{(( 'cov' )): (( metadata['cov'].argument|search_image ))}
(* if 'cover' in metadata -*)
{(( 'cover' )): (( metadata['cover'].argument|search_image ))}
(* endif -*)
(* for tag in metadata.get("tag", [])|sortargs -*)

12
patacrep/songs/chordpro/data/latex/song

@ -27,11 +27,11 @@
(( key ))={(( metadata[key] ))},
(* endif *)
(* endfor *)
(* if 'cov' in metadata *)
(* block cov *)
(* set cov = metadata["cov"].argument|search_image *)
(* if cov *)
cov={(( cov ))},
(* if 'cover' in metadata *)
(* block cover *)
(* set cover = metadata["cover"].argument|search_image *)
(* if cover *)
cover={(( cover ))},
(* endif *)
(* endblock *)
(* endif *)
@ -40,7 +40,7 @@
(* endfor *)
]
(* if (metadata.cov is defined) *)
(* if (metadata.cover is defined) *)
\cover
(* endif *)

2
test/test_chordpro/greensleeves.sgc

@ -5,7 +5,7 @@
{title: Un sous titre}
{artist: Traditionnel}
{album: Angleterre}
{cov: traditionnel}
{cover: traditionnel}
{partition: greensleeves.ly}

2
test/test_chordpro/greensleeves.tex

@ -7,7 +7,7 @@ Un sous titre}[
by={
Traditionnel },
album={Angleterre},
cov={img/traditionnel},
cover={img/traditionnel},
]
\cover

1
test/test_chordpro/invalid_directive.sgc

@ -0,0 +1 @@
{lang: en}

2
test/test_chordpro/invalid_directive.source

@ -0,0 +1,2 @@
{foo: bar}
{bar}

10
test/test_chordpro/invalid_directive.tex

@ -0,0 +1,10 @@
\selectlanguage{english}
\beginsong{}[
by={
},
]
\endsong

2
test/test_chordpro/metadata.sgc

@ -10,7 +10,7 @@
{artist: Texte de Jean Richepin, chanté par Georges Brassens}
{album: Album}
{copyright: Copyright}
{cov: metadata_cover}
{cover: metadata_cover}
{key: foo: Foo}
{comment: Comment}

2
test/test_chordpro/metadata.tex

@ -11,7 +11,7 @@ Subtitle5}[
Texte de Jean Richepin, chanté par Georges Brassens },
album={Album},
copyright={Copyright},
cov={img/test/test_chordpro/metadata_cover},
cover={img/test/test_chordpro/metadata_cover},
foo={Foo},
]

8
test/test_compilation/datadir.tex.control

@ -103,7 +103,7 @@ guitar,
Chordpro}[
by={
},
cov={img/datadir.png},
cover={img/datadir.png},
]
\cover
@ -130,7 +130,7 @@ Chordpro}[
Chordpro}[
by={
},
cov={img/datadir2.png},
cover={img/datadir2.png},
]
\cover
@ -157,7 +157,7 @@ Chordpro}[
Chordpro}[
by={
},
cov={@TEST_FOLDER@/datadir_datadir/songs/./relative.png},
cover={@TEST_FOLDER@/datadir_datadir/songs/./relative.png},
]
\cover
@ -184,7 +184,7 @@ Chordpro}[
Chordpro}[
by={
},
cov={@TEST_FOLDER@/datadir_datadir/songs/./subdir/subdir.png},
cover={@TEST_FOLDER@/datadir_datadir/songs/./subdir/subdir.png},
]
\cover

2
test/test_compilation/datadir_datadir/songs/datadir.sg

@ -1,5 +1,5 @@
\beginsong{Image included from datadir\\\LaTeX}
[cov={img/datadir}]
[cover={img/datadir}]
\cover

2
test/test_compilation/datadir_datadir/songs/datadir2.sg

@ -1,5 +1,5 @@
\beginsong{Image included from a different datadir\\\LaTeX}
[cov={img/datadir2}]
[cover={img/datadir2}]
\cover

2
test/test_compilation/datadir_datadir/songs/relative.sg

@ -1,5 +1,5 @@
\beginsong{Image included from song directory\\\LaTeX}
[cov={relative}]
[cover={relative}]
\cover

2
test/test_compilation/datadir_datadir/songs/subdir/subdir.sg

@ -1,5 +1,5 @@
\beginsong{Image included from a nested song directory\\\LaTeX}
[cov={subdir}]
[cover={subdir}]
\cover

Loading…
Cancel
Save