consolidate logic about MeCab path length

Former-commit-id: 2b984937be
This commit is contained in:
Robyn Speer 2016-08-04 15:16:20 -04:00
parent c11998e506
commit 6440d81676

View File

@ -22,8 +22,9 @@ def find_mecab_dictionary(names):
'/usr/local/lib/mecab/dic', '/usr/local/lib/mecab/dic',
] ]
full_paths = [os.path.join(path, name) for path in paths for name in names] full_paths = [os.path.join(path, name) for path in paths for name in names]
for path in full_paths: checked_paths = [path for path in full_paths if len(path) <= MAX_PATH_LENGTH]
if os.path.exists(path) and len(path) <= MAX_PATH_LENGTH: for path in checked_paths:
if os.path.exists(path):
return path return path
error_lines = [ error_lines = [
@ -32,7 +33,7 @@ def find_mecab_dictionary(names):
"the %r package." % suggested_pkg, "the %r package." % suggested_pkg,
"", "",
"We looked in the following locations:" "We looked in the following locations:"
] + ["\t%s" % path for path in full_paths if len(path) <= MAX_PATH_LENGTH] ] + ["\t%s" % path for path in checked_paths]
skipped_paths = [path for path in full_paths if len(path) > MAX_PATH_LENGTH] skipped_paths = [path for path in full_paths if len(path) > MAX_PATH_LENGTH]
if skipped_paths: if skipped_paths: