Better error when kitty config dir is a file

See #697
This commit is contained in:
Kovid Goyal 2018-07-03 06:30:29 +05:30
parent 4bf0e0ea23
commit f12697c897
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -58,7 +58,10 @@ def _get_config_dir():
candidate = os.path.abspath(os.path.expanduser(os.environ.get('XDG_CONFIG_HOME') or '~/.config'))
ans = os.path.join(candidate, appname)
try:
os.makedirs(ans, exist_ok=True)
except FileExistsError:
raise SystemExit('A file {} already exists. It must be a directory, not a file.'.format(ans))
return ans