mirror of
https://github.com/Steffo99/greed.git
synced 2024-11-25 07:14:18 +00:00
Don't crash if config.ini does not exist
This commit is contained in:
parent
002ccfb14b
commit
087eb0d594
1 changed files with 7 additions and 6 deletions
|
@ -2,13 +2,14 @@ import sys
|
||||||
import os
|
import os
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
# Check if a configuration file exists, create one if it doesn't and get the template version number.
|
# Check if the config file exists, and create one if it doesn't
|
||||||
with open("config/template_config.ini") as template_file:
|
if not os.path.isfile("config/config.ini"):
|
||||||
# Check if the config file exists
|
# Open the template file and create the config file
|
||||||
if not os.path.isfile("config/config.ini"):
|
with open("config/template_config.ini") as template_file, open("config/config.ini", "w") as config_file:
|
||||||
# Copy the template file to the config file
|
# Copy the template file to the config file
|
||||||
with open("config/config.ini", "w") as config_file:
|
config_file.write(template_file.read())
|
||||||
config_file.write(template_file.read())
|
|
||||||
|
with open("config/template_config.ini") as template_file:
|
||||||
# Find the template version number
|
# Find the template version number
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read_file(template_file)
|
config.read_file(template_file)
|
||||||
|
|
Loading…
Reference in a new issue