Skip to content
This repository was archived by the owner on Oct 9, 2018. It is now read-only.

Commit 6258325

Browse files
authored
Merge pull request #125 from lukeatuwpce/master
Session 11 (and crusty session 09) assignment
2 parents de7bff0 + 8285403 commit 6258325

11 files changed

+731
-361
lines changed

students/luke/s07/run_html_render.py

100644100755
Lines changed: 122 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
"""
44
a simple script can run and test your html rendering classes.
@@ -29,7 +29,8 @@ def render_page(page, filename):
2929
with open(filename, 'w') as outfile:
3030
outfile.write(f.getvalue())
3131

32-
32+
"""
33+
#########
3334
# Step 1
3435
#########
3536
@@ -45,184 +46,194 @@ def render_page(page, filename):
4546
# The rest of the steps have been commented out.
4647
# Uncomment them as you move along with the assignment.
4748
48-
# ## Step 2
49-
# ##########
49+
##########
50+
# Step 2
51+
##########
5052
51-
# page = hr.Html()
53+
page = hr.Html()
5254
53-
# body = hr.Body()
55+
body = hr.Body()
5456
55-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
56-
# "but this is enough to show that we can do some text"))
57+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
58+
"but this is enough to show that we can do some text"))
5759
58-
# body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
60+
body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
5961
60-
# page.append(body)
62+
page.append(body)
6163
62-
# render_page(page, "test_html_output2.html")
64+
render_page(page, "test_html_output2.html")
6365
64-
# # Step 3
65-
# ##########
66+
##########
67+
# Step 3
68+
##########
6669
67-
# page = hr.Html()
70+
page = hr.Html()
6871
69-
# head = hr.Head()
70-
# head.append(hr.Title("PythonClass = Revision 1087:"))
72+
head = hr.Head()
73+
head.append(hr.Title("PythonClass = Revision 1087:"))
7174
72-
# page.append(head)
75+
page.append(head)
7376
74-
# body = hr.Body()
77+
body = hr.Body()
7578
76-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
77-
# "but this is enough to show that we can do some text"))
78-
# body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
79+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
80+
"but this is enough to show that we can do some text"))
81+
body.append(hr.P("And here is another piece of text -- you should be able to add any number"))
7982
80-
# page.append(body)
83+
page.append(body)
8184
82-
# render_page(page, "test_html_output3.html")
85+
render_page(page, "test_html_output3.html")
8386
84-
# # Step 4
85-
# ##########
87+
##########
88+
# Step 4
89+
##########
8690
87-
# page = hr.Html()
91+
page = hr.Html()
8892
89-
# head = hr.Head()
90-
# head.append(hr.Title("PythonClass = Revision 1087:"))
93+
head = hr.Head()
94+
head.append(hr.Title("PythonClass = Revision 1087:"))
9195
92-
# page.append(head)
96+
page.append(head)
9397
94-
# body = hr.Body()
98+
body = hr.Body()
9599
96-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
97-
# "but this is enough to show that we can do some text",
98-
# style="text-align: center; font-style: oblique;"))
100+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
101+
"but this is enough to show that we can do some text",
102+
style="text-align: center; font-style: oblique;"))
99103
100-
# page.append(body)
104+
page.append(body)
101105
102-
# render_page(page, "test_html_output4.html")
106+
render_page(page, "test_html_output4.html")
103107
104-
# # Step 5
105-
# #########
108+
#########
109+
# Step 5
110+
#########
106111
107-
# page = hr.Html()
112+
page = hr.Html()
108113
109-
# head = hr.Head()
110-
# head.append(hr.Title("PythonClass = Revision 1087:"))
114+
head = hr.Head()
115+
head.append(hr.Title("PythonClass = Revision 1087:"))
111116
112-
# page.append(head)
117+
page.append(head)
113118
114-
# body = hr.Body()
119+
body = hr.Body()
115120
116-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
117-
# "but this is enough to show that we can do some text",
118-
# style="text-align: center; font-style: oblique;"))
121+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
122+
"but this is enough to show that we can do some text",
123+
style="text-align: center; font-style: oblique;"))
119124
120-
# body.append(hr.Hr())
125+
body.append(hr.Hr())
121126
122-
# page.append(body)
127+
page.append(body)
123128
124-
# render_page(page, "test_html_output5.html")
129+
render_page(page, "test_html_output5.html")
125130
126-
# # Step 6
127-
# #########
131+
"""
132+
#########
133+
# Step 6
134+
#########
128135

129-
# page = hr.Html()
136+
page = hr.Html()
130137

131-
# head = hr.Head()
132-
# head.append(hr.Title("PythonClass = Revision 1087:"))
138+
head = hr.Head()
139+
head.append(hr.Title("PythonClass = Revision 1087:"))
133140

134-
# page.append(head)
141+
page.append(head)
135142

136-
# body = hr.Body()
143+
body = hr.Body()
137144

138-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
139-
# "but this is enough to show that we can do some text",
140-
# style="text-align: center; font-style: oblique;"))
145+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
146+
"but this is enough to show that we can do some text",
147+
style="text-align: center; font-style: oblique;"))
141148

142-
# body.append(hr.Hr())
149+
body.append(hr.Hr())
143150

144-
# body.append("And this is a ")
145-
# body.append( hr.A("http://google.com", "link") )
146-
# body.append("to google")
151+
body.append("And this is a ")
152+
body.append( hr.A("http://google.com", "link") )
153+
body.append("to google")
147154

148-
# page.append(body)
155+
page.append(body)
149156

150-
# render_page(page, "test_html_output6.html")
157+
render_page(page, "test_html_output6.html")
151158

152-
# # Step 7
153-
# #########
159+
"""
160+
#########
161+
# Step 7
162+
#########
154163
155-
# page = hr.Html()
164+
page = hr.Html()
156165
157-
# head = hr.Head()
158-
# head.append(hr.Title("PythonClass = Revision 1087:"))
166+
head = hr.Head()
167+
head.append(hr.Title("PythonClass = Revision 1087:"))
159168
160-
# page.append(head)
169+
page.append(head)
161170
162-
# body = hr.Body()
171+
body = hr.Body()
163172
164-
# body.append( hr.H(2, "PythonClass - Class 6 example") )
173+
body.append( hr.H(2, "PythonClass - Class 6 example") )
165174
166-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
167-
# "but this is enough to show that we can do some text",
168-
# style="text-align: center; font-style: oblique;"))
175+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
176+
"but this is enough to show that we can do some text",
177+
style="text-align: center; font-style: oblique;"))
169178
170-
# body.append(hr.Hr())
179+
body.append(hr.Hr())
171180
172-
# list = hr.Ul(id="TheList", style="line-height:200%")
181+
list = hr.Ul(id="TheList", style="line-height:200%")
173182
174-
# list.append( hr.Li("The first item in a list") )
175-
# list.append( hr.Li("This is the second item", style="color: red") )
183+
list.append( hr.Li("The first item in a list") )
184+
list.append( hr.Li("This is the second item", style="color: red") )
176185
177-
# item = hr.Li()
178-
# item.append("And this is a ")
179-
# item.append( hr.A("http://google.com", "link") )
180-
# item.append("to google")
186+
item = hr.Li()
187+
item.append("And this is a ")
188+
item.append( hr.A("http://google.com", "link") )
189+
item.append("to google")
181190
182-
# list.append(item)
191+
list.append(item)
183192
184-
# body.append(list)
193+
body.append(list)
185194
186-
# page.append(body)
195+
page.append(body)
187196
188-
# render_page(page, "test_html_output7.html")
197+
render_page(page, "test_html_output7.html")
189198
190-
# # Step 8
191-
# ########
199+
########
200+
# Step 8
201+
########
192202
193-
# page = hr.Html()
203+
page = hr.Html()
194204
195205
196-
# head = hr.Head()
197-
# head.append( hr.Meta(charset="UTF-8") )
198-
# head.append(hr.Title("PythonClass = Revision 1087:"))
206+
head = hr.Head()
207+
head.append( hr.Meta(charset="UTF-8") )
208+
head.append(hr.Title("PythonClass = Revision 1087:"))
199209
200-
# page.append(head)
210+
page.append(head)
201211
202-
# body = hr.Body()
212+
body = hr.Body()
203213
204-
# body.append( hr.H(2, "PythonClass - Example") )
214+
body.append( hr.H(2, "PythonClass - Example") )
205215
206-
# body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
207-
# "but this is enough to show that we can do some text",
208-
# style="text-align: center; font-style: oblique;"))
216+
body.append(hr.P("Here is a paragraph of text -- there could be more of them, "
217+
"but this is enough to show that we can do some text",
218+
style="text-align: center; font-style: oblique;"))
209219
210-
# body.append(hr.Hr())
220+
body.append(hr.Hr())
211221
212-
# list = hr.Ul(id="TheList", style="line-height:200%")
222+
list = hr.Ul(id="TheList", style="line-height:200%")
213223
214-
# list.append( hr.Li("The first item in a list") )
215-
# list.append( hr.Li("This is the second item", style="color: red") )
224+
list.append( hr.Li("The first item in a list") )
225+
list.append( hr.Li("This is the second item", style="color: red") )
216226
217-
# item = hr.Li()
218-
# item.append("And this is a ")
219-
# item.append( hr.A("http://google.com", "link") )
220-
# item.append("to google")
227+
item = hr.Li()
228+
item.append("And this is a ")
229+
item.append( hr.A("http://google.com", "link") )
230+
item.append("to google")
221231
222-
# list.append(item)
232+
list.append(item)
223233
224-
# body.append(list)
234+
body.append(list)
225235
226-
# page.append(body)
236+
page.append(body)
227237
228-
# render_page(page, "test_html_output8.html")
238+
render_page(page, "test_html_output8.html")
239+
"""

0 commit comments

Comments
 (0)