diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2019-08-26 08:24:45 +0200 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2019-08-26 08:24:45 +0200 |
commit | 1f77e1ad3c295bdfc4746b69b2aad578299646cb (patch) | |
tree | 579f5a813115ae72b9d970a721d22c1886c1f07b /scripts/tellico2lesana | |
parent | b4c7f0823ee40a0b1e65ae84dea018ffad66a6f2 (diff) |
Properly convert tellico2lesana to use argparse
Diffstat (limited to 'scripts/tellico2lesana')
-rwxr-xr-x | scripts/tellico2lesana | 10 |
1 files changed, 9 insertions, 1 deletions
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 |