1
- #!/usr/bin/env python
1
+ #!/usr/bin/env python3
2
2
3
3
"""
4
4
a simple script can run and test your html rendering classes.
@@ -29,7 +29,8 @@ def render_page(page, filename):
29
29
with open (filename , 'w' ) as outfile :
30
30
outfile .write (f .getvalue ())
31
31
32
-
32
+ """
33
+ #########
33
34
# Step 1
34
35
#########
35
36
@@ -45,184 +46,194 @@ def render_page(page, filename):
45
46
# The rest of the steps have been commented out.
46
47
# Uncomment them as you move along with the assignment.
47
48
48
- # ## Step 2
49
- # ##########
49
+ ##########
50
+ # Step 2
51
+ ##########
50
52
51
- # page = hr.Html()
53
+ page = hr.Html()
52
54
53
- # body = hr.Body()
55
+ body = hr.Body()
54
56
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"))
57
59
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"))
59
61
60
- # page.append(body)
62
+ page.append(body)
61
63
62
- # render_page(page, "test_html_output2.html")
64
+ render_page(page, "test_html_output2.html")
63
65
64
- # # Step 3
65
- # ##########
66
+ ##########
67
+ # Step 3
68
+ ##########
66
69
67
- # page = hr.Html()
70
+ page = hr.Html()
68
71
69
- # head = hr.Head()
70
- # head.append(hr.Title("PythonClass = Revision 1087:"))
72
+ head = hr.Head()
73
+ head.append(hr.Title("PythonClass = Revision 1087:"))
71
74
72
- # page.append(head)
75
+ page.append(head)
73
76
74
- # body = hr.Body()
77
+ body = hr.Body()
75
78
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"))
79
82
80
- # page.append(body)
83
+ page.append(body)
81
84
82
- # render_page(page, "test_html_output3.html")
85
+ render_page(page, "test_html_output3.html")
83
86
84
- # # Step 4
85
- # ##########
87
+ ##########
88
+ # Step 4
89
+ ##########
86
90
87
- # page = hr.Html()
91
+ page = hr.Html()
88
92
89
- # head = hr.Head()
90
- # head.append(hr.Title("PythonClass = Revision 1087:"))
93
+ head = hr.Head()
94
+ head.append(hr.Title("PythonClass = Revision 1087:"))
91
95
92
- # page.append(head)
96
+ page.append(head)
93
97
94
- # body = hr.Body()
98
+ body = hr.Body()
95
99
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;"))
99
103
100
- # page.append(body)
104
+ page.append(body)
101
105
102
- # render_page(page, "test_html_output4.html")
106
+ render_page(page, "test_html_output4.html")
103
107
104
- # # Step 5
105
- # #########
108
+ #########
109
+ # Step 5
110
+ #########
106
111
107
- # page = hr.Html()
112
+ page = hr.Html()
108
113
109
- # head = hr.Head()
110
- # head.append(hr.Title("PythonClass = Revision 1087:"))
114
+ head = hr.Head()
115
+ head.append(hr.Title("PythonClass = Revision 1087:"))
111
116
112
- # page.append(head)
117
+ page.append(head)
113
118
114
- # body = hr.Body()
119
+ body = hr.Body()
115
120
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;"))
119
124
120
- # body.append(hr.Hr())
125
+ body.append(hr.Hr())
121
126
122
- # page.append(body)
127
+ page.append(body)
123
128
124
- # render_page(page, "test_html_output5.html")
129
+ render_page(page, "test_html_output5.html")
125
130
126
- # # Step 6
127
- # #########
131
+ """
132
+ #########
133
+ # Step 6
134
+ #########
128
135
129
- # page = hr.Html()
136
+ page = hr .Html ()
130
137
131
- # head = hr.Head()
132
- # head.append(hr.Title("PythonClass = Revision 1087:"))
138
+ head = hr .Head ()
139
+ head .append (hr .Title ("PythonClass = Revision 1087:" ))
133
140
134
- # page.append(head)
141
+ page .append (head )
135
142
136
- # body = hr.Body()
143
+ body = hr .Body ()
137
144
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;" ))
141
148
142
- # body.append(hr.Hr())
149
+ body .append (hr .Hr ())
143
150
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" )
147
154
148
- # page.append(body)
155
+ page .append (body )
149
156
150
- # render_page(page, "test_html_output6.html")
157
+ render_page (page , "test_html_output6.html" )
151
158
152
- # # Step 7
153
- # #########
159
+ """
160
+ #########
161
+ # Step 7
162
+ #########
154
163
155
- # page = hr.Html()
164
+ page = hr.Html()
156
165
157
- # head = hr.Head()
158
- # head.append(hr.Title("PythonClass = Revision 1087:"))
166
+ head = hr.Head()
167
+ head.append(hr.Title("PythonClass = Revision 1087:"))
159
168
160
- # page.append(head)
169
+ page.append(head)
161
170
162
- # body = hr.Body()
171
+ body = hr.Body()
163
172
164
- # body.append( hr.H(2, "PythonClass - Class 6 example") )
173
+ body.append( hr.H(2, "PythonClass - Class 6 example") )
165
174
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;"))
169
178
170
- # body.append(hr.Hr())
179
+ body.append(hr.Hr())
171
180
172
- # list = hr.Ul(id="TheList", style="line-height:200%")
181
+ list = hr.Ul(id="TheList", style="line-height:200%")
173
182
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") )
176
185
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")
181
190
182
- # list.append(item)
191
+ list.append(item)
183
192
184
- # body.append(list)
193
+ body.append(list)
185
194
186
- # page.append(body)
195
+ page.append(body)
187
196
188
- # render_page(page, "test_html_output7.html")
197
+ render_page(page, "test_html_output7.html")
189
198
190
- # # Step 8
191
- # ########
199
+ ########
200
+ # Step 8
201
+ ########
192
202
193
- # page = hr.Html()
203
+ page = hr.Html()
194
204
195
205
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:"))
199
209
200
- # page.append(head)
210
+ page.append(head)
201
211
202
- # body = hr.Body()
212
+ body = hr.Body()
203
213
204
- # body.append( hr.H(2, "PythonClass - Example") )
214
+ body.append( hr.H(2, "PythonClass - Example") )
205
215
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;"))
209
219
210
- # body.append(hr.Hr())
220
+ body.append(hr.Hr())
211
221
212
- # list = hr.Ul(id="TheList", style="line-height:200%")
222
+ list = hr.Ul(id="TheList", style="line-height:200%")
213
223
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") )
216
226
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")
221
231
222
- # list.append(item)
232
+ list.append(item)
223
233
224
- # body.append(list)
234
+ body.append(list)
225
235
226
- # page.append(body)
236
+ page.append(body)
227
237
228
- # render_page(page, "test_html_output8.html")
238
+ render_page(page, "test_html_output8.html")
239
+ """
0 commit comments