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} \selectlanguage{french}
\songcolumns{2} \songcolumns{2}
\beginsong{Chevaliers de la table ronde} \beginsong{Chevaliers de la table ronde}
[by={Traditionnel},cov={traditionnel},album={France}] [by={Traditionnel},cover={traditionnel},album={France}]
\cover \cover
\gtab{C}{X32010} \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 % traditionnel : the file "8-bit-lagerfeuer.jpg" that corresponds to the album art
% 8 bit lagerfeuer : the album whose song is extracted from % 8 bit lagerfeuer : the album whose song is extracted from
\beginsong{Sad robot} \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) % inserts the album art (8-bit-lagerfeuer.jpg)
\cover \cover

2
examples/songs/example-fr.sg

@ -26,7 +26,7 @@
% traditionnel : le fichier "8-bit-lagerfeuer.jpg" correspondant à la pochette de l'album % 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 % 8 bit lagerfeuer : le nom de l'album dont la chanson est extraite
\beginsong{Sad robot} \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) % insère la pochette de l'album (8-bit-lagerfeuer.jpg)
\cover \cover

2
examples/songs/greensleeves.sg

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

2
examples/songs/vent_frais.sg

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

2
patacrep/data/latex/patacrep.sty

@ -139,7 +139,7 @@
\setlength{\coverspace}{0.1cm} \setlength{\coverspace}{0.1cm}
\newcommand{\songcover}{} \newcommand{\songcover}{}
\newcommand{\songalbum}{} \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{album}{\let\songalbum\@empty}{\def\songalbum{#1}}
\newsongkey{url}{\let\songurl\@empty}{\def\songurl{#1}} \newsongkey{url}{\let\songurl\@empty}{\def\songurl{#1}}
\newsongkey{original}{\let\songoriginal\@empty}{\def\songoriginal{#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) song = parse_song(song.read(), self.fullpath)
self.authors = song.authors self.authors = song.authors
self.titles = song.titles 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.data = song.meta
self.cached = { self.cached = {
'song': song, 'song': song,

30
patacrep/songs/chordpro/ast.py

@ -11,6 +11,27 @@ def _indent(string):
"""Return and indented version of argument.""" """Return and indented version of argument."""
return "\n".join([" {}".format(line) for line in string.split('\n')]) 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 #: List of properties that are to be displayed in the flow of the song (not as
#: metadata at the beginning or end of song. #: metadata at the beginning or end of song.
INLINE_DIRECTIVES = { INLINE_DIRECTIVES = {
@ -30,8 +51,8 @@ DIRECTIVE_SHORTCUTS = {
"by": "artist", "by": "artist",
"c": "comment", "c": "comment",
"gc": "guitar_comment", "gc": "guitar_comment",
"cover": "cov", "cov": "cover",
"language": "lang", "lang": "language",
} }
def directive_name(text): def directive_name(text):
@ -208,6 +229,7 @@ class Song(AST):
def add(self, data): def add(self, data):
"""Add an element to the song""" """Add an element to the song"""
# pylint: disable=too-many-branches
if isinstance(data, Error): if isinstance(data, Error):
pass pass
elif data is None: elif data is None:
@ -222,6 +244,8 @@ class Song(AST):
self.content[0].prepend(data.strip()) self.content[0].prepend(data.strip())
elif isinstance(data, Directive) and data.inline: elif isinstance(data, Directive) and data.inline:
# Add a directive in the content of the song. # 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) self.content.append(data)
elif data.inline: elif data.inline:
# Add an object in the content of the song. # Add an object in the content of the song.
@ -229,6 +253,8 @@ class Song(AST):
elif isinstance(data, Directive): elif isinstance(data, Directive):
# Add a metadata directive. Some of them are added using special # Add a metadata directive. Some of them are added using special
# methods listed in ``METADATA_ADD``. # 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: if data.keyword in self.METADATA_ADD:
getattr(self, self.METADATA_ADD[data.keyword])(data) getattr(self, self.METADATA_ADD[data.keyword])(data)
else: else:

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

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

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

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

2
test/test_chordpro/greensleeves.sgc

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

2
test/test_chordpro/greensleeves.tex

@ -7,7 +7,7 @@ Un sous titre}[
by={ by={
Traditionnel }, Traditionnel },
album={Angleterre}, album={Angleterre},
cov={img/traditionnel}, cover={img/traditionnel},
] ]
\cover \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} {artist: Texte de Jean Richepin, chanté par Georges Brassens}
{album: Album} {album: Album}
{copyright: Copyright} {copyright: Copyright}
{cov: metadata_cover} {cover: metadata_cover}
{key: foo: Foo} {key: foo: Foo}
{comment: Comment} {comment: Comment}

2
test/test_chordpro/metadata.tex

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

8
test/test_compilation/datadir.tex.control

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save