sort: Allow adding of comma seperated tags

This commit is contained in:
fleaz 2023-02-24 00:03:58 +01:00
parent 590590c8e5
commit d9a1f637f8
No known key found for this signature in database
GPG key ID: AED15F8FDD04D083

View file

@ -36,17 +36,19 @@ def command():
print("Skipping") print("Skipping")
continue continue
tag = tag_lookup.get(select, None) for text in select.split(","):
if not tag: tag = tag_lookup.get(text, None)
print(f"Creating new category '{select}'") if not tag:
tag = create_tag(select, session) print(f"Creating new category '{text}'")
tag = create_tag(text, session)
tags = session.query(Tag).all() tags = session.query(Tag).all()
tag_names = FuzzyWordCompleter([x.name for x in tags]) tag_names = FuzzyWordCompleter([x.name for x in tags])
tag_lookup = {tag.name: tag for tag in tags} tag_lookup = {tag.name: tag for tag in tags}
t.tags.append(tag)
session.add(t)
t.tags.append(tag)
session.add(t)
session.commit() session.commit()
print("-" * 20) print("-" * 20)