diff options
Diffstat (limited to 'scripts/tellico2lesana')
-rwxr-xr-x | scripts/tellico2lesana | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/scripts/tellico2lesana b/scripts/tellico2lesana index 6f9cc5a..0d16ad4 100755 --- a/scripts/tellico2lesana +++ b/scripts/tellico2lesana @@ -6,8 +6,6 @@ import zipfile import lesana -import guacamole - NS = {'tellico': 'http://periapsis.org/tellico/'} @@ -28,21 +26,19 @@ F_TYPE_MAP = { } -class T2L(guacamole.Command): +class T2L(lesana.command.Command): """ Manage collections """ - - def register_arguments(self, parser): - parser.add_argument( - '-c', '--collection', + arguments = [ + (['-c', '--collection'], dict( help='Name of the new lesana collection', default=None, - ) - parser.add_argument( - 'file', + )), + (['file'], dict( help='Tellico file to convert to lesana.', - ) + )), + ] def read_field_data(self, xfield): if xfield.tag in self.date_fields: @@ -69,9 +65,8 @@ class T2L(guacamole.Command): data = xfield.text return data - - def invoked(self, ctx): - with zipfile.ZipFile(ctx.args.file, 'r') as zp: + def main(self): + with zipfile.ZipFile(self.args.file, 'r') as zp: tree = ElementTree.parse(zp.open('tellico.xml')) # open collection xml_collection = tree.getroot().find('tellico:collection', NS) @@ -109,7 +104,7 @@ class T2L(guacamole.Command): field['list'] = l_type fields.append(field) # Create a collection with the settings we have loaded - directory = ctx.args.collection or ctx.args.file.replace( + directory = self.args.collection or self.args.file.replace( '.tc', '.lesana' ) @@ -137,7 +132,5 @@ class T2L(guacamole.Command): self.collection.update_cache() - - if __name__ == '__main__': T2L().main() |