diff options
author | rebortg <github@ghlr.de> | 2022-05-31 21:16:48 +0200 |
---|---|---|
committer | rebortg <github@ghlr.de> | 2022-05-31 21:27:58 +0200 |
commit | 6a88ab9bb1f333233654a10c4cbf87c31848d47c (patch) | |
tree | 57936a23056447f06f974ec7bdd0f3e7ba1ecd3d /docs/_ext/testcoverage.py | |
parent | 7c58e0fec38c6a26e0d004a1ab86fac6959bc29e (diff) | |
download | vyos-documentation-6a88ab9bb1f333233654a10c4cbf87c31848d47c.tar.gz vyos-documentation-6a88ab9bb1f333233654a10c4cbf87c31848d47c.zip |
improve coverage with all real vyos commands exported from iso
(cherry picked from commit 68a335a08633d18e11110e98e5fef7a979d7e850)
Diffstat (limited to 'docs/_ext/testcoverage.py')
-rw-r--r-- | docs/_ext/testcoverage.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/docs/_ext/testcoverage.py b/docs/_ext/testcoverage.py index 3d1461a9..c06cf301 100644 --- a/docs/_ext/testcoverage.py +++ b/docs/_ext/testcoverage.py @@ -1,14 +1,13 @@ ''' generate json with all commands from xml for vyos documentation coverage - ''' - import sys import os import json import re import logging +import datetime from io import BytesIO from lxml import etree as ET @@ -33,11 +32,32 @@ input_data = [ } ] +vyos_commands_dir = "_include/coverage" + node_data = { 'cfgcmd': {}, 'opcmd': {}, } + +def get_vyos_commands(): + return_data = None + for (dirpath, dirnames, filenames) in os.walk(vyos_commands_dir): + for file in filenames: + with open(f"{vyos_commands_dir}/{file}") as f: + data = json.load(f) + + if not return_data: + return_data = data + + # find latestes export + if datetime.datetime.fromisoformat(return_data['date']) < datetime.datetime.fromisoformat(data['date']): + return_data = data + + return return_data + + + def get_properties(p): props = {} props['valueless'] = False @@ -378,6 +398,4 @@ def override_element(l: list): el.getparent().remove(el) if __name__ == "__main__": - res = get_working_commands() - print(json.dumps(res)) - #print(res['cfgcmd'][0]) + get_vyos_commands() |