mirror of
https://github.com/kastdeur/bwwtolily.git
synced 2024-11-24 20:53:33 +01:00
Hella refactored some shit
This commit is contained in:
parent
01ea98f703
commit
dce0309a22
1 changed files with 372 additions and 369 deletions
21
bwwtolily.py
21
bwwtolily.py
|
@ -7,11 +7,17 @@ GPL v3
|
|||
from optparse import OptionParser
|
||||
import sys,os,re,subprocess
|
||||
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
|
||||
#make a print function to handle various version of python
|
||||
def do_print(string):
|
||||
try:
|
||||
eval("print "+string)
|
||||
except:
|
||||
print(string)
|
||||
|
||||
#define the class that will convert a bww file to a lilypond file
|
||||
class bwwtolily :
|
||||
|
||||
def __init__(self,addmidi=False):
|
||||
self.tune_elements = []
|
||||
self.most_recent_note = 0
|
||||
|
@ -72,7 +78,6 @@ class bwwtolily :
|
|||
else:
|
||||
self.lily_midi=''
|
||||
|
||||
|
||||
def set_file(self,file_path):
|
||||
#determine the absolute path to the file
|
||||
abs_file = os.path.join(os.getcwd(),file_path)
|
||||
|
@ -88,8 +93,9 @@ class bwwtolily :
|
|||
|
||||
def quit(self,string=""):
|
||||
if string!="":
|
||||
print string
|
||||
do_print( string)
|
||||
sys.exit()
|
||||
|
||||
def parse(self):
|
||||
'''reate a string that represents the converted
|
||||
contents of the file'''
|
||||
|
@ -150,8 +156,6 @@ class bwwtolily :
|
|||
elements = tune_notes.split()
|
||||
for element in elements:
|
||||
self.transpose(element)
|
||||
#print self.tune_notes
|
||||
|
||||
|
||||
def lilynote(self,bwwname):
|
||||
#convert a bww notename to a lilypond notename
|
||||
|
@ -308,10 +312,9 @@ class bwwtolily :
|
|||
self.tune_elements.append(dict_result)
|
||||
return
|
||||
except:
|
||||
print "unparsed: "+element
|
||||
do_print( "unparsed: "+element)
|
||||
return
|
||||
|
||||
|
||||
#handle writing the output
|
||||
def create_output_file(self):
|
||||
#determine the output file
|
||||
|
@ -389,7 +392,7 @@ if __name__ == "__main__" :
|
|||
#parse the args
|
||||
(options, args) = parser.parse_args()
|
||||
if options.version:
|
||||
print "bwwtolily: ",version
|
||||
do_print( "bwwtolily: ",version)
|
||||
sys.exit()
|
||||
|
||||
if options.input!=None:
|
||||
|
|
Loading…
Reference in a new issue