Skip to content

Commit

Permalink
Unzip local zip if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
hankcs committed Feb 3, 2020
1 parent 0f9d9a4 commit b537199
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion hanlp/utils/io_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,14 @@ def get_resource(path: str, save_dir=None, extract=True, prefix=HANLP_URL, appen
child = path_join(realpath, anchor)
if os.path.exists(child):
return child
elif os.path.isdir(realpath) or os.path.isfile(realpath):
elif os.path.isdir(realpath) or (os.path.isfile(realpath) and (not compressed or not extract)):
return realpath
else:
pattern = realpath + '.*'
files = glob.glob(pattern)
zip_path = realpath + compressed
if zip_path in files:
files.remove(zip_path)
if files:
if len(files) > 1:
logger.debug(f'Found multiple files with {pattern}, will use the first one.')
Expand Down
2 changes: 1 addition & 1 deletion hanlp/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Author: hankcs
# Date: 2019-12-28 19:26

__version__ = '2.0.0-alpha.34'
__version__ = '2.0.0-alpha.35'

0 comments on commit b537199

Please sign in to comment.