1
0
Fork 0
mirror of https://github.com/kastdeur/bwwtolily.git synced 2024-11-24 20:53:33 +01:00

Readability: Fixed some indentation and missing newlines

This commit is contained in:
Eric Teunis de Boone 2018-10-28 02:06:53 +01:00
parent 3996b9f38e
commit bb079e8b02

View file

@ -2,12 +2,13 @@
# #
#bwwtolily: will convert a bww file to a lilypond file #bwwtolily: will convert a bww file to a lilypond file
#copyright: 2008 Jezra Lickter #copyright: 2008 Jezra Lickter
#contributions by ET de Boone
#GPL v3 #GPL v3
from argparse import ArgumentParser from argparse import ArgumentParser
import sys,os,re,subprocess import sys,os,re,subprocess
version = "0.5.2" version = "0.6.2"
#make a print function to handle various version of python #make a print function to handle various version of python
def do_print(string): def do_print(string):
@ -114,7 +115,7 @@ class bwwtolily :
sys.exit() sys.exit()
def parse(self): def parse(self):
'''reate a string that represents the converted '''create a string that represents the converted
contents of the file''' contents of the file'''
#open the file read only #open the file read only
file_handle = open(self.original_file,"r") file_handle = open(self.original_file,"r")
@ -170,7 +171,7 @@ class bwwtolily :
return lilynote return lilynote
def transpose(self,element): def transpose(self,element):
#receive a bww element and return a lilypond equivelent #receive a bww element and return a lilypond equivalent
#is the element a note? #is the element a note?
note_result = self.regex_note_info.search(element) note_result = self.regex_note_info.search(element)
@ -197,48 +198,56 @@ class bwwtolily :
self.most_recent_note-=1 self.most_recent_note-=1
self.tune_elements.append("]") self.tune_elements.append("]")
return return
#is the element a grace note? #is the element a grace note?
grace_result=self.regex_grace_note.search(element) grace_result=self.regex_grace_note.search(element)
if grace_result: if grace_result:
grace = "\\gr"+self.lilynote( grace_result.group(1) ) grace = "\\gr"+self.lilynote( grace_result.group(1) )
self.tune_elements.append(grace) self.tune_elements.append(grace)
return return
#is the element an echo beat? #is the element an echo beat?
echo_beat_result=self.regex_echo_beat.search(element) echo_beat_result=self.regex_echo_beat.search(element)
if echo_beat_result: if echo_beat_result:
echo_beat = "\\echo"+self.lilynote( echo_beat_result.group(1) ) echo_beat = "\\echo"+self.lilynote( echo_beat_result.group(1) )
self.tune_elements.append(echo_beat) self.tune_elements.append(echo_beat)
return return
#is the element a doubling? #is the element a doubling?
doubling_result=self.regex_doubling.search(element) doubling_result=self.regex_doubling.search(element)
if doubling_result: if doubling_result:
doubling = "\\dbl"+self.lilynote( doubling_result.group(1) ) doubling = "\\dbl"+self.lilynote( doubling_result.group(1) )
self.tune_elements.append(doubling) self.tune_elements.append(doubling)
return return
#is the element a half doubling? #is the element a half doubling?
hdoubling_result=self.regex_half_doubling.search(element) hdoubling_result=self.regex_half_doubling.search(element)
if hdoubling_result: if hdoubling_result:
half_doubling = "\\hdbl"+self.lilynote( hdoubling_result.group(1) ) half_doubling = "\\hdbl"+self.lilynote( hdoubling_result.group(1) )
self.tune_elements.append(half_doubling) self.tune_elements.append(half_doubling)
return return
#is the element a pele? #is the element a pele?
pele_result=self.regex_pele.search(element) pele_result=self.regex_pele.search(element)
if pele_result: if pele_result:
pele = "\\pel"+self.lilynote( pele_result.group(1) ) pele = "\\pel"+self.lilynote( pele_result.group(1) )
self.tune_elements.append(pele) self.tune_elements.append(pele)
return return
#is the element a thumb pele? #is the element a thumb pele?
tpele_result=self.regex_thumb_pele.search(element) tpele_result=self.regex_thumb_pele.search(element)
if tpele_result: if tpele_result:
tpele = "\\tpel"+self.lilynote( tpele_result.group(1) ) tpele = "\\tpel"+self.lilynote( tpele_result.group(1) )
self.tune_elements.append(tpele) self.tune_elements.append(tpele)
return return
#is the element a hpele? #is the element a hpele?
hpele_result=self.regex_half_pele.search(element) hpele_result=self.regex_half_pele.search(element)
if hpele_result: if hpele_result:
hpele = "\\hpel"+self.lilynote( hpele_result.group(1) ) hpele = "\\hpel"+self.lilynote( hpele_result.group(1) )
self.tune_elements.append(hpele) self.tune_elements.append(hpele)
return return
#is the element a strike? #is the element a strike?
strike_result=self.regex_strike.search(element) strike_result=self.regex_strike.search(element)
if strike_result: if strike_result:
@ -257,6 +266,7 @@ class bwwtolily :
strike = "\\gra" strike = "\\gra"
self.tune_elements.append(strike) self.tune_elements.append(strike)
return return
#is the element a dot? #is the element a dot?
dot_result=self.regex_dot.search(element) dot_result=self.regex_dot.search(element)
if dot_result: if dot_result:
@ -274,9 +284,11 @@ class bwwtolily :
#get the matching elements #get the matching elements
note_count = slur_result.group("note_count") note_count = slur_result.group("note_count")
end_note = slur_result.group("end_note") end_note = slur_result.group("end_note")
#get the length of the slur as an integer #get the length of the slur as an integer
slur_len = int(note_count) slur_len = int(note_count)
'''find the position of the note that is slur_len from the end''' '''find the position of the note that is slur_len from the end'''
#get the tune_elements lenght #get the tune_elements lenght
elem_index = len(self.tune_elements)-1 elem_index = len(self.tune_elements)-1
note_count = 0 note_count = 0
@ -295,6 +307,7 @@ class bwwtolily :
#add the slur end #add the slur end
self.tune_elements.append(")") self.tune_elements.append(")")
return return
#is this a bww tie slur? #is this a bww tie slur?
if element == "^ts": if element == "^ts":
self.slur_tie_pending = True self.slur_tie_pending = True