mirror of https://github.com/patacrep/patacrep.git
Engine for LaTeX songbooks
http://www.patacrep.com
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.1 KiB
121 lines
2.1 KiB
15 years ago
|
#!/usr/bin/python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
15 years ago
|
# warning: lines beginning with ## are parsed by
|
||
|
# the songbook-client as rules categories
|
||
|
|
||
|
|
||
15 years ago
|
import glob
|
||
15 years ago
|
|
||
15 years ago
|
# the dictionary has target_word:replacement_word pairs
|
||
|
word_dic = {
|
||
15 years ago
|
##: oe inclusion
|
||
15 years ago
|
"coeur": "cœur",
|
||
|
"boeuf": "bœuf",
|
||
|
"oeuvre": "œuvre",
|
||
|
"soeur": "sœur",
|
||
|
"noeud": "nœud",
|
||
|
"oeil": "œil",
|
||
15 years ago
|
"voeu": "vœu",
|
||
14 years ago
|
"oeuf": "œuf",
|
||
15 years ago
|
"oe{}": "œ",
|
||
14 years ago
|
##: Contractions
|
||
|
"ptit": "p'tit",
|
||
15 years ago
|
##: Punctuation
|
||
15 years ago
|
"’": "'",
|
||
|
"Ca ": "Ça ",
|
||
14 years ago
|
"\\musicnote{Intro": "\\musicnote{intro",
|
||
|
"\\musicnote{Outro": "\\musicnote{outro",
|
||
15 years ago
|
"...": "\\dots ",
|
||
15 years ago
|
"…": "\\dots",
|
||
14 years ago
|
#replace tabs with two spaces
|
||
|
" ": " ",
|
||
15 years ago
|
##: Typo
|
||
|
"New-York": "New York",
|
||
14 years ago
|
" i ": " I ",
|
||
15 years ago
|
"avant hier": "avant-hier",
|
||
14 years ago
|
##: Conversion to anglo-saxon chords
|
||
|
"Lam ": "Am ",
|
||
|
"La7": "A7",
|
||
|
"Lasus2": "Asus2",
|
||
|
"Sim ": "Bm ",
|
||
|
"Sim}": "Bm}",
|
||
|
"Sim]": "Bm]",
|
||
|
"Si7": "B7",
|
||
|
"Dom ": "Cm ",
|
||
|
"Do7": "C7",
|
||
|
"Do9": "C9",
|
||
|
"Ré ": "D ",
|
||
|
"Rém ": "Dm ",
|
||
|
"Rém]": "Dm]",
|
||
|
"Ré7": "D7",
|
||
|
"Ré#": "D#",
|
||
|
"Mim ": "Em ",
|
||
|
"Mim]": "Em]",
|
||
|
"Mim7": "Em7",
|
||
|
"Mim}": "Em}",
|
||
|
"Mi7": "E7",
|
||
|
"Mi7sus4": "E7sus4",
|
||
|
"Fa ": "F ",
|
||
|
"Fa}": "F}",
|
||
|
"Fa\\": "F\\",
|
||
|
"Fam ": "Fm ",
|
||
|
"Fa7": "F7",
|
||
|
"Sol ": "G ",
|
||
|
"Sol]": "G]",
|
||
|
"Solm ": "Gm ",
|
||
|
"Solm]": "Gm]",
|
||
|
"Sol7": "G7",
|
||
|
"/La": "/A",
|
||
|
"/Si": "/B",
|
||
|
"/Do": "/C",
|
||
|
"/Ré": "/D",
|
||
|
"/Mi": "/E",
|
||
|
"/Fa": "/F",
|
||
|
"/Sol": "/G",
|
||
|
"gtab{La": "gtab{A",
|
||
|
"gtab{Si": "gtab{B",
|
||
|
"gtab{Do": "gtab{C",
|
||
|
"gtab{Ré": "gtab{D",
|
||
|
"gtab{Mi": "gtab{E",
|
||
|
"gtab{Fa": "gtab{F",
|
||
|
"gtab{Sol": "gtab{G",
|
||
|
"\\[La": "\\[A",
|
||
|
"\\[Si": "\\[B",
|
||
|
"\\[Do": "\\[C",
|
||
|
"\\[Ré": "\\[D",
|
||
|
"\\[Mi": "\\[E",
|
||
|
"\\[Fa": "\\[F",
|
||
|
"\\[Sol": "\\[G",
|
||
|
"\\[Re": "\\[D",
|
||
15 years ago
|
"b]": "&]",
|
||
14 years ago
|
"b7]": "&7]",
|
||
|
#C
|
||
15 years ago
|
"032010": "X32010",
|
||
14 years ago
|
#A
|
||
15 years ago
|
"002220": "X02220",
|
||
|
"002020": "X02020",
|
||
|
"002210": "X02210",
|
||
14 years ago
|
#D
|
||
15 years ago
|
"000232": "XX0232",
|
||
|
"X00232": "XX0232",
|
||
|
"000212": "XX0212",
|
||
|
"000231": "XX0231",
|
||
|
"X00231": "XX0231",
|
||
14 years ago
|
#B
|
||
15 years ago
|
"021202": "X21202",
|
||
15 years ago
|
### end of rules
|
||
15 years ago
|
}
|
||
|
|
||
|
# Process song files
|
||
|
songfiles = glob.glob('songs/*/*.sg')
|
||
15 years ago
|
for filename in songfiles:
|
||
|
with open(filename, 'r+') as songfile:
|
||
|
data = songfile.read()
|
||
|
for search, replace in word_dic.items():
|
||
|
data = data.replace(search, replace)
|
||
|
songfile.seek(0)
|
||
|
songfile.write(data)
|
||
|
songfile.truncate()
|
||
|
|