I've published version 0.4.4 which should fix that. Please upgrade and let me know. For now all of the output will be in a single (invalid, no single root element) XML file that will have multiple tools concatenated together. Cheers, Helena On 2018-05-28, Matthias Bernt wrote:
Hi Helena,
got it running, but I struggling with subparsers (the tools that I try to wrap basically only uses subparsers .. a lot of them). I adapted the example.py in your repo to include a subparser which seems to be excluded from the xml.
I call `python example.py --generate_galaxy_xml`
since `python example.py sub --generate_galaxy_xml` seems not to work.
Any suggestions?
Best, Matthias
On 28.05.2018 10:02, H. Rasche wrote:
Hey Matthias,
And let me know if you have any questions or bugs!
There are a couple of things it won't do, but if you're looking to get 90% of the way from python script to tool interface, it will do that. It won't get you the last 10% of nice repeat blocks and sections and all of the things that help make galaxy tools more user-friendly. But this can still be a huge time savings
Cheers, Helena (@erasche)
On 2018-05-28, Björn Grüning wrote:
Hi Matthias,
check this one out: https://github.com/erasche/argparse2tool
Cheers, Bjoern
Am 28.05.2018 um 09:43 schrieb Matthias Bernt:
Dear list,
just a question for advice: I plan to wrap a python script (with lots of options) which uses the argparse library. I was wondering if somebody has an idea to generate the tool xml (semi-)automatically? For instance, by subclassing the formatter, parsing the python code, or parsing the command line...
Cheers, Matthias
___________________________________________________________ Please keep all replies on the list by using "reply all" in your mail client. To manage your subscriptions to this and other Galaxy lists, please use the interface at: https://lists.galaxyproject.org/
To search Galaxy mailing lists use the unified search at: http://galaxyproject.org/search/
--
------------------------------------------- Matthias Bernt Bioinformatics Service Molekulare Systembiologie (MOLSYB) Helmholtz-Zentrum für Umweltforschung GmbH - UFZ/ Helmholtz Centre for Environmental Research GmbH - UFZ Permoserstraße 15, 04318 Leipzig, Germany Phone +49 341 235 482296, m.bernt@ufz.de, www.ufz.de
Sitz der Gesellschaft/Registered Office: Leipzig Registergericht/Registration Office: Amtsgericht Leipzig Handelsregister Nr./Trade Register Nr.: B 4703 Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: MinDirig Wilfried Kraus Wissenschaftlicher Geschäftsführer/Scientific Managing Director: Prof. Dr. Dr. h.c. Georg Teutsch Administrative Geschäftsführerin/ Administrative Managing Director: Prof. Dr. Heike Graßmann -------------------------------------------
# /usr/bin/python3 import argparse
parser = argparse.ArgumentParser(description='Process some integers.', prefix_chars='-+', epilog="here's some epilog text", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('keyword', metavar='Q', type=str, nargs=1, help='action keyword')
parser.add_argument('integers', metavar='N', type=int, nargs='+', help='an integer for the accumulator')
parser.add_argument('--sum', '-s', dest='accumulate', action='store_const', const=sum, default=max, help='sum the integers (default: find the max)')
parser.add_argument('--foo', nargs='?', help='foo help') parser.add_argument('--bar', nargs='*', default=[1, 2, 3], help='BAR!') parser.add_argument('--true', action='store_true', help='Store a true') parser.add_argument('--false', action='store_false', help='Store a false') parser.add_argument('--append', action='append', help='Append a value')
parser.add_argument('--nargs2', nargs=2, help='nargs2')
parser.add_argument('--mode', choices=['rock', 'paper', 'scissors'], default='scissors')
parser.add_argument('--version', action='version', version='2.0')
subparsers = parser.add_subparsers() subparser = subparsers.add_parser('sub', help='test subparser') subparser.add_argument('keyword', type=str) subparser.add_argument('--subtrue', action='store_true', help='Store a true')
args = parser.parse_args()