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)
|
lookup = dict((descendant.id, descendant) for descendant in descendants)
|
||||||
replies = {}
|
replies = {}
|
||||||
roots = set()
|
roots = set()
|
||||||
|
def getreps(id):
|
||||||
|
if id in replies:
|
||||||
|
reps = replies[id]
|
||||||
|
else:
|
||||||
|
reps = set()
|
||||||
|
replies[id] = reps
|
||||||
|
return reps
|
||||||
for descendant in descendants:
|
for descendant in descendants:
|
||||||
if not descendant.in_reply_to_id:
|
if not descendant.in_reply_to_id:
|
||||||
roots.add(descendant.id)
|
roots.add(descendant.id)
|
||||||
print("ROOT", descendant.id, descendant.account.id, descendant.account.acct)
|
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:
|
else:
|
||||||
reps = set()
|
reps = getreps(descendant.in_reply_to_id)
|
||||||
print("NEWREPLY", descendant.id,
|
reps.add(descendant.id)
|
||||||
descendant.in_reply_to_id,
|
reps = getreps(descendant.in_reply_to_account_id)
|
||||||
descendant.in_reply_to_id in lookup)
|
reps.add(descendant.id)
|
||||||
replies[descendant.in_reply_to_id] = set([descendant.id])
|
|
||||||
seen = set()
|
seen = set()
|
||||||
def onelevel(reps):
|
def onelevel(reps):
|
||||||
for rep in reps:
|
for rep in reps:
|
||||||
|
|
Loading…
Reference in New Issue