-
Notifications
You must be signed in to change notification settings - Fork 1
/
page.py
48 lines (42 loc) · 1.21 KB
/
page.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
40
41
42
43
44
45
46
47
48
class Page:
dataTypes = {"version" : "text", "book" : "text",
"date" : "int", "verse" : "int", "line" : "text"}
def __init__(self, version, book, chapter, verses, url):
self.version = version
self.book = book
self.chapter = chapter
self.verses = verses
self.url = url
def unify_verses(self, single_line=True):
if (single_line):
for verse in self.verses:
line = ""
for word in self.verses[verse]:
line += word + " "
self.verses[verse] = line[:len(line) - 1]
else:
body = ""
for verse in self.verses:
for word in self.verses[verse]:
body += word + " "
body += "\n"
return body
def text_write(self, name):
text = open(name, 'a')
text.write(self.url + "\n")
text.write(self.version + "\n")
text.write(self.book + " " + str(self.chapter) + "\n\n")
for verse in self.verses:
decoded = self.verses[verse].encode('utf-8')
text.write(str(verse) + ": " + decoded + "\n")
text.close()
def exportData(self):
dictList = []
for verseNum in verses:
contentDict = {"version" : version,
"book" : book,
"chapter": chapter,
"verse" : verseNum,
"line" : verses[verseNum]}
dictList.append(contentDict)
return dictList