Skip to content

Commit

Permalink
updating cluster CLI to reduce redundancy #44
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnmjones committed Aug 12, 2021
1 parent 27890fe commit 7da3c4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
17 changes: 14 additions & 3 deletions hypercane/args/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from argparse import RawTextHelpFormatter
from datetime import datetime

import hypercane.actions.identify

identify_parser = argparse.ArgumentParser(prog="hc identify",
description="'hc identify' discovers resource identifiers in a web archive collection, a list of TimeMaps, original resources, or mementos",
formatter_class=RawTextHelpFormatter
Expand All @@ -11,7 +13,10 @@
subparsers.required = True

memento_parser = subparsers.add_parser('mementos', help="Discover the mementos in a web archive collection.")
memento_parser.set_defaults(which='mementos')
memento_parser.set_defaults(
which='mementos',
exec=hypercane.actions.identify.discover_mementos
)

memento_parser.add_argument('--timegates',
default=[
Expand All @@ -31,7 +36,10 @@
)

timemap_parser = subparsers.add_parser('timemaps', help="Discover the TimeMaps in a web archive collection.")
timemap_parser.set_defaults(which='timemaps')
timemap_parser.set_defaults(
which='timemaps',
exec=hypercane.actions.identify.discover_timemaps
)

# note: this is just for testing purposes, but do not remove this argument
timemap_parser.add_argument('--faux-tms-acceptable',
Expand All @@ -41,4 +49,7 @@
dest='faux_tms_acceptable')

originalresource_parser = subparsers.add_parser('original-resources', help="Discover the original resources in a web archive collection.")
originalresource_parser.set_defaults(which='original-resources')
originalresource_parser.set_defaults(
which='original-resources',
exec=hypercane.actions.identify.discover_original_resources
)
9 changes: 1 addition & 8 deletions hypercane/cli/identify.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import hypercane.actions.identify
import hypercane.errors

from hypercane.args import universal_cli_required_args, universal_cli_optional_args
from hypercane.args.identify import identify_parser
from hypercane.version import __useragent__
from hypercane.actions import get_logger, calculate_loglevel

identify_functions = {
"mementos": hypercane.actions.identify.discover_mementos,
"timemaps": hypercane.actions.identify.discover_timemaps,
"original-resources": hypercane.actions.identify.discover_original_resources,
}

if __name__ == '__main__':

for item in identify_parser._subparsers._group_actions:
Expand Down Expand Up @@ -44,4 +37,4 @@
if args.errorfilename is not None:
hypercane.errors.errorstore.type = hypercane.errors.FileErrorStore(args.errorfilename)

identify_functions[args.which](args)
args.exec(args)

0 comments on commit 7da3c4c

Please sign in to comment.