# Otherwise just exit
sys.exit(0)
+ def __get_list(self, backend, slug):
+ """
+ Fetches a list or terminates the program if we could not find the list.
+ """
+ # Fetch the list
+ list = backend.lists.get_by_slug(slug)
+
+ # Terminate because we could not find the list
+ if not list:
+ sys.stderr.write("Could not find list '%s'\n" % slug)
+ raise SystemExit(2)
+
+ return list
+
def __list(self, backend, args):
table = rich.table.Table(title=_("Lists"))
table.add_column(_("Name"))
"""
Deletes a list
"""
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Delete!
list.delete(
"""
Shows information about a list
"""
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
table = rich.table.Table(title=list.name)
table.add_column(_("Property"))
Updates a single list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Update!
list.update(force=args.force)
Exports a list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Export!
list.export(args.output, format=args.format)
Adds a new source to a list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Create the source
backend.sources.create(
Removes a source from a list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Remove the source
list.delete_source(
Analyzes a list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Show duplicates
self.__analyze_duplicates(list)
Shows the history of a list
"""
# Fetch the list
- list = backend.lists.get_by_slug(args.list)
+ list = self.__get_list(backend, args.list)
# Fetch the history
history = list.get_history(limit=args.limit)