-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdosboxconfv6.py
39 lines (33 loc) · 1.39 KB
/
dosboxconfv6.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
33
34
35
36
37
38
39
import copy
categoryOrder = ['[sdl]', '[dosbox]', '[render]', '[cpu]', '[mixer]', '[midi]', '[sblaster]', '[gus]', '[speaker]',
'[joystick]', '[serial]', '[dos]', '[ipx]']
def loadDosboxConf(dosboxFile, dosboxConf):
dosboxConfCopy = copy.deepcopy(dosboxConf)
dosboxConfFile = open(dosboxFile)
currentCategory = None
for line in dosboxConfFile.readlines():
if line.startswith('#'):
continue
if line.startswith('[autoexec]'):
break
if line.startswith('['):
currentCategory = line.rstrip(' \n\r')
if currentCategory not in dosboxConfCopy:
dosboxConfCopy[currentCategory] = dict()
else:
cleanLine = line.rstrip(' \n\r')
if cleanLine != '':
keyValue = cleanLine.split('=')
value = keyValue[1].rstrip(' \n\r').strip(' \n\r')
if value != '':
dosboxConfCopy[currentCategory][keyValue[0].rstrip(' \n\r').strip(' \n\r')] \
= keyValue[1].rstrip(' \n\r').strip(' \n\r')
dosboxConfFile.close()
return dosboxConfCopy
def writeDosboxConf(path, dosboxConf):
file = open(path, 'w')
for category in dosboxConf:
file.write(category + '\n')
for key in dosboxConf[category]:
file.write(key + '=' + dosboxConf[category][key] + '\n')
file.close()