Improved error handling for configs that don't exist.
parent
89bf3b0ba7
commit
d3998aa1cd
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue