1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
import argparse
import logging
from .fasttext_manager import fasttext_downloader
from .utils import clear_cache
def entrance():
dateparser_argparse = argparse.ArgumentParser(
description="dateparser download manager."
)
dateparser_argparse.add_argument(
"--fasttext",
type=str,
help='To download a fasttext language detection models. Supported models are "small" and "large"',
)
dateparser_argparse.add_argument(
"--clear",
"--clear-cache",
help="To clear all cached models",
action="store_true",
)
args = dateparser_argparse.parse_args()
if args.clear:
clear_cache()
logging.info("dateparser-download: All cache deleted")
if args.fasttext:
fasttext_downloader(args.fasttext)
if not (args.clear or args.fasttext):
dateparser_argparse.error(
"dateparser-download: You need to specify the command (i.e.: --fasttext or --clear)"
)
|