-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileMethods.py
32 lines (25 loc) · 870 Bytes
/
fileMethods.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
'''
WoT randomizer - file utilities written by KptKosmit91
'''
import os
import pathlib
def createFolder(name):
if not os.path.exists(name):
#print("Creating folder '" + name + "'.")\
pathlib.Path(name).mkdir(parents=True, exist_ok=True)
# else:
# print("Folder '" + name + "' already exists.")
def createFile(name, content):
file = open(name, 'w')
file.write(content)
file.close()
def createFileWithWarning(name, error, content):
if not os.path.exists(name):
createFile(name, content)
else:
shouldCreate = str(input("File " + name + " already exists. Should it be overwriten? (Y/N) " + error + " "))
if shouldCreate.lower() == "y" or shouldCreate.lower() == "yes":
createFile(name, content)
else:
print("Keeping previous " + name)