zhuyifei1999 added a comment.
Using [[github.com/zhuyifei1999/guppy3|guppy]] to traverse the reference
graph:
import osmium, pywikibot
import guppy
en_wiki = pywikibot.Site("en", "wikipedia")
thisframe = []
class TestHandler(osmium.SimpleHandler):
def node(self, n):
print(n.id)
entry = pywikibot.Page(en_wiki, 'non-existing article or even
redirect')
entry.text
entry.clear_cache() # Clear cache even works if there is no call
to `.text`
thisframe.append(guppy.hpy().iso(n).referrers.theone)
# n = None
h = TestHandler()
# Download from
http://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
try:
h.apply_file('liechtenstein-latest.osm.pbf')
except Exception:
pass
hp = guppy.hpy()
print(hp.iso(thisframe[0]).referrers)
print(hp.iso(thisframe[0]).referrers[0].referrers)
print(hp.iso(thisframe[0]).referrers[0].referrers[1].sp)
(venv) zhuyifei1999@zhuyifei1999-ThinkPad-T480 ~/mw-dev/pywikibot-core $
python T261162.py
family and mylang are not set.
Defaulting to family='wikipedia' and mylang='test'.
26032956
Partition of a set of 2 objects. Total size = 568 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 1 50 464 82 464 82 types.FrameType
1 1 50 104 18 568 100 list
Partition of a set of 2 objects. Total size = 640 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 1 50 568 89 568 89 types.FrameType
1 1 50 72 11 640 100 types.TracebackType
0:
hp.Root.i0_modules['__main__'].__dict__['thisframe'][0].f_locals['entry'].__dict__['_getexception'].??
TASK DETAIL
https://phabricator.wikimedia.org/T261162
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: zhuyifei1999
Cc: zhuyifei1999, Aklapper, pywikibot-bugs-list, Stalker, JohnsonLee01, SHEKH,
Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89,
Dvorapa, Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs