diff options
author | Sean B. Palmer <sbp@aldebaran.local> | 2012-04-24 15:31:27 +0100 |
---|---|---|
committer | Sean B. Palmer <sbp@aldebaran.local> | 2012-04-24 15:31:27 +0100 |
commit | 0908b6a61dac8df774fce26451e508a1efc7841b (patch) | |
tree | 6dcc8c62bbec3d1aade6fcb1d69e433a5d7b0e63 | |
parent | c5fe137b01a0b0fe01b4f2d6b85afc28fc4a1f8a (diff) | |
download | bot-0908b6a61dac8df774fce26451e508a1efc7841b.tar.gz bot-0908b6a61dac8df774fce26451e508a1efc7841b.tar.bz2 bot-0908b6a61dac8df774fce26451e508a1efc7841b.zip |
Create default config if it doesn't exist
-rwxr-xr-x | phenny | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -59,6 +59,14 @@ def create_default_config(fn): """) f.close() +def create_default_config_file(dotdir): + print 'Creating a default config file at ~/.phenny/default.py...' + default = os.path.join(dotdir, 'default.py') + create_default_config(default) + + print 'Done; now you can edit default.py, and run phenny! Enjoy.' + sys.exit(0) + def create_dotdir(dotdir): print 'Creating a config directory at ~/.phenny...' try: os.mkdir(dotdir) @@ -68,16 +76,15 @@ def create_dotdir(dotdir): print >> sys.stderr, 'Please fix this and then run phenny again.' sys.exit(1) - print 'Creating a default config file at ~/.phenny/default.py...' - default = os.path.join(dotdir, 'default.py') - create_default_config(default) - - print 'Done; now you can edit default.py, and run phenny! Enjoy.' - sys.exit(0) + create_default_config_file(dotdir) def check_dotdir(): + default = os.path.join(dotdir, 'default.py') + if not os.path.isdir(dotdir): create_dotdir(dotdir) + elif not os.path.isfile(default): + create_default_config_file(dotdir) def config_names(config): config = config or 'default' |