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