Yet more debugging
Trying to find how to thread stuff is harder than I thought it would be. Where's the root?
This commit is contained in:
parent
d08d32c11c
commit
be49ed879e
|
@ -4,23 +4,22 @@ def maketree(descendants):
|
|||
lookup = dict((descendant.id, descendant) for descendant in descendants)
|
||||
replies = {}
|
||||
roots = set()
|
||||
def getreps(id):
|
||||
if id in replies:
|
||||
reps = replies[id]
|
||||
else:
|
||||
reps = set()
|
||||
replies[id] = reps
|
||||
return reps
|
||||
for descendant in descendants:
|
||||
if not descendant.in_reply_to_id:
|
||||
roots.add(descendant.id)
|
||||
print("ROOT", descendant.id, descendant.account.id, descendant.account.acct)
|
||||
elif descendant.in_reply_to_id in replies:
|
||||
reps = replies[descendant.in_reply_to_id]
|
||||
reps.add(descendant.id)
|
||||
print("REPLY", descendant.id,
|
||||
descendant.in_reply_to_id,
|
||||
descendant.in_reply_to_account_id,
|
||||
descendant.in_reply_to_id in lookup)
|
||||
else:
|
||||
reps = set()
|
||||
print("NEWREPLY", descendant.id,
|
||||
descendant.in_reply_to_id,
|
||||
descendant.in_reply_to_id in lookup)
|
||||
replies[descendant.in_reply_to_id] = set([descendant.id])
|
||||
reps = getreps(descendant.in_reply_to_id)
|
||||
reps.add(descendant.id)
|
||||
reps = getreps(descendant.in_reply_to_account_id)
|
||||
reps.add(descendant.id)
|
||||
seen = set()
|
||||
def onelevel(reps):
|
||||
for rep in reps:
|
||||
|
|
Loading…
Reference in New Issue