1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#! /usr/bin/python3 -O
# -*- python -*-
# Songwrite 3
# Copyright (C) 2001-2016 Jean-Baptiste LAMY -- jibalamy@free.fr
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, os, os.path
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), "..", "share"))
#if os.path.dirname(sys.argv[0]).endswith("bin"): # /usr/{local/}bin
# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..", "share")))
#else: # Raw source not installed
# sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")))
import editobj3
editobj3.GUI = "Qt"
import songwrite3.globdef
import songwrite3.model as model
import songwrite3.plugins
songwrite3.plugins.load_all_plugins()
import songwrite3.__editobj3__
import songwrite3.main
i = 1
create_new = 1
mainloop = 0
task = None
output = output_filename = None
songs = []
songbook = None
while i < len(sys.argv):
arg = sys.argv[i]
if arg == "--version":
create_new = 0
print("Songwrite 3 version %s" % model.VERSION)
elif arg == "--help":
create_new = 0
print("""Songwrite 3 -- A music, score, tablature, fingering and lyrics editor by Jiba (jiba""" + chr(64) + """lesfleursdunormal""" + chr(46) + """fr)
Usage:
songwrite3 <file>...
--version
--help
--import <format> <input-file>
--export <format> <output-file>
--script <python script>
Supported import format: %s.
Supported export format: %s.""" % (", ".join(songwrite3.plugins.IMPORT_FORMATS), ", ".join(songwrite3.plugins.EXPORT_FORMATS)))
elif arg == "--import":
songs.append(songwrite3.plugins.get_importer(sys.argv[i + 1]).import_from(sys.argv[i + 2]))
i += 2
elif arg == "--export":
for song in songs:
songwrite3.plugins.get_exporter(sys.argv[i + 1]).export_to(song, sys.argv[i + 2])
i += 2
songs = []
create_new = 0
elif arg == "--script" :
script = sys.argv[i + 1]
song = songs[-1]
exec(script)
i += 1
elif arg == "--config" :
songwrite3.globdef.CONFIGFILE = sys.argv[i + 1]
songwrite3.globdef.config.__init__()
i += 1
else: # It's a filename
song = model.get_song(arg)
if isinstance(song, model.Songbook):
songbook = song
else:
create_new = 0
songs.append(song)
i += 1
if songs or create_new:
import songwrite3.pipe
piped = False
if songwrite3.pipe.is_already_running(): # Try the pipe !
commands = ["open %s" % song.filename for song in songs]
if not commands: commands = ["new song"]
for command in commands:
if not songwrite3.pipe.send(command):
break
else: piped = True
if not piped:
songwrite3.pipe.create()
songwrite3.pipe.listen()
if songs:
import songwrite3.main as main
for o in songs:
main.App(o)
main.mainloop()
elif create_new:
import songwrite3.main as main
app = main.App()
if songbook:
app.set_songbook(songbook)
app.on_songbook_prop()
main.mainloop()
|