Improved error handling for configs that don't exist.

doc_update
Joey Hines 2018-08-30 08:58:54 -05:00
parent 89bf3b0ba7
commit d3998aa1cd
1 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,5 @@
import codecs
import configparser
import os
def create_config(config, path):
@ -35,9 +34,9 @@ def create_config(config, path):
def read_config(path):
config = configparser.ConfigParser()
config.read_file(codecs.open(path, "r", "utf8"))
if len(config.sections()) == 0:
try:
config.read_file(codecs.open(path, "r", "utf8"))
except FileNotFoundError:
create_config(config, path)
print("Config generated.")
quit(0)