sforkowany z mirror/rnsutils
1
0
Forkuj 0

Add xrni comment command line utility

master
Olivier Jolly 2016-02-02 11:06:23 +01:00
rodzic 04ef45597a
commit 1245ab151b
3 zmienionych plików z 90 dodań i 1 usunięć

Wyświetl plik

@ -173,7 +173,10 @@ class RenoiseInstrument(object):
@property
def comment(self):
return "\n".join(self.root.GlobalProperties.Comments.Comment)
try:
return "\n".join([comment.pyval for comment in self.root.GlobalProperties.Comments.Comment])
except AttributeError:
return None
@comment.setter
def comment(self, value):

Wyświetl plik

@ -0,0 +1,85 @@
# xrnicomment. manipulate XRNI comments
# Copyright (C) 2016 Olivier Jolly
#
# 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/>.
from __future__ import print_function
import argparse
import logging
import sys
import os
from rnsutils.instrument import RenoiseInstrument
__date__ = '2016-02-02'
__updated__ = '2016-02-02'
__author__ = 'olivier@pcedev.com'
ACTION_VIEW = 0
ACTION_EDIT = 1
ACTION_DELETE = 2
def main(argv=None):
program_name = os.path.basename(sys.argv[0])
program_version = "v0.8"
program_build_date = "%s" % __updated__
program_version_string = '%%prog %s (%s)' % (program_version, program_build_date)
program_longdesc = '''Display or change XRNI comments'''
program_license = "GPL v3+ 2016 Olivier Jolly"
if argv is None:
argv = sys.argv[1:]
try:
parser = argparse.ArgumentParser(epilog=program_longdesc,
description=program_license)
parser.add_argument("-d", "--debug", dest="debug", action="store_true",
default=False,
help="debug parsing [default: %(default)s]")
parser.add_argument("-e", "--edit", dest="action", action="store_const", default=ACTION_VIEW, const=ACTION_EDIT,
help="edit comment with standard input content")
parser.add_argument("-r", "--remove", dest="action", action="store_const", const=ACTION_DELETE,
help="remove comment")
parser.add_argument("-v", "--view", dest="action", action="store_const", const=ACTION_VIEW,
help="view comment [default action]")
parser.add_argument("xrni_filename", help="input file in XRNI format", nargs="+")
# process options
opts = parser.parse_args(argv)
except Exception as e:
indent = len(program_name) * " "
sys.stderr.write(program_name + ": " + repr(e) + "\n")
sys.stderr.write(indent + " for help use --help")
return 2
if opts.debug:
logging.root.setLevel(logging.DEBUG)
else:
logging.root.setLevel(logging.INFO)
for xrni_filename in opts.xrni_filename:
renoise_instrument = RenoiseInstrument(xrni_filename)
print(renoise_instrument.comment)
return 0
if __name__ == "__main__":
sys.exit(main())

Wyświetl plik

@ -119,6 +119,7 @@ setup(
'sf2toxrni=rnsutils.sf2toxrni:main',
'sfztoxrni=rnsutils.sfztoxrni:main',
'xrnireencode=rnsutils.xrnireencode:main',
'xrnicomment=rnsutils.xrnicomment:main',
],
},