2424DEFAULT_SETTINGFILE = DEFAULT_SETTINGFILE .as_posix ()
2525
2626
27- def unlink_default_dict_package (output ):
27+ def unlink_default_dict_package (output , verbose = True ):
2828 try :
2929 dst_path = Path (import_module ('sudachidict' ).__file__ ).parent
3030 except ImportError :
31- print ('sudachidict not exists' , file = output )
31+ if verbose :
32+ print ('Package `sudachidict` does not exist.' , file = output )
3233 return
3334
3435 if dst_path .is_symlink ():
35- print ('unlinking sudachidict' , file = output )
3636 dst_path .unlink ()
37- print ('sudachidict unlinked' , file = output )
37+ if verbose :
38+ print ('Removed the package symbolic link `sudachidict`.' , file = output )
3839 if dst_path .exists ():
39- raise IOError ('unlink failed (directory exists) ' )
40+ raise IOError ('Unlink failed (The `sudachidict` directory exists and it is not a symbolic link). ' )
4041
4142
4243def set_default_dict_package (dict_package , output ):
43- unlink_default_dict_package (output )
44+ unlink_default_dict_package (output , verbose = False )
4445
4546 src_path = Path (import_module (dict_package ).__file__ ).parent
4647 dst_path = src_path .parent / 'sudachidict'
4748 dst_path .symlink_to (src_path )
48- print ('default dict package = {} ' .format (dict_package ), file = output )
49+ print ('Set the default dictionary to `{}`. ' .format (dict_package ), file = output )
4950
5051 return dst_path
5152
@@ -57,15 +58,15 @@ def create_default_link_for_sudachidict_core(output):
5758 try :
5859 import_module ('sudachidict_core' )
5960 except ImportError :
60- raise KeyError ('`systemDict` must be specified if `SudachiDict_core` not installed' )
61+ raise KeyError ('You need to specify `systemDict` in the config when `sudachidict_core` is not installed. ' )
6162 try :
6263 import_module ('sudachidict_full' )
63- raise KeyError ('Multiple packages of `SudachiDict_*` installed. Set default dict with link command.' )
64+ raise KeyError ('Multiple dictionaries installed. Set the default with ` link -t` command.' )
6465 except ImportError :
6566 pass
6667 try :
6768 import_module ('sudachidict_small' )
68- raise KeyError ('Multiple packages of `SudachiDict_*` installed. Set default dict with link command.' )
69+ raise KeyError ('Multiple dictionaries installed. Set the default with ` link -t` command.' )
6970 except ImportError :
7071 pass
7172 dict_path = set_default_dict_package ('sudachidict_core' , output = output )
0 commit comments