aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-09-16 12:16:57 +0200
committerElena ``of Valhalla'' Grandi <valhalla@trueelena.org>2020-09-16 12:16:57 +0200
commitc7b332764115de5c41a518c64ce902adc3b9b924 (patch)
tree8879cfadef9d644715a651b08a70a5e182551991 /scripts
parent872b637d3144ce73c450691e122de1a4648231b6 (diff)
flake8 fixes
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/lesana24
-rwxr-xr-xscripts/tellico2lesana56
2 files changed, 33 insertions, 47 deletions
diff --git a/scripts/lesana b/scripts/lesana
index 4b0179b..c8e6b7f 100755
--- a/scripts/lesana
+++ b/scripts/lesana
@@ -8,22 +8,22 @@ import argparse
import lesana.command
-class Lesana():
+class Lesana:
"""
Manage collections
"""
commands = (
- ('new', lesana.command.New()),
- ('edit', lesana.command.Edit()),
- ('show', lesana.command.Show()),
- ('index', lesana.command.Index()),
- ('search', lesana.command.Search()),
- ('update', lesana.command.Update()),
- ('export', lesana.command.Export()),
- ('init', lesana.command.Init()),
- ('rm', lesana.command.Remove()),
- )
+ ("new", lesana.command.New()),
+ ("edit", lesana.command.Edit()),
+ ("show", lesana.command.Show()),
+ ("index", lesana.command.Index()),
+ ("search", lesana.command.Search()),
+ ("update", lesana.command.Update()),
+ ("export", lesana.command.Export()),
+ ("init", lesana.command.Init()),
+ ("rm", lesana.command.Remove()),
+ )
def _main(self, args):
self.parser.print_help()
@@ -41,5 +41,5 @@ class Lesana():
self.args.func(self.args)
-if __name__ == '__main__':
+if __name__ == "__main__":
Lesana().main()
diff --git a/scripts/tellico2lesana b/scripts/tellico2lesana
index a24415e..28a1f15 100755
--- a/scripts/tellico2lesana
+++ b/scripts/tellico2lesana
@@ -12,34 +12,32 @@ NS = {'tellico': 'http://periapsis.org/tellico/'}
# https://docs.kde.org/trunk5/en/extragear-office/tellico/field-type-values.html
F_TYPE_MAP = {
- '0': 'string', # not in the specs, but seen in the wild
+ '0': 'string', # not in the specs, but seen in the wild
'1': 'string',
'2': 'text',
'3': 'string',
'4': 'bool',
'6': 'integer',
'7': 'url',
- '8': 'list', # single column table
+ '8': 'list', # single column table
'10': 'file',
'12': 'timestamp', # date
- '14': 'integer', # rating
+ '14': 'integer', # rating
+}
- }
-
-class T2L():
+class T2L:
"""
Manage collections
"""
+
arguments = [
- (['-c', '--collection'], dict(
- help='Name of the new lesana collection',
- default=None,
- )),
- (['file'], dict(
- help='Tellico file to convert to lesana.',
- )),
- ]
+ (
+ ['-c', '--collection'],
+ dict(help='Name of the new lesana collection', default=None,),
+ ),
+ (['file'], dict(help='Tellico file to convert to lesana.',)),
+ ]
def _load_args(self):
self.parser = argparse.ArgumentParser()
@@ -57,11 +55,7 @@ class T2L():
elif 'day' in child.tag:
day = child.text
try:
- data = datetime.date(
- int(year),
- int(month),
- int(day)
- )
+ data = datetime.date(int(year), int(month), int(day))
except ValueError:
data = None
elif xfield.iter().__next__():
@@ -88,7 +82,7 @@ class T2L():
if xf.attrib['type'] == '12':
self.date_fields.append(
'{' + NS['tellico'] + '}' + xf.attrib['name']
- )
+ )
f_type = F_TYPE_MAP.get(xf.attrib['type'])
# TODO: support fields with the multiple values flag
# (they should probably become lists)
@@ -107,33 +101,25 @@ class T2L():
'name': xf.attrib['name'] + plural,
'type': f_type,
'help': xf.attrib['title'],
- }
+ }
if l_type:
field['list'] = l_type
fields.append(field)
# Create a collection with the settings we have loaded
directory = self.args.collection or self.args.file.replace(
- '.tc',
- '.lesana'
- )
+ '.tc', '.lesana'
+ )
self.collection = lesana.collection.Collection.init(
directory=directory,
git_enabled=False,
- settings={
- 'name': title,
- 'fields': fields,
- }
- )
+ settings={'name': title, 'fields': fields,},
+ )
# import data
for xe in xml_collection.findall('tellico:entry', NS):
- data = {
- 'eid': xe.attrib['id']
- }
+ data = {'eid': xe.attrib['id']}
for xfield in xe.getchildren():
- field_name = xfield.tag.replace(
- '{'+NS['tellico']+'}',
- '')
+ field_name = xfield.tag.replace('{' + NS['tellico'] + '}', '')
data[field_name] = self.read_field_data(xfield)
new_entry = lesana.collection.Entry(self.collection, data=data)
self.collection.save_entries([new_entry])