-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
63 lines (43 loc) · 1.65 KB
/
main.py
File metadata and controls
63 lines (43 loc) · 1.65 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from utils import XMLGenerator
from utils import MakeXmlPretty
class main:
years = []
allowedYears = [2016, 2017, 2018, 2019]
XMLStart = '<?xml version="1.0" encoding="utf-8" ?><AllTeams>'
def getYearsFromUser(self):
tempInput = input("Please enter some years from 2016 to 2019, with ',' separating it")
tempYears = tempInput.split(",")
try:
tempYearsInt = list(map(int,tempYears))
except:
print("You did not entered correct years")
self.getYearsFromUser()
# print(tempYearsInt)
# print(self.allowedYears)
if filter(lambda x: tempYearsInt in x, self.allowedYears):
self.generateFullXML(tempYearsInt)
else:
print("You did not entered correct years")
self.getYearsFromUser()
def generateFullXML(self, years):
xmlFiles = []
for year in years:
xmlFiles.append(XMLGenerator.GenerateXMLFromYears(year).parseJsonIntoObjects())
with open('teams.xml','a') as file:
file.write(self.XMLStart)
for xml in xmlFiles:
xml.write(open('teams.xml','a'), encoding='unicode')
with open('teams.xml','a') as file:
file.write("</AllTeams>")
self.askForPretty()
def askForPretty(self):
answer = input("Do you want your XML to be pretty? type 'yes' or 'no' ")
if answer == "yes":
MakeXmlPretty.MakeXMLPretty()
elif answer == "no":
print("Completed")
else:
print("Type correct answer")
self.askForPretty()
if __name__ == '__main__':
main().getYearsFromUser()