Commit 0ee535d1 authored by Adrian Cansino's avatar Adrian Cansino

Update family_tree.py

parent 27781975
Pipeline #691 failed with stages
...@@ -433,7 +433,7 @@ def commandLine(): ...@@ -433,7 +433,7 @@ def commandLine():
print("Error: no such person " + cmd[1]) print("Error: no such person " + cmd[1])
elif cmd[0] == "edit-age": elif cmd[0] == "edit-age":
try: try:
tree.get_person(cmd[1]).set_name(cmd[2]) tree.get_person(cmd[1]).set_age(cmd[2])
except KeyError: except KeyError:
print("Error: no such person " + cmd[1]) print("Error: no such person " + cmd[1])
elif cmd[0] == "edit-sex": elif cmd[0] == "edit-sex":
...@@ -446,13 +446,21 @@ def commandLine(): ...@@ -446,13 +446,21 @@ def commandLine():
print("Error: no such person " + cmd[1]) print("Error: no such person " + cmd[1])
elif cmd[0] == "relationship": elif cmd[0] == "relationship":
try: try:
if(cmd[1] == cmd[2]):
print("Error: inputs must be distinct")
else:
print(tree.relationship(tree.get_person(cmd[1]), tree.get_person(cmd[2]))) print(tree.relationship(tree.get_person(cmd[1]), tree.get_person(cmd[2])))
except KeyError: except KeyError:
print("Error: one or both persons do not exist") print("Error: one or both persons do not exist")
elif cmd[0] == "load": elif cmd[0] == "load":
try:
tree = openfile(cmd[1]) tree = openfile(cmd[1])
print(cmd[1] + ".ft has been loaded") print(cmd[1] + ".ft has been loaded")
except FileNotFoundError:
print("Error: file not found")
elif cmd[0] == "save": elif cmd[0] == "save":
tree.find_root()
tree.precompute()
savefile(cmd[1], tree) savefile(cmd[1], tree)
print("file saved") print("file saved")
elif cmd[0] == "bye": elif cmd[0] == "bye":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment