mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2025-02-08 14:56:44 +01:00
Add refetch to update command arguments
This commit is contained in:
parent
c3b014d06e
commit
2493075669
1 changed files with 31 additions and 8 deletions
|
@ -23,13 +23,14 @@ Update command.
|
||||||
|
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
from argparse import ArgumentParser, FileType
|
from argparse import ArgumentParser, Namespace, FileType
|
||||||
from typing import Any, Iterable, Iterator, Optional
|
from typing import Any, Iterable, Iterator, Optional
|
||||||
|
|
||||||
from jmespath import search
|
from jmespath import search
|
||||||
|
|
||||||
from fimfarchive.fetchers import FimfarchiveFetcher, FimfictionFetcher
|
from fimfarchive.fetchers import Fetcher, FimfarchiveFetcher, FimfictionFetcher
|
||||||
from fimfarchive.flavors import UpdateStatus
|
from fimfarchive.flavors import UpdateStatus
|
||||||
|
from fimfarchive.selectors import Selector, RefetchSelector
|
||||||
from fimfarchive.signals import SignalReceiver
|
from fimfarchive.signals import SignalReceiver
|
||||||
from fimfarchive.stories import Story
|
from fimfarchive.stories import Story
|
||||||
from fimfarchive.tasks import UpdateTask
|
from fimfarchive.tasks import UpdateTask
|
||||||
|
@ -169,7 +170,7 @@ class UpdatePrinter(SignalReceiver):
|
||||||
if story:
|
if story:
|
||||||
print(StoryFormatter(story))
|
print(StoryFormatter(story))
|
||||||
else:
|
else:
|
||||||
print("Status: Missing")
|
print("Action: Missing")
|
||||||
|
|
||||||
def on_failure(self, sender, key, error):
|
def on_failure(self, sender, key, error):
|
||||||
"""
|
"""
|
||||||
|
@ -202,15 +203,37 @@ class UpdateCommand(Command):
|
||||||
metavar='PATH',
|
metavar='PATH',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--refetch',
|
||||||
|
help="refetch all available stories",
|
||||||
|
action='store_true',
|
||||||
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
def configure(self, opts: Namespace) -> UpdateTask:
|
||||||
|
"""
|
||||||
|
Returns a configured task instance.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
opts: Parsed command line arguments.
|
||||||
|
"""
|
||||||
|
fimfarchive: Fetcher = FimfarchiveFetcher(opts.archive)
|
||||||
|
fimfiction: Fetcher = FimfictionFetcher()
|
||||||
|
selector: Optional[Selector] = None
|
||||||
|
|
||||||
|
if opts.refetch:
|
||||||
|
selector = RefetchSelector()
|
||||||
|
|
||||||
|
return UpdateTask(
|
||||||
|
fimfarchive=fimfarchive,
|
||||||
|
fimfiction=fimfiction,
|
||||||
|
selector=selector,
|
||||||
|
)
|
||||||
|
|
||||||
def __call__(self, *args):
|
def __call__(self, *args):
|
||||||
opts = self.parser.parse_args(args)
|
opts = self.parser.parse_args(args)
|
||||||
|
task = self.configure(opts)
|
||||||
task = UpdateTask(
|
|
||||||
fimfarchive=FimfarchiveFetcher(opts.archive),
|
|
||||||
fimfiction=FimfictionFetcher(),
|
|
||||||
)
|
|
||||||
|
|
||||||
with UpdatePrinter(task):
|
with UpdatePrinter(task):
|
||||||
task.run()
|
task.run()
|
||||||
|
|
Loading…
Reference in a new issue