mirror of
https://github.com/JockeTF/fimfarchive.git
synced 2024-11-24 06:17:58 +01:00
Add command for normalizing story meta
This commit is contained in:
parent
4a92ced65b
commit
3c5b705794
3 changed files with 59 additions and 0 deletions
|
@ -24,11 +24,13 @@ Command module.
|
||||||
|
|
||||||
from .base import Command
|
from .base import Command
|
||||||
from .root import RootCommand
|
from .root import RootCommand
|
||||||
|
from .normal import NormalCommand
|
||||||
from .update import UpdateCommand
|
from .update import UpdateCommand
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Command',
|
'Command',
|
||||||
'RootCommand',
|
'RootCommand',
|
||||||
|
'NormalCommand',
|
||||||
'UpdateCommand',
|
'UpdateCommand',
|
||||||
)
|
)
|
||||||
|
|
55
fimfarchive/commands/normal.py
Normal file
55
fimfarchive/commands/normal.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
"""
|
||||||
|
Normalize command.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Fimfarchive, preserves stories from Fimfiction.
|
||||||
|
# Copyright (C) 2019 Joakim Soderlund
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from fimfarchive.converters import LocalUtcConverter
|
||||||
|
from fimfarchive.fetchers import DirectoryFetcher
|
||||||
|
from fimfarchive.utils import tqdm
|
||||||
|
from fimfarchive.writers import DirectoryWriter
|
||||||
|
|
||||||
|
|
||||||
|
from .base import Command
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = (
|
||||||
|
'NormalCommand',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class NormalCommand(Command):
|
||||||
|
"""
|
||||||
|
Normalizes updated story meta.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __call__(self, *args: str) -> int:
|
||||||
|
convert = LocalUtcConverter()
|
||||||
|
fetcher = DirectoryFetcher(meta_path=Path('worktree/update/meta'))
|
||||||
|
writer = DirectoryWriter(meta_path='worktree/normal/meta')
|
||||||
|
|
||||||
|
for story in tqdm(fetcher):
|
||||||
|
story = convert(story)
|
||||||
|
writer.write(story)
|
||||||
|
|
||||||
|
return 0
|
|
@ -25,6 +25,7 @@ Root command.
|
||||||
from typing import Dict, Type
|
from typing import Dict, Type
|
||||||
|
|
||||||
from .base import Command
|
from .base import Command
|
||||||
|
from .normal import NormalCommand
|
||||||
from .update import UpdateCommand
|
from .update import UpdateCommand
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,6 +39,7 @@ class RootCommand(Command):
|
||||||
The main application command.
|
The main application command.
|
||||||
"""
|
"""
|
||||||
commands: Dict[str, Type[Command]] = {
|
commands: Dict[str, Type[Command]] = {
|
||||||
|
'normal': NormalCommand,
|
||||||
'update': UpdateCommand,
|
'update': UpdateCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue