From 2d310876c62ef01c92ee040039dd03a02701b99d Mon Sep 17 00:00:00 2001 From: Thorsten Vitt Date: Tue, 5 Feb 2019 15:18:31 +0100 Subject: [PATCH] Download page --- src/macrogen/main.py | 5 ++- src/macrogen/report.py | 83 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/src/macrogen/main.py b/src/macrogen/main.py index 238b521..8386d5d 100755 --- a/src/macrogen/main.py +++ b/src/macrogen/main.py @@ -11,7 +11,7 @@ logger = logging.getLogger('main') -def _main(argv=sys.argv): +def main(argv=sys.argv): graphs = graph.macrogenesis_graphs() report.write_order_xml(graphs) @@ -24,10 +24,11 @@ def _main(argv=sys.argv): report.report_conflicts(graphs) report.report_sources(graphs) report.report_index(graphs) + report.report_downloads(graphs) render_all() if __name__ == '__main__': import requests_cache requests_cache.install_cache(expire_after=86400) - _main() + main() diff --git a/src/macrogen/report.py b/src/macrogen/report.py index 50b5b66..cf18fa2 100644 --- a/src/macrogen/report.py +++ b/src/macrogen/report.py @@ -467,6 +467,86 @@ def _fmt_xml(xml: Union[Tuple[str, int], Sequence[Tuple[str, int]]]): return "; ".join(result) +def report_downloads(graphs: MacrogenesisInfo): + target.mkdir(exist_ok=True, parents=True) + + simplified = simplify_graph(graphs.base) + nx.write_gpickle(graphs.base, str(target / 'base.gpickle')) + nx.write_gexf(simplified, str(target / 'base.gexf')) + nx.write_edgelist(simplified, str(target / 'base.edges')) + + write_html(target / 'downloads.php', """ +
+

Downloadable files for the base graph in various formats:

+
+

Nodes

+

The nodes are either URIs or dates in ISO 8601 format. URIs of the form + faust://document/scheme/sigil denote a witness (document) + that has the identifier sigil in the respective identifier scheme. + faust://inscription/scheme/sigil/id denote an + inscription (single “writing event”) on the respective document.

+

If some URI has a schemefaustedition, then it was not possible to map it to + a document in the edition. You may still try the sigil with the search. Otherwise, the document can be + displayed at http://faustedition.net/document?sigil=sigil. +

+

Dates are always of the form YYYY-MM-DD.

+ +

Edges

+

The edges have attributes that describe them further:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValue(s)Meaning (uv)
kind + not_before, not_after, from_, to_, when, + timeline + These all essentially mean u happened before v
timelinev is the next date after date node u
temp-synu and v happened about at the same time +
ignorebooleanif present and true, this edge is to be ignored for philological reasons
deletebooleanif present and true, this edge has been removed by the minimum feedback edge set heuristics
weightpositive integertrust in edge, generated mainly from sources
sourceURIURI identifying the source for this assertion
xmlfile name and line of the XML file + with this assertion
+ """, "Downloads") + def report_refs(graphs: MacrogenesisInfo): # Fake dates for when we don’t have any earliest/latest info @@ -638,7 +718,8 @@ def report_index(graphs): ('sources', 'Quellen', 'Aussagen nach Quelle aufgeschlüsselt'), ('dag', 'sortierrelevanter Gesamtgraph', 'Graph aller für die Sortierung berücksichtigter Aussagen (einzoomen!)'), ('tred', 'transitive Reduktion', 'Transitive Reduktion des Gesamtgraphen'), - ('help', 'Legende', 'Legende zu den Graphen')] + ('help', 'Legende', 'Legende zu den Graphen'), + ('downloads', 'Downloads', 'Graphen zum Download')] links = "\n".join(('{}{}'.format(*page) for page in pages)) report = f"""