+ 1548647185510
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ donationlist
+ Python
+ EXPRESSION
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/students/robert_kesterson/lesson07/html_render.py b/students/robert_kesterson/lesson07/html_render.py
new file mode 100644
index 0000000..508400f
--- /dev/null
+++ b/students/robert_kesterson/lesson07/html_render.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+"""
+A class-based system for rendering html.
+"""
+
+
+# This is the framework for the base class
+class Element(object):
+
+ def __init__(self, content=None):
+ pass
+
+ def append(self, new_content):
+ pass
+
+ def render(self, out_file):
+ out_file.write("just something as a place holder...")
diff --git a/students/robert_kesterson/lesson07/run_html_render.py b/students/robert_kesterson/lesson07/run_html_render.py
new file mode 100644
index 0000000..9608a65
--- /dev/null
+++ b/students/robert_kesterson/lesson07/run_html_render.py
@@ -0,0 +1,231 @@
+#!/usr/bin/env python3
+
+"""
+a simple script can run and test your html rendering classes.
+
+Uncomment the steps as you add to your rendering.
+
+"""
+
+from io import StringIO
+
+# importing the html_rendering code with a short name for easy typing.
+import html_render as hr
+
+
+# writing the file out:
+def render_page(page, filename, indent=None):
+ """
+ render the tree of elements
+
+ This uses StringIO to render to memory, then dump to console and
+ write to file -- very handy!
+ """
+
+ f = StringIO()
+ if indent is None:
+ page.render(f)
+ else:
+ page.render(f, indent)
+
+ print(f.getvalue())
+ with open(filename, 'w') as outfile:
+ outfile.write(f.getvalue())
+
+
+# Step 1
+#########
+
+page = hr.Element()
+
+page.append("Here is a paragraph of text -- there could be more of them, "
+ "but this is enough to show that we can do some text")
+
+page.append("And here is another piece of text -- you should be able to add any number")
+
+render_page(page, "test_html_output1.html")
+
+# The rest of the steps have been commented out.
+# Uncomment them as you move along with the assignment.
+
+# ## Step 2
+# ##########
+
+# page = hr.Html()
+
+# body = hr.Body()
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text"))
+
+# body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
+
+# page.append(body)
+
+# render_page(page, "test_html_output2.html")
+
+# # Step 3
+# ##########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text"))
+# body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
+
+# page.append(body)
+
+# render_page(page, "test_html_output3.html")
+
+# # Step 4
+# ##########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text",
+# style="text-align: center; font-style: oblique;"))
+
+# page.append(body)
+
+# render_page(page, "test_html_output4.html")
+
+# # Step 5
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text",
+# style="text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# page.append(body)
+
+# render_page(page, "test_html_output5.html")
+
+# # Step 6
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text",
+# style="text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# body.append("And this is a ")
+# body.append( hr.A("http://google.com", "link") )
+# body.append("to google")
+
+# page.append(body)
+
+# render_page(page, "test_html_output6.html")
+
+# # Step 7
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append( hr.H(2, "PythonClass - Class 6 example") )
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text",
+# style="text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# list = hr.Ul(id="TheList", style="line-height:200%")
+
+# list.append( hr.Li("The first item in a list") )
+# list.append( hr.Li("This is the second item", style="color: red") )
+
+# item = hr.Li()
+# item.append("And this is a ")
+# item.append( hr.A("http://google.com", "link") )
+# item.append("to google")
+
+# list.append(item)
+
+# body.append(list)
+
+# page.append(body)
+
+# render_page(page, "test_html_output7.html")
+
+# # Step 8 and 9
+# ##############
+
+# page = hr.Html()
+
+
+# head = hr.Head()
+# head.append( hr.Meta(charset="UTF-8") )
+# head.append(hr.Title("PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append( hr.H(2, "PythonClass - Example") )
+
+# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
+# "but this is enough to show that we can do some text",
+# style="text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# list = hr.Ul(id="TheList", style="line-height:200%")
+
+# list.append( hr.Li("The first item in a list") )
+# list.append( hr.Li("This is the second item", style="color: red") )
+
+# item = hr.Li()
+# item.append("And this is a ")
+# item.append( hr.A("http://google.com", "link") )
+# item.append("to google")
+
+# list.append(item)
+
+# body.append(list)
+
+# page.append(body)
+
+# render_page(page, "test_html_output8.html")
diff --git a/students/robert_kesterson/lesson07/sample_html.html b/students/robert_kesterson/lesson07/sample_html.html
new file mode 100644
index 0000000..9c2e675
--- /dev/null
+++ b/students/robert_kesterson/lesson07/sample_html.html
@@ -0,0 +1,27 @@
+
+
+
+
+ Python Class Sample page
+
+
+
Python Class - Html rendering example
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
\ No newline at end of file
diff --git a/students/robert_kesterson/lesson07/test_html_render.py b/students/robert_kesterson/lesson07/test_html_render.py
new file mode 100644
index 0000000..5833d50
--- /dev/null
+++ b/students/robert_kesterson/lesson07/test_html_render.py
@@ -0,0 +1,264 @@
+"""
+test code for html_render.py
+
+This is just a start -- you will need more tests!
+"""
+
+import io
+import pytest
+
+# import * is often bad form, but makes it easier to test everything in a module.
+from html_render import *
+
+
+# utility function for testing render methods
+# needs to be used in multiple tests, so we write it once here.
+def render_result(element, ind=""):
+ """
+ calls the element's render method, and returns what got rendered as a
+ string
+ """
+ # the StringIO object is a "file-like" object -- something that
+ # provides the methods of a file, but keeps everything in memory
+ # so it can be used to test code that writes to a file, without
+ # having to actually write to disk.
+ outfile = io.StringIO()
+ # this so the tests will work before we tackle indentation
+ if ind:
+ element.render(outfile, ind)
+ else:
+ element.render(outfile)
+ return outfile.getvalue()
+
+########
+# Step 1
+########
+
+def test_init():
+ """
+ This only tests that it can be initialized with and without
+ some content -- but it's a start
+ """
+ e = Element()
+
+ e = Element("this is some text")
+
+
+def test_append():
+ """
+ This tests that you can append text
+
+ It doesn't test if it works --
+ that will be covered by the render test later
+ """
+ e = Element("this is some text")
+ e.append("some more text")
+
+
+def test_render_element():
+ """
+ Tests whether the Element can render two pieces of text
+ So it is also testing that the append method works correctly.
+
+ It is not testing whether indentation or line feeds are correct.
+ """
+ e = Element("this is some text")
+ e.append("and this is some more text")
+
+ # This uses the render_results utility above
+ file_contents = render_result(e).strip()
+
+ # making sure the content got in there.
+ assert("this is some text") in file_contents
+ assert("and this is some more text") in file_contents
+
+ # make sure it's in the right order
+ assert file_contents.index("this is") < file_contents.index("and this")
+
+ # making sure the opening and closing tags are right.
+ assert file_contents.startswith("")
+ assert file_contents.endswith("")
+
+# # Uncomment this one after you get the one above to pass
+# # Does it pass right away?
+# def test_render_element2():
+# """
+# Tests whether the Element can render two pieces of text
+# So it is also testing that the append method works correctly.
+
+# It is not testing whether indentation or line feeds are correct.
+# """
+# e = Element()
+# e.append("this is some text")
+# e.append("and this is some more text")
+
+# # This uses the render_results utility above
+# file_contents = render_result(e).strip()
+
+# # making sure the content got in there.
+# assert("this is some text") in file_contents
+# assert("and this is some more text") in file_contents
+
+# # make sure it's in the right order
+# assert file_contents.index("this is") < file_contents.index("and this")
+
+# # making sure the opening and closing tags are right.
+# assert file_contents.startswith("")
+# assert file_contents.endswith("")
+
+
+
+# # ########
+# # # Step 2
+# # ########
+
+# # tests for the new tags
+# def test_html():
+# e = Html("this is some text")
+# e.append("and this is some more text")
+
+# file_contents = render_result(e).strip()
+
+# assert("this is some text") in file_contents
+# assert("and this is some more text") in file_contents
+# print(file_contents)
+# assert file_contents.endswith("