Skip to content

Commit a9d945d

Browse files
committed
Fixing properties and checking for existence of link before validation
1 parent 5832d1a commit a9d945d

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

modules/link.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_links(node):
4040
"""
4141
def retrieve_link(child):
4242
link = child.get('href')
43-
if LinkNode.valid_link(link) and link:
43+
if link and LinkNode.valid_link(link):
4444
return link
4545
return None
4646

torBot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ def main():
127127
"""
128128
args = get_args()
129129
connect(args.ip, args.port)
130-
try:
131-
node = LinkNode(args.url)
132-
except (ValueError, HTTPError, ConnectionError) as err:
133-
raise err
134130

135131
# If flag is -v, --update, -q/--quiet then user only runs that operation
136132
# because these are single flags only
@@ -145,13 +141,16 @@ def main():
145141
# If url flag is set then check for accompanying flag set. Only one
146142
# additional flag can be set with -u/--url flag
147143
if args.url:
144+
try:
145+
node = LinkNode(args.url)
146+
except (ValueError, HTTPError, ConnectionError) as err:
147+
raise err
148148
LinkIO.display_ip()
149149
# -m/--mail
150150
if args.mail:
151-
emails = node.get_emails()
152-
print(emails)
151+
print(node.emails)
153152
if args.save:
154-
saveJson('Emails', emails)
153+
saveJson('Emails', node.emails)
155154
# -i/--info
156155
elif args.info:
157156
execute_all(node.name)
@@ -167,7 +166,7 @@ def main():
167166
else:
168167
LinkIO.display_children(node)
169168
if args.save:
170-
saveJson("Links", node.get_children())
169+
saveJson("Links", node.links)
171170
else:
172171
print("usage: See torBot.py -h for possible arguments.")
173172

0 commit comments

Comments
 (0)