Skip to content

Commit adc9fb6

Browse files
committed
Don't call function multiple times after first unconditional call
1 parent 5baf706 commit adc9fb6

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

config.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
saveDB = None
3333
gameDB = None
3434

35-
def __createSavePath():
36-
if not os.path.exists(savePath):
37-
os.mkdir(savePath)
35+
def __createDirs(path):
36+
if not os.path.exists(path):
37+
os.makedirs(path)
3838

3939
def defPaths():
4040
global pyfaPath
@@ -61,9 +61,10 @@ def defPaths():
6161
savePath = unicode(os.path.expanduser(os.path.join("~", ".pyfa")),
6262
sys.getfilesystemencoding())
6363

64+
__createDirs(savePath)
65+
6466
format = '%(asctime)s %(name)-24s %(levelname)-8s %(message)s'
6567
logging.basicConfig(format=format, level=logLevel)
66-
__createSavePath()
6768
handler = logging.handlers.RotatingFileHandler(os.path.join(savePath, "log.txt"), maxBytes=1000000, backupCount=3)
6869
formatter = logging.Formatter(format)
6970
handler.setFormatter(formatter)
@@ -74,13 +75,11 @@ def defPaths():
7475
# Redirect stderr to file if we're requested to do so
7576
stderrToFile = getattr(configforced, "stderrToFile", None)
7677
if stderrToFile is True:
77-
__createSavePath()
7878
sys.stderr = open(os.path.join(savePath, "error_log.txt"), "w")
7979

8080
# Same for stdout
8181
stdoutToFile = getattr(configforced, "stdoutToFile", None)
8282
if stdoutToFile is True:
83-
__createSavePath()
8483
sys.stdout = open(os.path.join(savePath, "output_log.txt"), "w")
8584

8685
# Static EVE Data from the staticdata repository, should be in the staticdata

0 commit comments

Comments
 (0)