Skip to content

Commit ee10a94

Browse files
committed
output to file instead of terminal
1 parent 21e3a00 commit ee10a94

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

EUP2UB.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# file handling
2-
#fname = input("Enter file name: ")
3-
#if len(fname) < 1 : fname = "wardrobe.ini"
1+
# input file handling
42
fname = "wardrobe.ini"
53
try:
6-
fhand = open(fname)
4+
inHand = open(fname, 'r')
75
except:
86
print('File cannot be opened:', fname)
97
exit()
108

9+
# output file handling
10+
outputName = "UB_ped_xml.txt"
11+
try:
12+
outHand = open(outputName, 'w')
13+
except:
14+
print('File cannot be opened:', outputName)
15+
exit()
16+
1117
#vars
1218
wardrobeName = ""
1319
wardrobeDict = dict()
@@ -32,7 +38,7 @@
3238
}
3339

3440
# consume wardrobe.ini
35-
for line in fhand:
41+
for line in inHand:
3642
line = line.rstrip()
3743
if line.startswith("[") : #find start of individual wardrobe and save/print name
3844
wardrobeName = line.strip('[]')
@@ -63,7 +69,8 @@
6369
#use dict.get to pull xref and create output
6470
#loop through data structure and output
6571
for wardrobe in allWardrobes :
66-
print(wardrobe)
72+
#print(wardrobe)
73+
outHand.write(wardrobe + "\n")
6774
#print(allWardrobes[wardrobe])
6875
output = "<Ped"
6976
for comp in allWardrobes[wardrobe] :
@@ -88,5 +95,9 @@
8895

8996
#print(allWardrobes[wardrobe][comp])
9097

91-
output += ">{}</Ped>".format(pedName)
92-
print(output, "\n")
98+
output += ">{}</Ped>\n\n".format(pedName)
99+
#print(output)
100+
outHand.write(output)
101+
102+
inHand.close()
103+
outHand.close()

0 commit comments

Comments
 (0)