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
self.config = {
'template': "default.tex",
'titleprefixwords': [],
'authwords': {},
'lang': 'french',
'lang': 'english',
'sort': [u"by", u"album", u"@title"],
'content': None,
'datadir': os.path.abspath('.'),
}
self.songslist = None
self._parse(raw_songbook)
self._set_songs_default()
def _set_songs_default(self):
"""Set the default values for the Song() class."""
Song.sort = self.config['sort']
Song.prefixes = self.config['titleprefixwords']
def _set_songs_default(self, config):
"""Set the default values for the Song() class.
Argument:
- config : a dictionary containing the configuration
"""
Song.sort = config['sort']
Song.prefixes = config['titleprefixwords']
Song.authwords['after'] = [
re.compile(r"^.*%s\b(.*)" % 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'] = [
re.compile(r"^(.*)%s (.*)$" % sep)
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.update(self.config)
context['titleprefixkeys'] = ["after", "sep", "ignore"]
context['songlist'] = self.songslist
context['filename'] = output.name[:-4]
self._set_songs_default(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}"}
},
"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)",
"french": "Options pour traiter les noms d'auteurs (commandes LaTeX 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)"},
"default": {"default": {}}
}
}
(* endvariables *)

7
songbook_core/data/templates/patacrep.tex

@ -32,7 +32,12 @@
"indexbgcolor": {"description": {"english": "Index Shade", "french": "Couleur d'index"},
"type": "color",
"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 *)

Loading…
Cancel
Save