Browse Source

Changement de la valeur par défaut de titleprefixwords

fix #18
pull/27/head
Luthaf 11 years ago
parent
commit
cd0d0ae0a5
  1. 26
      songbook_core/build.py
  2. 8
      songbook_core/data/templates/default.tex
  3. 7
      songbook_core/data/templates/patacrep.tex

26
songbook_core/build.py

@ -41,31 +41,32 @@ class Songbook(object):
# Default values: will be updated while parsing raw_songbook # Default values: will be updated while parsing raw_songbook
self.config = { self.config = {
'template': "default.tex", 'template': "default.tex",
'titleprefixwords': [], 'lang': 'english',
'authwords': {},
'lang': 'french',
'sort': [u"by", u"album", u"@title"], 'sort': [u"by", u"album", u"@title"],
'content': None, 'content': None,
'datadir': os.path.abspath('.'), 'datadir': os.path.abspath('.'),
} }
self.songslist = None self.songslist = None
self._parse(raw_songbook) self._parse(raw_songbook)
self._set_songs_default()
def _set_songs_default(self): def _set_songs_default(self, config):
"""Set the default values for the Song() class.""" """Set the default values for the Song() class.
Song.sort = self.config['sort']
Song.prefixes = self.config['titleprefixwords'] Argument:
- config : a dictionary containing the configuration
"""
Song.sort = config['sort']
Song.prefixes = config['titleprefixwords']
Song.authwords['after'] = [ Song.authwords['after'] = [
re.compile(r"^.*%s\b(.*)" % after) re.compile(r"^.*%s\b(.*)" % after)
for after for after
in self.config['authwords']["after"] in config['authwords']["after"]
] ]
Song.authwords['ignore'] = self.config['authwords']['ignore'] Song.authwords['ignore'] = config['authwords']['ignore']
Song.authwords['sep'] = [ Song.authwords['sep'] = [
re.compile(r"^(.*)%s (.*)$" % sep) re.compile(r"^(.*)%s (.*)$" % sep)
for sep in ([ for sep in ([
" %s" % sep for sep in self.config['authwords']["sep"] " %s" % sep for sep in config['authwords']["sep"]
] + [',']) ] + [','])
] ]
@ -112,12 +113,13 @@ class Songbook(object):
) )
context = renderer.get_variables() context = renderer.get_variables()
context.update(self.config) context.update(self.config)
context['titleprefixkeys'] = ["after", "sep", "ignore"] context['titleprefixkeys'] = ["after", "sep", "ignore"]
context['songlist'] = self.songslist context['songlist'] = self.songslist
context['filename'] = output.name[:-4] context['filename'] = output.name[:-4]
self._set_songs_default(context)
renderer.render_tex(output, context) renderer.render_tex(output, context)

8
songbook_core/data/templates/default.tex

@ -52,10 +52,12 @@
"default": {"default": "\\begin{flushright}Generated using Songbook (\\url{http://www.patacrep.com})\\end{flushright}"} "default": {"default": "\\begin{flushright}Generated using Songbook (\\url{http://www.patacrep.com})\\end{flushright}"}
}, },
"titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles", "titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles",
"french": "Ignore des mots dans le classement des chansons"} "french": "Ignore des mots dans le classement des chansons"},
"default": {"default": []}
}, },
"authwords": {"descriptipn": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)", "authwords": {"description": {"english": "Set of options to process author string (LaTeX commands authsepword, authignoreword, authbyword)",
"french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"} "french": "Options pour traiter les noms d'auteurs (commandes LaTeX authsepword, authignoreword, authbyword)"},
"default": {"default": {}}
} }
} }
(* endvariables *) (* endvariables *)

7
songbook_core/data/templates/patacrep.tex

@ -32,7 +32,12 @@
"indexbgcolor": {"description": {"english": "Index Shade", "french": "Couleur d'index"}, "indexbgcolor": {"description": {"english": "Index Shade", "french": "Couleur d'index"},
"type": "color", "type": "color",
"default": {"default": "D1E4AE"} "default": {"default": "D1E4AE"}
} },
"titleprefixwords": {"description": {"english": "Ignore some words in the beginning of song titles",
"french": "Ignore des mots dans le classement des chansons"},
"default": {"default": ["The", "Le", "La", "L'", "A", "Au", "Ces", "De",
"Des", "El", "Les", "Ma", "Mon", "Un"]}
}
} }
(* endvariables *) (* endvariables *)

Loading…
Cancel
Save