interwiki_graph — Graphviz Drawing for Interwiki#

Module with the Graphviz drawing calls.

class interwiki_graph.GraphDrawer(subject)[source]#

Bases: object

Graphviz (dot) code creator.

Parameters:

subject (pywikibot.interwiki_graph.Subject) – page data to graph

:raises ImportError if pydot is not installed

addDirectedEdge(page, refPage)[source]#

Add a directed edge from refPage to page.

Parameters:
Return type:

None

addNode(page)[source]#

Add a node for page.

Parameters:

page (Page) –

Return type:

None

createGraph()[source]#

Create graph of the interwiki links.

For more info see https://meta.wikimedia.org/wiki/Interwiki_graphs

Return type:

None

static getLabel(page)[source]#

Get label for page.

Parameters:

page (Page) –

Return type:

str

saveGraphFile()[source]#

Write graphs to the data directory.

Return type:

None

class interwiki_graph.GraphSavingThread(graph, origin)[source]#

Bases: Thread

Threaded graph renderer.

Rendering a graph can take extremely long. We use multithreading because of that.

TODO: Find out if several threads running in parallel can slow down the system too much. Consider adding a mechanism to kill a thread if it takes too long.

Parameters:
  • graph (pydot.Dot) –

  • origin (pywikibot.page.Page) –

run()[source]#

Write graphs to the data directory.

Return type:

None

class interwiki_graph.Subject(origin=None)[source]#

Bases: object

Data about a page with translations on multiple wikis.

Parameters:

origin (pywikibot.page.Page | None) – the page on the ‘origin’ wiki

property origin: pywikibot.page.Page | None#

Page on the origin wiki.

interwiki_graph.getFilename(page, extension=None)[source]#

Create a filename that is unique for the page.

Parameters:
  • page (pywikibot.page.Page) – page used to create the new filename

  • extension (str | None) – file extension

Returns:

filename of <family>-<lang>-<page>.<ext>

Return type:

str