mirror of
https://github.com/kastdeur/pipeband-music.git
synced 2025-05-15 12:29:22 +02:00
Created script, for easier set creation
This commit is contained in:
parent
7f99754be7
commit
3d6f025aee
12 changed files with 121 additions and 72 deletions
45
make-set
Normal file
45
make-set
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/python3
|
||||
|
||||
## Script to easily generate a set (concatenated scores)
|
||||
|
||||
import codecs, os
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(__file__)
|
||||
parser.add_argument('setfile')
|
||||
parser.add_argument('-c',dest='copy',action='store_true',default=False)
|
||||
parser.add_argument('scores',nargs='+')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
os.makedirs(os.path.dirname(args.setfile), exist_ok=True)
|
||||
fpoint = codecs.open(args.setfile, 'w+', 'utf8')
|
||||
fpoint.write(u'\ufeff')
|
||||
fpoint.write('\\version \"2.18.2\"\n\n')
|
||||
|
||||
for f in args.scores:
|
||||
|
||||
if not os.path.exists(f):
|
||||
continue
|
||||
|
||||
if args.copy is True:
|
||||
text = codecs.open(f, 'r', 'utf8').read()
|
||||
if text.startswith(u'\ufeff'): text = text[1:]
|
||||
text = text.split(u'\n')
|
||||
|
||||
for line in text:
|
||||
if line.startswith(u'\\include'):
|
||||
incline = line.replace('\\include', '').strip('"\' ')
|
||||
|
||||
if not incline.startswith('\\'): #already absolute
|
||||
incline = os.path.join(os.path.abspath(os.path.dirname(f)), incline)
|
||||
|
||||
line = "\\include \""+incline+"\""
|
||||
fpoint.write(line.replace('\r', '')+'\n')
|
||||
else:
|
||||
fpoint.write('\\include \"' + os.path.join( os.path.abspath( os.curdir ) ,f) + '\"\n')
|
||||
|
||||
fpoint.close()
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue