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.
49 lines
917 B
49 lines
917 B
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import glob
|
|
|
|
# the dictionary has target_word:replacement_word pairs
|
|
word_dic = {
|
|
#oe inclusion
|
|
"coeur": "cœur",
|
|
"boeuf": "bœuf",
|
|
"oeuvre": "œuvre",
|
|
"soeur": "sœur",
|
|
"noeud": "nœud",
|
|
"oeil": "œil",
|
|
"oe{}": "œ",
|
|
#punctuation
|
|
"’": "'",
|
|
"Ca ": "Ça ",
|
|
"...": "\\dots ",
|
|
#Chords
|
|
"\\[Re]": "\\[Ré]",
|
|
"b]": "&]",
|
|
#Do
|
|
"032010": "X32010",
|
|
#La
|
|
"002220": "X02220",
|
|
"002020": "X02020",
|
|
"002210": "X02210",
|
|
#Ré
|
|
"000232": "XX0232",
|
|
"X00232": "XX0232",
|
|
"000212": "XX0212",
|
|
"000231": "XX0231",
|
|
"X00231": "XX0231",
|
|
#Si
|
|
"021202": "X21202",
|
|
}
|
|
|
|
# Process song files
|
|
songfiles = glob.glob('songs/*/*.sg')
|
|
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()
|
|
|
|
|