Move data-grabbing functions to the classes.

This commit is contained in:
Elliott Pardee 2018-08-23 11:45:47 -04:00
parent df64f9b3d3
commit 1b92b9bc24
4 changed files with 236 additions and 284 deletions

193
.idea/workspace.xml generated
View File

@ -2,7 +2,10 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c8edefbc-71df-41a9-9878-b830c52cd7b5" name="Default Changelist" comment=""> <list default="true" id="c8edefbc-71df-41a9-9878-b830c52cd7b5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/goarch_api/daily.py" beforeDir="false" afterPath="$PROJECT_DIR$/goarch_api/daily.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/goarch_api/lectionary.py" beforeDir="false" afterPath="$PROJECT_DIR$/goarch_api/lectionary.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/goarch_api/saint.py" beforeDir="false" afterPath="$PROJECT_DIR$/goarch_api/saint.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -14,8 +17,10 @@
<session id="1829562699"> <session id="1829562699">
<usages-collector id="statistics.lifecycle.project"> <usages-collector id="statistics.lifecycle.project">
<counts> <counts>
<entry key="project.closed" value="1" />
<entry key="project.open.time.2" value="1" />
<entry key="project.open.time.4" value="1" /> <entry key="project.open.time.4" value="1" />
<entry key="project.opened" value="1" /> <entry key="project.opened" value="2" />
</counts> </counts>
</usages-collector> </usages-collector>
<usages-collector id="statistics.file.extensions.open"> <usages-collector id="statistics.file.extensions.open">
@ -40,7 +45,7 @@
<entry key="dummy" value="14" /> <entry key="dummy" value="14" />
<entry key="gitignore" value="1" /> <entry key="gitignore" value="1" />
<entry key="md" value="690" /> <entry key="md" value="690" />
<entry key="py" value="11414" /> <entry key="py" value="11444" />
<entry key="txt" value="122" /> <entry key="txt" value="122" />
</counts> </counts>
</usages-collector> </usages-collector>
@ -48,7 +53,7 @@
<counts> <counts>
<entry key="Markdown" value="690" /> <entry key="Markdown" value="690" />
<entry key="PLAIN_TEXT" value="137" /> <entry key="PLAIN_TEXT" value="137" />
<entry key="Python" value="11476" /> <entry key="Python" value="11506" />
</counts> </counts>
</usages-collector> </usages-collector>
</session> </session>
@ -57,13 +62,13 @@
<favorites_list name="goarch_api" /> <favorites_list name="goarch_api" />
</component> </component>
<component name="FileEditorManager"> <component name="FileEditorManager">
<leaf> <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/README.md"> <entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT"> <state split_layout="SPLIT">
<first_editor relative-caret-position="92"> <first_editor relative-caret-position="161">
<caret line="4" column="78" lean-forward="true" selection-start-line="4" selection-start-column="78" selection-end-line="4" selection-end-column="78" /> <caret line="7" selection-start-line="7" selection-end-line="7" />
</first_editor> </first_editor>
<second_editor /> <second_editor />
</state> </state>
@ -82,7 +87,7 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1388"> <state relative-caret-position="3082">
<caret line="134" column="7" selection-start-line="134" selection-start-column="7" selection-end-line="134" selection-end-column="7" /> <caret line="134" column="7" selection-start-line="134" selection-start-column="7" selection-end-line="134" selection-end-column="7" />
</state> </state>
</provider> </provider>
@ -96,8 +101,8 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/LICENSE.txt"> <entry file="file://$PROJECT_DIR$/LICENSE.txt">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="314"> <state relative-caret-position="15502">
<caret line="674" lean-forward="true" selection-start-line="674" selection-end-line="674" /> <caret line="674" selection-start-line="674" selection-end-line="674" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -116,15 +121,15 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/goarch_api/daily.py"> <entry file="file://$PROJECT_DIR$/goarch_api/daily.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="92"> <state relative-caret-position="174">
<caret line="4" column="34" selection-start-line="4" selection-start-column="34" selection-end-line="4" selection-end-column="34" /> <caret line="62" column="51" selection-start-line="62" selection-start-column="51" selection-end-line="62" selection-end-column="51" />
<folding> <folding>
<element signature="e#0#22#0" expanded="true" /> <element signature="e#0#22#0" expanded="true" />
<marker date="1535019752828" expanded="true" signature="1780:1785" ph="..." /> <marker date="1535039127435" expanded="true" signature="165:170" ph="..." />
<marker date="1535019752828" expanded="true" signature="1815:2051" ph="..." /> <marker date="1535039127435" expanded="true" signature="200:438" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -132,20 +137,14 @@
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/goarch_api/models.py"> <entry file="file://$PROJECT_DIR$/goarch_api/models.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor" />
<state>
<folding>
<marker date="1535024528601" expanded="true" signature="2013:2247" ph="..." />
</folding>
</state>
</provider>
</entry> </entry>
</file> </file>
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/goarch_api/saint.py"> <entry file="file://$PROJECT_DIR$/goarch_api/saint.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="943"> <state relative-caret-position="220">
<caret line="41" column="39" selection-start-line="41" selection-start-column="39" selection-end-line="41" selection-end-column="39" /> <caret line="17" column="66" selection-start-line="17" selection-start-column="66" selection-end-line="17" selection-end-column="66" />
<folding> <folding>
<element signature="e#0#9#0" expanded="true" /> <element signature="e#0#9#0" expanded="true" />
</folding> </folding>
@ -156,11 +155,11 @@
<file pinned="false" current-in-tab="false"> <file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/goarch_api/lectionary.py"> <entry file="file://$PROJECT_DIR$/goarch_api/lectionary.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1702"> <state relative-caret-position="174">
<caret line="74" selection-start-line="74" selection-end-line="74" /> <caret line="69" column="63" selection-start-line="69" selection-start-column="63" selection-end-line="69" selection-end-column="63" />
<folding> <folding>
<element signature="e#0#9#0" expanded="true" /> <element signature="e#0#9#0" expanded="true" />
<marker date="1535020618448" expanded="true" signature="246:2121" ph="..." /> <marker date="1535039114263" expanded="true" signature="219:222" ph="..." />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -203,6 +202,9 @@
<option value="$PROJECT_DIR$/setup.py" /> <option value="$PROJECT_DIR$/setup.py" />
<option value="$PROJECT_DIR$/goarch_api/client.py" /> <option value="$PROJECT_DIR$/goarch_api/client.py" />
<option value="$PROJECT_DIR$/README.md" /> <option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/goarch_api/saint.py" />
<option value="$PROJECT_DIR$/goarch_api/lectionary.py" />
<option value="$PROJECT_DIR$/goarch_api/daily.py" />
</list> </list>
</option> </option>
</component> </component>
@ -363,14 +365,9 @@
<frame x="54" y="27" width="1312" height="741" extended-state="6" /> <frame x="54" y="27" width="1312" height="741" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="Favorites" sideWeight="0.18271606" side_tool="true" weight="0.24980605" /> <window_info active="true" content_ui="combo" id="Project" order="0" sideWeight="0.8172839" visible="true" weight="0.24980605" />
<window_info content_ui="combo" id="Project" order="0" sideWeight="0.8172839" visible="true" weight="0.24980605" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Thumbnails" weight="0.3294702" /> <window_info id="Favorites" order="2" sideWeight="0.18271606" side_tool="true" weight="0.24980605" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Python Console" weight="0.3294702" />
<window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.3305648" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" /> <window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.3294702" /> <window_info anchor="bottom" id="Run" order="2" weight="0.3294702" />
@ -378,6 +375,11 @@
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" weight="0.3294702" /> <window_info anchor="bottom" id="TODO" order="6" weight="0.3294702" />
<window_info anchor="bottom" id="Thumbnails" order="7" weight="0.3294702" />
<window_info anchor="bottom" id="Version Control" order="8" />
<window_info anchor="bottom" id="Terminal" order="9" visible="true" weight="0.3305648" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Python Console" order="11" weight="0.3294702" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
@ -387,89 +389,44 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="editorHistoryManager"> <component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/venv/lib/python3.6/site-packages/aiohttp/client.py"> <entry file="file://$PROJECT_DIR$/venv/lib/python3.6/site-packages/aiohttp/client.py" />
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="120">
<caret line="70" column="6" selection-start-line="70" selection-start-column="6" selection-end-line="70" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/venv/lib/python3.6/site-packages/lxml/__init__.py"> <entry file="file://$PROJECT_DIR$/venv/lib/python3.6/site-packages/lxml/__init__.py">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/goarch_api/translation.py"> <entry file="file://$PROJECT_DIR$/src/goarch_api/translation.py" />
<provider selected="true" editor-type-id="text-editor"> <entry file="file://$PROJECT_DIR$/src/goarch_api/reading.py" />
<state relative-caret-position="138"> <entry file="file://$PROJECT_DIR$/src/test_all.py" />
<caret line="6" column="24" lean-forward="true" selection-end-line="14" /> <entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="161">
<caret line="7" selection-start-line="7" selection-end-line="7" />
</first_editor>
<second_editor />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/goarch_api/reading.py"> <entry file="file://$PROJECT_DIR$/setup.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="431"> <state relative-caret-position="115">
<caret line="22" lean-forward="true" selection-start-line="22" selection-end-line="22" /> <caret line="5" column="23" selection-start-line="5" selection-start-column="23" selection-end-line="5" selection-end-column="23" />
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/src/test_all.py"> <entry file="file://$PROJECT_DIR$/.gitignore">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="46"> <state relative-caret-position="3082">
<caret line="2" column="29" selection-start-line="2" selection-start-column="29" selection-end-line="2" selection-end-column="29" /> <caret line="134" column="7" selection-start-line="134" selection-start-column="7" selection-end-line="134" selection-end-column="7" />
<folding>
<element signature="e#0#34#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/goarch_api/daily.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="92">
<caret line="4" column="34" selection-start-line="4" selection-start-column="34" selection-end-line="4" selection-end-column="34" />
<folding>
<element signature="e#0#22#0" expanded="true" />
<marker date="1535019752828" expanded="true" signature="1780:1785" ph="..." />
<marker date="1535019752828" expanded="true" signature="1815:2051" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/goarch_api/saint.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="943">
<caret line="41" column="39" selection-start-line="41" selection-start-column="39" selection-end-line="41" selection-end-column="39" />
<folding>
<element signature="e#0#9#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/goarch_api/lectionary.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1702">
<caret line="74" selection-start-line="74" selection-end-line="74" />
<folding>
<element signature="e#0#9#0" expanded="true" />
<marker date="1535020618448" expanded="true" signature="246:2121" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/MANIFEST"> <entry file="file://$PROJECT_DIR$/MANIFEST">
<provider selected="true" editor-type-id="text-editor" /> <provider selected="true" editor-type-id="text-editor" />
</entry> </entry>
<entry file="file://$PROJECT_DIR$/goarch_api/models.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<folding>
<marker date="1535024528601" expanded="true" signature="2013:2247" ph="..." />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/LICENSE.txt"> <entry file="file://$PROJECT_DIR$/LICENSE.txt">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="314"> <state relative-caret-position="15502">
<caret line="674" lean-forward="true" selection-start-line="674" selection-end-line="674" /> <caret line="674" selection-start-line="674" selection-end-line="674" />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -485,27 +442,39 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/setup.py"> <entry file="file://$PROJECT_DIR$/goarch_api/models.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/goarch_api/lectionary.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="115"> <state relative-caret-position="174">
<caret line="5" column="23" selection-start-line="5" selection-start-column="23" selection-end-line="5" selection-end-column="23" /> <caret line="69" column="63" selection-start-line="69" selection-start-column="63" selection-end-line="69" selection-end-column="63" />
<folding>
<element signature="e#0#9#0" expanded="true" />
<marker date="1535039114263" expanded="true" signature="219:222" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/.gitignore"> <entry file="file://$PROJECT_DIR$/goarch_api/saint.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1388"> <state relative-caret-position="220">
<caret line="134" column="7" selection-start-line="134" selection-start-column="7" selection-end-line="134" selection-end-column="7" /> <caret line="17" column="66" selection-start-line="17" selection-start-column="66" selection-end-line="17" selection-end-column="66" />
<folding>
<element signature="e#0#9#0" expanded="true" />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/README.md"> <entry file="file://$PROJECT_DIR$/goarch_api/daily.py">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]"> <provider selected="true" editor-type-id="text-editor">
<state split_layout="SPLIT"> <state relative-caret-position="174">
<first_editor relative-caret-position="92"> <caret line="62" column="51" selection-start-line="62" selection-start-column="51" selection-end-line="62" selection-end-column="51" />
<caret line="4" column="78" lean-forward="true" selection-start-line="4" selection-start-column="78" selection-end-line="4" selection-end-column="78" /> <folding>
</first_editor> <element signature="e#0#22#0" expanded="true" />
<second_editor /> <marker date="1535039127435" expanded="true" signature="165:170" ph="..." />
<marker date="1535039127435" expanded="true" signature="200:438" ph="..." />
</folding>
</state> </state>
</provider> </provider>
</entry> </entry>

View File

@ -5,66 +5,59 @@ from goarch_api.models import Reading, Translation
from goarch_api.saint import Saint from goarch_api.saint import Saint
def get_data(self):
client = HTTPClient()
resp = client.get(self.path)
if resp is not None:
tree = etree.fromstring(resp.encode())
date = tree.find("date").text
self.formatted_date = tree.find("formatteddate").text
self.icon = tree.find("icon").text
self.fasting = tree.find("fasting").text
self.tone = tree.find("tone").text
self.readings = []
for reading in tree.find("readings").iterchildren():
_id = reading.get("id")
_type = reading.find("type").text
type_bb = reading.find("typebb").text
event = reading.find("event").text
translation = reading.find("translation")
t_lang = translation.get("xml:lang")
t_title = translation.find("title").text
t_short_title = translation.find("shorttitle").text
# more often than not, these things have a newline after the text in the element
t_clip = translation.find("clip").text.strip()
converted_translation = Translation(title=t_title, short_title=t_short_title, clip=t_clip, lang=t_lang)
converted_reading = Reading(_id, _type, type_bb, event, translation=converted_translation, date=date)
self.readings.append(converted_reading)
self.lectionary_title = tree.find("lectionarytitle").text.strip()
self.saints = []
for saint in tree.find("saintsfeasts").iterchildren():
_id = saint.find("id").text
converted_saint = Saint(_id)
self.saints.append(converted_saint)
class Daily: class Daily:
def __init__(self, date=None): def __init__(self, date=None):
self.date = date self.date = date
self.path = "/daily.asp" self._path = "/daily.asp"
self.public_url = "https://www.goarch.org/chapel" self.public_url = "https://www.goarch.org/chapel"
if date is not None: if date is not None:
self.path += f"?date={date}" self._path += f"?date={date}"
self.public_url += f"?date={date}" self.public_url += f"?date={date}"
get_data(self) def get_data(self):
client = HTTPClient()
resp = client.get(self._path)
if __name__ == "__main__": if resp is not None:
daily = Daily(date="8/15/2018") tree = etree.fromstring(resp.encode())
date = tree.find("date").text
self.formatted_date = tree.find("formatteddate").text
self.icon = tree.find("icon").text
self.fasting = tree.find("fasting").text
self.tone = tree.find("tone").text
self.readings = []
for reading in tree.find("readings").iterchildren():
_id = reading.get("id")
_type = reading.find("type").text
type_bb = reading.find("typebb").text
event = reading.find("event").text
translation = reading.find("translation")
t_lang = translation.get("xml:lang")
t_title = translation.find("title").text
t_short_title = translation.find("shorttitle").text
# more often than not, these things have a newline after the text in the element
t_clip = translation.find("clip").text.strip()
converted_translation = Translation(title=t_title, short_title=t_short_title, clip=t_clip, lang=t_lang)
converted_reading = Reading(_id, _type, type_bb, event, translation=converted_translation, date=date)
self.readings.append(converted_reading)
self.lectionary_title = tree.find("lectionarytitle").text.strip()
self.saints = []
for saint in tree.find("saintsfeasts").iterchildren():
_id = saint.find("id").text
converted_saint = Saint(_id)
self.saints.append(converted_saint)

View File

@ -11,50 +11,6 @@ def remove_html_tags(raw):
return re.sub(regex, " ", raw) return re.sub(regex, " ", raw)
def lect_get_data(self):
client = HTTPClient()
resp = client.get(self.path)
if resp is not None:
tree = etree.fromstring(resp.encode())
self.display_title = tree.find("displaytitle").text
self.event = tree.find("event").text
self.prokeimenon = tree.find("prokeimenon").text
icon = tree.find("icon")
i_file_path = icon.find("url").text.replace("http://onlinechapel.goarch.org/images/", "")
i_copyright = icon.find("copyright").text
self.icon = Icon(i_file_path, i_copyright)
self.translations = []
for translation in tree.findall("translation"):
lang = translation.get("xml:lang")
title = translation.find("title").text
short_title = translation.find("shorttitle").text
clip = translation.find("clip").text.strip()
body = remove_html_tags(translation.find("body").text).strip()
if self.type == "epistle":
prok_mode = translation.find("prokmode").text
prok_psalm = translation.find("prokpsalm").text.replace(": ", ":")
prok_prokeimenon = translation.find("prokprokeimenon").text
prok_verse = translation.find("prokverse").text
converted_translation = Translation(lang=lang, title=title, short_title=short_title,
clip=clip, body=body, prok_mode=prok_mode,
prok_psalm=prok_psalm, prok_prokeimenon=prok_prokeimenon,
prok_verse=prok_verse)
else:
converted_translation = Translation(lang=lang, title=title, short_title=short_title,
clip=clip, body=body)
self.translations.append(converted_translation)
class Lectionary: class Lectionary:
# this class will provide full readings from Reading objects # this class will provide full readings from Reading objects
def __init__(self, _type, code, event, date=None): def __init__(self, _type, code, event, date=None):
@ -63,15 +19,52 @@ class Lectionary:
self.event = event self.event = event
self.date = date self.date = date
self.path = f"/lectionary.asp?type={_type}&code={str(code)}&event={str(event)}" self._path = f"/lectionary.asp?type={_type}&code={str(code)}&event={str(event)}"
self.public_url = f"https://www.goarch.org/chapel/lectionary?type={_type}&code={str(code)}&event={str(event)}" self.public_url = f"https://www.goarch.org/chapel/lectionary?type={_type}&code={str(code)}&event={str(event)}"
if date is not None: if date is not None:
self.path += f"&date={date}" self._path += f"&date={date}"
self.public_url += f"&date={date}" self.public_url += f"&date={date}"
lect_get_data(self) def get_data(self):
client = HTTPClient()
resp = client.get(self._path)
if __name__ == "__main__": if resp is not None:
lect = Lectionary("MG", 370, 165) tree = etree.fromstring(resp.encode())
self.display_title = tree.find("displaytitle").text
self.event = tree.find("event").text
self.prokeimenon = tree.find("prokeimenon").text
icon = tree.find("icon")
i_file_path = icon.find("url").text.replace("http://onlinechapel.goarch.org/images/", "")
i_copyright = icon.find("copyright").text
self.icon = Icon(i_file_path, i_copyright)
self.translations = []
for translation in tree.findall("translation"):
lang = translation.get("xml:lang")
title = translation.find("title").text
short_title = translation.find("shorttitle").text
clip = translation.find("clip").text.strip()
body = remove_html_tags(translation.find("body").text).strip()
if self.type == "epistle":
prok_mode = translation.find("prokmode").text
prok_psalm = translation.find("prokpsalm").text.replace(": ", ":")
prok_prokeimenon = translation.find("prokprokeimenon").text
prok_verse = translation.find("prokverse").text
converted_translation = Translation(lang=lang, title=title, short_title=short_title,
clip=clip, body=body, prok_mode=prok_mode,
prok_psalm=prok_psalm, prok_prokeimenon=prok_prokeimenon,
prok_verse=prok_verse)
else:
converted_translation = Translation(lang=lang, title=title, short_title=short_title,
clip=clip, body=body)
self.translations.append(converted_translation)

View File

@ -11,78 +11,75 @@ def remove_html_tags(raw):
return re.sub(regex, " ", raw) return re.sub(regex, " ", raw)
def saint_get_data(self):
client = HTTPClient()
resp = client.get(self.path)
if resp is not None:
tree = etree.fromstring(resp.encode())
self.date = tree.find("date").text
self.title = tree.find("title").text
self.display_date = tree.find("displaydate").text
self.date = tree.find("date").text
self.icons = []
for icon in tree.find("icons").iterchildren():
_id = icon.get("id")
file_path = icon.find("filepath").text
_copyright = icon.find("copyright").text
converted_icon = Icon(_id, file_path, _copyright)
self.icons.append(converted_icon)
self.lectionary = []
for reading in tree.find("lectionary").iterchildren():
_id = reading.find("id").text
_type = reading.get("type")
lectionary_reading = LectionaryReading(_id, _type)
self.lectionary.append(lectionary_reading)
self.readings = []
for reading in tree.find("readings").iterchildren():
lang = reading.get("xml:lang")
title = reading.find("title").text
short_title = reading.find("shorttitle").text
body = remove_html_tags(reading.find("body").text).strip()
_copyright = reading.find("copyright").text
converted_translation = Translation(title=title, short_title=short_title, lang=lang,
body=body, _copyright=_copyright)
self.readings.append(converted_translation)
self.hymns = []
for hymn in tree.find("hymns").iterchildren():
_type = hymn.find("type").text
title = hymn.find("title").text
short_title = hymn.find("shorttitle").text
tone = hymn.find("tone").text
translation = hymn.find("translation")
t_lang = translation.get("xml:lang")
t_body = translation.find("body").text
t_copyright = translation.find("copyright").text
converted_translation = Translation(lang=t_lang, body=t_body, _copyright=t_copyright)
converted_hymn = Hymn(_type, title, short_title, tone, converted_translation)
self.hymns.append(converted_hymn)
class Saint: class Saint:
def __init__(self, _id): def __init__(self, _id):
self.id = _id self.id = _id
self.path = f"/saints.asp?contentid={_id}" self._path = f"/saints.asp?contentid={_id}"
self.public_url = f"https://www.goarch.org/chapel/saints?contentid={_id}" self.public_url = f"https://www.goarch.org/chapel/saints?contentid={_id}"
saint_get_data(self) def get_data(self):
client = HTTPClient()
resp = client.get(self._path)
if resp is not None:
tree = etree.fromstring(resp.encode())
self.date = tree.find("date").text
self.title = tree.find("title").text
self.display_date = tree.find("displaydate").text
self.date = tree.find("date").text
self.icons = []
for icon in tree.find("icons").iterchildren():
_id = icon.get("id")
file_path = icon.find("filepath").text
_copyright = icon.find("copyright").text
converted_icon = Icon(_id, file_path, _copyright)
self.icons.append(converted_icon)
self.lectionary = []
for reading in tree.find("lectionary").iterchildren():
_id = reading.find("id").text
_type = reading.get("type")
lectionary_reading = LectionaryReading(_id, _type)
self.lectionary.append(lectionary_reading)
self.readings = []
for reading in tree.find("readings").iterchildren():
lang = reading.get("xml:lang")
title = reading.find("title").text
short_title = reading.find("shorttitle").text
body = remove_html_tags(reading.find("body").text).strip()
_copyright = reading.find("copyright").text
converted_translation = Translation(title=title, short_title=short_title, lang=lang,
body=body, _copyright=_copyright)
self.readings.append(converted_translation)
self.hymns = []
for hymn in tree.find("hymns").iterchildren():
_type = hymn.find("type").text
title = hymn.find("title").text
short_title = hymn.find("shorttitle").text
tone = hymn.find("tone").text
translation = hymn.find("translation")
t_lang = translation.get("xml:lang")
t_body = translation.find("body").text
t_copyright = translation.find("copyright").text
converted_translation = Translation(lang=t_lang, body=t_body, _copyright=t_copyright)
converted_hymn = Hymn(_type, title, short_title, tone, converted_translation)
self.hymns.append(converted_hymn)