I once went down a similar rathole. I was trying to find all article which were
(recursively) in Category:Music. That's when I discovered just what a mess the wiki
category graph is. At first glance, it looks like a tree, but it's not. It's not
even a DAG. It has cycles! And not just "it can theoretically have cycles",
but "in real life, cycles do exist". In fact, if you start to walk the graph
from Music, you will indeed end up hitting a cycle. But, OK, we know how to detect and
break cycles. But even if you do that, it turns out there are occasional links that go
off into weird directions and pretty soon I was finding pages that had absolutely nothing
to do with music.
But enough of that. If this was a one-off job, what I'd do is take the source for
Category.articles(), add just before "yield member" I'd add:
if member.title() == "p":
raise a RuntimeException,
and then look at the stack dump to see how you got there. If you had to do this
programmatically, I'd do something similar, but modify the code to explicitly maintain
a stack of subcategories. Or if you want to be cute, just use inspect.Traceback and take
advantage of the stack that the python interpreter is already maintaining for you.
On Apr 3, 2024, at 11:17 AM, Bináris
<wikiposta(a)gmail.com> wrote:
Hi,
given a category c and a page p, p is listed in c.articles(recurse=True)
But is shouldn't... And I don't know the depth of it.
Is there a simple way to find a path between them, and guess, why is the page in the
category?
(I spent 10 minutes with manual trying, total fail.)
--
Bináris
_______________________________________________
pywikibot mailing list -- pywikibot(a)lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…
To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org