From 4c9ccc3b8ba0ff50bf5e715ae84bf8837b3dadc1 Mon Sep 17 00:00:00 2001 From: Mahmoud Lababidi Date: Wed, 14 Sep 2016 10:04:09 -0400 Subject: [PATCH] Add parameter to download() for application to not exit if a Model exists. The default behavior is unchanged. --- spacy/download.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/download.py b/spacy/download.py index 4fbc6b11b..2efa28630 100644 --- a/spacy/download.py +++ b/spacy/download.py @@ -9,15 +9,16 @@ from sputnik.package_list import (PackageNotFoundException, from . import about -def download(lang, force=False): +def download(lang, force=False, fail_on_exist=True): if force: sputnik.purge(about.__title__, about.__version__) try: sputnik.package(about.__title__, about.__version__, about.__models__[lang]) - print("Model already installed. Please run 'python -m " - "spacy.%s.download --force' to reinstall." % lang, file=sys.stderr) - sys.exit(0) + if fail_on_exist: + print("Model already installed. Please run 'python -m " + "spacy.%s.download --force' to reinstall." % lang, file=sys.stderr) + sys.exit(0) except (PackageNotFoundException, CompatiblePackageNotFoundException): pass