Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HW [-1] Mailroom_OO #223

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
f9f9d58
"added Readme"
dancornutt Oct 10, 2018
ba3781a
Added typo
dancornutt Oct 10, 2018
dc4ac5d
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Oct 10, 2018
52ffacd
Changed Dir filepath, was in example_students...oops
dancornutt Oct 10, 2018
98812f6
removed accidental file!
dancornutt Oct 13, 2018
c53ee6e
Submitting break_me.py for git practice
dancornutt Oct 15, 2018
7420596
Adding the git ignore file
dancornutt Oct 16, 2018
14b74b0
changed name of git ignore file
dancornutt Oct 16, 2018
27ceb70
added local only folder
dancornutt Oct 17, 2018
5e6caa0
Notes and examples from class.
dancornutt Oct 17, 2018
4647126
added more notes
dancornutt Oct 17, 2018
621fe79
Delete 2018-11-16_Notes.txt
dancornutt Oct 17, 2018
aca0c3c
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Oct 17, 2018
6900410
changed file structure and added session02 modules.
dancornutt Oct 20, 2018
6e40048
Merge branch 'master' of https://github.com/dancornutt/Fall2018-PY210A
dancornutt Oct 20, 2018
3924a66
added assertions for testing.
dancornutt Oct 20, 2018
91fc652
updated print_grid with correct spacing
dancornutt Oct 23, 2018
312ef8d
updated ignore file to ignore local hw folder
dancornutt Oct 23, 2018
7f36102
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Oct 24, 2018
1af302e
Added files for list_lab and slicing lab
dancornutt Oct 27, 2018
fb345aa
Added shebang line and +x modifier
dancornutt Oct 28, 2018
1565996
Finished list_lab, still need to complete bonus if time allows.
dancornutt Oct 28, 2018
1bbb7f4
Finished all series in list lab, still need to do the bonus
dancornutt Oct 28, 2018
74331d3
Finished up slice.py lab
dancornutt Oct 29, 2018
ca93463
Created empty file
dancornutt Oct 29, 2018
4527b07
completed mailroom thankyou, started strformat_lab
dancornutt Oct 30, 2018
631041e
completed mailroom task, working on formatting
dancornutt Oct 30, 2018
1d2571b
progress on the last lab!
dancornutt Oct 30, 2018
d935df4
Finished up the lab for string formatting.
dancornutt Oct 30, 2018
700676a
Mailroom - report now ordered
dancornutt Oct 31, 2018
7f98f02
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Oct 31, 2018
db6cc66
created files, started dict lab
dancornutt Nov 2, 2018
beb8086
completed dict_lab, could update docstring to be more clear
dancornutt Nov 2, 2018
d5d9a45
added file_ex.py for File Exercise in hw
dancornutt Nov 2, 2018
310e57a
Finished dict_lab and file_ex
dancornutt Nov 4, 2018
d305bb0
Changed trigrams to read file and create new edited file
dancornutt Nov 4, 2018
6c5cd44
Of trigram problem, for read/write to work and removing unwanted char…
dancornutt Nov 4, 2018
6d632d6
got trigram working
dancornutt Nov 4, 2018
8cb5948
added initial error handler
dancornutt Nov 6, 2018
a90204b
added new text
dancornutt Nov 6, 2018
f134a0e
added mailroom.py (part2) still in work
dancornutt Nov 7, 2018
4d99367
working on mailroom.py part 2, not finished. Will finish in session05 hw
dancornutt Nov 7, 2018
c003086
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Nov 7, 2018
78df3a9
Finished exceptions_lab.py
dancornutt Nov 8, 2018
4e63712
Finished except_exercise.py
dancornutt Nov 8, 2018
7d44d68
added comprehension_lab.py --in work
dancornutt Nov 9, 2018
f342d86
Started dict_set_lab2.py
dancornutt Nov 10, 2018
afc3eae
Added more functionaltiy for mailroom, with dispatch dict and donatio…
dancornutt Nov 11, 2018
b5d7dbc
Mailroom now has report with dictionary
dancornutt Nov 11, 2018
8a2900e
Mailroom updated for sorted report
dancornutt Nov 11, 2018
29555f5
Mailroom working nicely, basics are complete.
dancornutt Nov 11, 2018
e68ae27
Fixed menu error in Mailroom
dancornutt Nov 12, 2018
5a2e368
removed unneeded functionality from mailroom
dancornutt Nov 13, 2018
d1029c9
Finished unit test labs
dancornutt Nov 18, 2018
27d1d41
added advanced params to mailroom. it's sweet.
dancornutt Nov 19, 2018
eb1a56c
Added unit test file.
dancornutt Nov 20, 2018
6c4c6d0
added functionality of test_mailroom.py
dancornutt Nov 20, 2018
328c353
Added more test_mailroom.py functionality, ran out of time to finish.
dancornutt Nov 20, 2018
cd8538d
Started Session07 html renderer
dancornutt Nov 24, 2018
b2e67c5
On step 4 of HTML parser
dancornutt Nov 27, 2018
bce1cb3
Through step 4 of HTML parser
dancornutt Nov 27, 2018
bb32577
Working on Step 5
dancornutt Nov 27, 2018
039a1bf
On to step 6
dancornutt Nov 27, 2018
55a0f41
Complete with Step 5
dancornutt Nov 27, 2018
0c9c351
Finished Step 6
dancornutt Nov 27, 2018
2fc7e0c
Finished step 7
dancornutt Nov 27, 2018
6575712
Merge branch 'master' into master
dancornutt Nov 28, 2018
7348a63
Halfway through Step 7
dancornutt Nov 28, 2018
ef89656
Working on Step 7 still
dancornutt Nov 28, 2018
a9affd5
added session 08
dancornutt Nov 28, 2018
13418a7
Merge branch 'master' of https://github.com/dancornutt/Fall2018-PY210A
dancornutt Nov 28, 2018
40a1e76
Up through step 7 of hw
dancornutt Dec 1, 2018
ac51b0a
Mostly finished with HW
dancornutt Dec 2, 2018
eb5b1a8
Finished HW
dancornutt Dec 2, 2018
cdbb7ad
Added functionality for +/* ordering
dancornutt Dec 4, 2018
d000bcc
Merge branch 'master' of https://github.com/UWPCE-PythonCert-ClassRep…
dancornutt Dec 5, 2018
226ea72
Working on mailroom_oo
dancornutt Dec 9, 2018
212b4ba
Made progress on YAML input file
dancornutt Dec 12, 2018
7c4338b
added package for mailroom_oo
dancornutt Dec 12, 2018
98a4a30
got mailroom_oo to be functional and use YAML as a input file for the DB
dancornutt Dec 16, 2018
ddd2345
Merge branch 'master' into master
dancornutt Dec 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
On step 4 of HTML parser
dancornutt committed Nov 27, 2018
commit b2e67c58edb3144358160f454fc3c6ae1c7e3040
33 changes: 27 additions & 6 deletions students/DanCornutt/session07/html_render.py
Original file line number Diff line number Diff line change
@@ -11,16 +11,19 @@ class Element:

def __init__(self, content=None):
if content:
self.content = [content]
else: self.content = []
self.contents = [content]
else: self.contents = []

def append(self, new_content):
self.content.append(new_content)
self.contents.append(new_content)

def render(self, out_file):
out_file.write("<{}>".format(self.tag))
for line in self.content:
out_file.write(line)
for content in self.contents:
out_file.write("<{}>".format(self.tag))
try:
content.render(out_file)
except AttributeError:
out_file.write(content)
out_file.write("\n")
out_file.write("</{}>".format(self.tag))

@@ -29,3 +32,21 @@ class Html(Element):

class Body(Element):
tag = "body"

class P(Element):
tag = "p"

class Head(Element):
tag = "head"

class OneLineTag(Element):
def render(self, out_file):
out_file.write("<{}>".format(self.tag))
out_file.write(self.contents[0])
out_file.write("</{}>".format(self.tag))

def append(self, content):
raise NotImplementedError

class Title(OneLineTag):
tag = "title"
22 changes: 11 additions & 11 deletions students/DanCornutt/session07/run_html_render.py
Original file line number Diff line number Diff line change
@@ -45,24 +45,24 @@ def render_page(page, filename, indent=None):

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.
The rest of the steps have been commented out.
Uncomment them as you move along with the assignment.

# ## Step 2
# ##########
## Step 2
##########

# page = hr.Html()
page = hr.Html()

# body = hr.Body()
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("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"))
body.append(hr.P("And here is another piece of text -- you should be able to add any number"))

# page.append(body)
page.append(body)

# render_page(page, "test_html_output2.html")
render_page(page, "test_html_output2.html")

# # Step 3
# ##########
87 changes: 58 additions & 29 deletions students/DanCornutt/session07/test_html_render.py
Original file line number Diff line number Diff line change
@@ -138,49 +138,78 @@ def test_body():
assert file_contents.endswith("</body>")


# def test_p():
# e = P("this is some text")
# e.append("and this is some more text")

# file_contents = render_result(e).strip()
def test_p():
e = P("this is some text")
e.append("and this is some more text")

# assert("this is some text") in file_contents
# assert("and this is some more text") in file_contents
file_contents = render_result(e).strip()

# assert file_contents.startswith("<p>")
# assert file_contents.endswith("</p>")
assert("this is some text") in file_contents
assert("and this is some more text") in file_contents

assert file_contents.startswith("<p>")
assert file_contents.endswith("</p>")

# def test_sub_element():
# """
# tests that you can add another element and still render properly
# """
# page = Html()
# page.append("some plain text.")
# page.append(P("A simple paragraph of text"))
# page.append("Some more plain text.")

# file_contents = render_result(page)
# print(file_contents) # so we can see it if the test fails
def test_sub_element():
"""
tests that you can add another element and still render properly
"""
page = Html()
page.append("some plain text.")
page.append(P("A simple paragraph of text"))
page.append("Some more plain text.")

# # note: The previous tests should make sure that the tags are getting
# # properly rendered, so we don't need to test that here.
# assert "some plain text" in file_contents
# assert "A simple paragraph of text" in file_contents
# assert "Some more plain text." in file_contents
# assert "some plain text" in file_contents
# # but make sure the embedded element's tags get rendered!
# assert "<p>" in file_contents
# assert "</p>" in file_contents
file_contents = render_result(page)
print(file_contents) # so we can see it if the test fails

# note: The previous tests should make sure that the tags are getting
# properly rendered, so we don't need to test that here.
assert "some plain text" in file_contents
assert "A simple paragraph of text" in file_contents
assert "Some more plain text." in file_contents
assert "some plain text" in file_contents
# but make sure the embedded element's tags get rendered!
assert "<p>" in file_contents
assert "</p>" in file_contents



########
# Step 3
########

# Add your tests here!
def test_head():
e = Head("this is some new text")
e.append("and this is some more new text")

file_contents = render_result(e).strip()

assert("this is some new text") in file_contents
assert("and this is some more new text") in file_contents

assert file_contents.startswith("<head>")
assert file_contents.endswith("</head>")


def test_title():
e = Title("This is a Title")

file_contents = render_result(e).strip()

assert("This is a Title") in file_contents
print(file_contents)
assert file_contents.startswith("<title>")
assert file_contents.endswith("</title>")
assert "\n" not in file_contents

def test_one_line_tag_append():
"""
You should not be able to append content to a OneLineTag
"""
e = OneLineTag("the initial content")
with pytest.raises(NotImplementedError):
e.append("some more content")

# #####################
# # indentation testing