From fd0b9834b09d4afe5bdaccc42e3e5c73d64d25d6 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 22 Apr 2017 19:24:42 +0200 Subject: tellico2lesana: create a lesana collection --- scripts/tellico2lesana | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/tellico2lesana b/scripts/tellico2lesana index 8de8bf9..e820069 100755 --- a/scripts/tellico2lesana +++ b/scripts/tellico2lesana @@ -3,6 +3,8 @@ from xml.etree import ElementTree import zipfile +import lesana + import guacamole @@ -30,9 +32,14 @@ class T2L(guacamole.Command): """ def register_arguments(self, parser): + parser.add_argument( + '-c', '--collection', + help='Name of the new lesana collection', + default=None, + ) parser.add_argument( 'file', - help='Tellico file to convert to lesana.' + help='Tellico file to convert to lesana.', ) def invoked(self, ctx): @@ -54,9 +61,19 @@ class T2L(guacamole.Command): 'name': xf.attrib['title'], 'type': f_type, }) - # TODO: create a collection with the following settings: - import ruamel.yaml - print(ruamel.yaml.dump({'title': title, 'fields': fields})) + # Create a collection with the settings we have loaded + directory = ctx.args.collection or ctx.args.file.replace( + '.tc', + '.lesana' + ) + lesana.collection.Collection.init( + directory=directory, + git_enabled=False, + settings={ + 'name': title, + 'fields': fields, + } + ) # import data -- cgit v1.2.3