From 7f783cdbfacca319b2550bf7bfe4866fa0c382e6 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 28 Sep 2022 15:52:03 +0200 Subject: [PATCH] Add a few short snippets created for debugging --- snippets/README.md | 7 +++++++ snippets/birdvisu | 1 + snippets/test_diff.py | 13 +++++++++++++ snippets/test_ospffile.py | 11 +++++++++++ 4 files changed, 32 insertions(+) create mode 100644 snippets/README.md create mode 120000 snippets/birdvisu create mode 100644 snippets/test_diff.py create mode 100644 snippets/test_ospffile.py diff --git a/snippets/README.md b/snippets/README.md new file mode 100644 index 0000000..9878809 --- /dev/null +++ b/snippets/README.md @@ -0,0 +1,7 @@ +Here are a few short scripts which I created for testing. They are not +representative of any kind of use, but help testing/debugging that the happy +path works at least a bit. + +The `birdvisu` symlink is a quick hack, since the files were originally in the +repository root and birdvisu had (has?) no packages created for it, so we need +to be able to find the library somehow. diff --git a/snippets/birdvisu b/snippets/birdvisu new file mode 120000 index 0000000..90a1f0e --- /dev/null +++ b/snippets/birdvisu @@ -0,0 +1 @@ +../birdvisu \ No newline at end of file diff --git a/snippets/test_diff.py b/snippets/test_diff.py new file mode 100644 index 0000000..1cdf0d0 --- /dev/null +++ b/snippets/test_diff.py @@ -0,0 +1,13 @@ +from birdvisu import maps + +with open('current.ospf') as actual: + act_topo = maps.Topology.from_ospffile(actual) +with open('reference.ospf') as reference: + ref_topo = maps.Topology.from_ospffile(reference) + +diff = maps.TopologyDifference(act_topo, ref_topo) +diff.compare() + +from pprint import pprint + +pprint(vars(diff)) diff --git a/snippets/test_ospffile.py b/snippets/test_ospffile.py new file mode 100644 index 0000000..d5be411 --- /dev/null +++ b/snippets/test_ospffile.py @@ -0,0 +1,11 @@ +#!/bin/python3 + +from birdvisu import ospffile +from pprint import pprint + +with open('reference.ospf') as f: + loaded = ospffile.load(f) + +#pprint(loaded) + +print(ospffile.dumps(loaded))