| 1 |
import argparse |
| 2 |
import logging |
| 3 |
import warnings |
| 4 |
|
| 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="[DEPRECATED] fastText is no longer supported. Please use langdetect instead.", |
| 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 |
warnings.warn( |
| 32 |
"fastText support has been removed as the library is archived and unmaintained. " |
| 33 |
"Please migrate to langdetect. Install with: pip install dateparser[langdetect]", |
| 34 |
DeprecationWarning, |
| 35 |
stacklevel=2, |
| 36 |
) |
| 37 |
dateparser_argparse.error( |
| 38 |
"fastText is no longer supported. Please use langdetect for language detection." |
| 39 |
) |
| 40 |
|
| 41 |
if not args.clear: |
| 42 |
dateparser_argparse.error( |
| 43 |
"dateparser-download: You need to specify the command (i.e.: --clear)" |
| 44 |
) |