24
24
DEFAULT_SETTINGFILE = DEFAULT_SETTINGFILE .as_posix ()
25
25
26
26
27
- def unlink_default_dict_package (output ):
27
+ def unlink_default_dict_package (output , verbose = True ):
28
28
try :
29
29
dst_path = Path (import_module ('sudachidict' ).__file__ ).parent
30
30
except ImportError :
31
- print ('sudachidict not exists' , file = output )
31
+ if verbose :
32
+ print ('Package `sudachidict` does not exist.' , file = output )
32
33
return
33
34
34
35
if dst_path .is_symlink ():
35
- print ('unlinking sudachidict' , file = output )
36
36
dst_path .unlink ()
37
- print ('sudachidict unlinked' , file = output )
37
+ if verbose :
38
+ print ('Removed the package symbolic link `sudachidict`.' , file = output )
38
39
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). ' )
40
41
41
42
42
43
def set_default_dict_package (dict_package , output ):
43
- unlink_default_dict_package (output )
44
+ unlink_default_dict_package (output , verbose = False )
44
45
45
46
src_path = Path (import_module (dict_package ).__file__ ).parent
46
47
dst_path = src_path .parent / 'sudachidict'
47
48
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 )
49
50
50
51
return dst_path
51
52
@@ -57,15 +58,15 @@ def create_default_link_for_sudachidict_core(output):
57
58
try :
58
59
import_module ('sudachidict_core' )
59
60
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. ' )
61
62
try :
62
63
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.' )
64
65
except ImportError :
65
66
pass
66
67
try :
67
68
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.' )
69
70
except ImportError :
70
71
pass
71
72
dict_path = set_default_dict_package ('sudachidict_core' , output = output )
0 commit comments