Create empty user config file if it does not exist

Running `beet config -e` with a non-existing configuration file
does not always work (e.g., OSX uses `open` by default, which requires
the file to exist). This could occur during e.g. initial setup.

Resolve #1480
This commit is contained in:
Tom Jaspers 2015-07-07 22:56:02 +01:00
parent 493fbab1a5
commit 12295376eb

View file

@ -1482,11 +1482,13 @@ def config_func(lib, opts, args):
def config_edit():
"""Open a program to edit the user configuration.
An empty config file is created if no existing config file exists.
"""
path = config.user_config_path()
editor = os.environ.get('EDITOR')
try:
if not os.path.isfile(path):
open(path, 'w+').close()
util.interactive_open(path, editor)
except OSError as exc:
message = "Could not edit configuration: {0}".format(exc)