1
0
Fork 0
mirror of https://github.com/kastdeur/pipeband-music.git synced 2024-12-23 00:33:31 +01:00

Title can be set for a set file

This commit is contained in:
Eric Teunis de Boone 2016-07-12 11:23:53 +02:00
parent ed9ba6aa0b
commit 55dad71d0e

View file

@ -6,7 +6,8 @@ from argparse import ArgumentParser
parser = ArgumentParser(__file__) parser = ArgumentParser(__file__)
parser.add_argument('setfile') parser.add_argument('setfile')
parser.add_argument('-c',dest='copy',action='store_true',default=False) parser.add_argument('-c',dest='copy',action='store_true',default=False,help="Copy files instead of just linkingi")
parser.add_argument('-t',dest='title',help="Title for the set")
parser.add_argument('scores',nargs='+') parser.add_argument('scores',nargs='+')
args = parser.parse_args() args = parser.parse_args()
@ -15,10 +16,30 @@ if os.path.isdir(args.setfile):
print("First argument cannot be a directory ") print("First argument cannot be a directory ")
sys.exit() sys.exit()
os.makedirs(os.path.dirname(args.setfile), exist_ok=True) if os.path.dirname(args.setfile):
fpoint = codecs.open(args.setfile, 'w+', 'utf8') os.makedirs(os.path.dirname(args.setfile), exist_ok=True)
fpoint.write(u'\ufeff')
fpoint.write('\\version \"2.18.2\"\n\n') if args.setfile == '--':
fprint = print
else:
fpoint = codecs.open(args.setfile, 'w+', 'utf8')
fprint = fpoint.write
fprint(u'\ufeff')
fprint('\\version \"2.18.2\"\n\n')
if args.title:
fprint(
"\header {"+
"title = \"" + args.title + "\""+
"}\n")
fprint(
"\paper {"+
"#(define page-breaking ly:minimal-breaking)" +
"}\n")
fprint("\n\n%Scores\n")
for f in args.scores: for f in args.scores:
@ -38,8 +59,8 @@ for f in args.scores:
incline = os.path.join(os.path.abspath(os.path.dirname(f)), incline) incline = os.path.join(os.path.abspath(os.path.dirname(f)), incline)
line = "\\include \""+incline+"\"" line = "\\include \""+incline+"\""
fpoint.write(line.replace('\r', '')+'\n') fprint(line.replace('\r', '')+'\n')
else: else:
fpoint.write('\\include \"' + os.path.join( os.path.abspath( os.curdir ) ,f) + '\"\n') fprint('\\include \"' + os.path.join( os.path.abspath( os.curdir ) ,f) + '\"\n')
fpoint.close() fpoint.close()