From 1f77e1ad3c295bdfc4746b69b2aad578299646cb Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Mon, 26 Aug 2019 08:24:45 +0200 Subject: Properly convert tellico2lesana to use argparse --- scripts/tellico2lesana | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/tellico2lesana b/scripts/tellico2lesana index 0d16ad4..4bd0810 100755 --- a/scripts/tellico2lesana +++ b/scripts/tellico2lesana @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import argparse import datetime from xml.etree import ElementTree import zipfile @@ -26,7 +27,7 @@ F_TYPE_MAP = { } -class T2L(lesana.command.Command): +class T2L(): """ Manage collections """ @@ -40,6 +41,12 @@ class T2L(lesana.command.Command): )), ] + def _load_args(self): + self.parser = argparse.ArgumentParser() + for arg in self.arguments: + self.parser.add_argument(*arg[0], **arg[1]) + self.args = self.parser.parse_args() + def read_field_data(self, xfield): if xfield.tag in self.date_fields: for child in xfield: @@ -66,6 +73,7 @@ class T2L(lesana.command.Command): return data def main(self): + self._load_args() with zipfile.ZipFile(self.args.file, 'r') as zp: tree = ElementTree.parse(zp.open('tellico.xml')) # open collection -- cgit v1.2.3