Skip to content

Commit

Permalink
Naive and simple helper tool
Browse files Browse the repository at this point in the history
- adding new examples to counters require fresh inversion of mapping

Signed-off-by: Stefan Hagen <stefan@hagen.link>
  • Loading branch information
sthagen committed Jun 18, 2024
1 parent 1f005f2 commit 4b51e70
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions csaf_2.1/prose/edit/bin/invert_eg_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#! /usr/bin/env python
"""Bread and butter inversion of global eexample number to example sug mapping."""
import json
import pathlib

ETC_PATH = pathlib.Path('etc')
IN_PATH = ETC_PATH / 'example-global-to-local.json'
OUT_PATH = ETC_PATH / 'example-local-to-global.json'

if not ETC_PATH.is_dir():
raise RuntimeError('Please execute me inside csaf_2.1/prose/edit/ because I am a simple tool')

with open(IN_PATH, 'rt', encoding='utf-8') as handle:
data = json.load(handle)

inverted = {v: k for k, v in data.items()}
ordered = {k: inverted[k] for k in sorted(inverted)}

with open(OUT_PATH, 'wt', encoding='utf-8') as handle:
json.dump(ordered, handle, indent=2)

0 comments on commit 4b51e70

Please sign in to comment.