diff options
author | rebortg <github@ghlr.de> | 2022-05-31 21:16:48 +0200 |
---|---|---|
committer | rebortg <github@ghlr.de> | 2022-05-31 21:16:48 +0200 |
commit | 68a335a08633d18e11110e98e5fef7a979d7e850 (patch) | |
tree | d8cbd5da7c2bfdda6ea7a55c76f6dc516ff4537f /docs/_ext/testcoverage.py | |
parent | 336b4498b8367f0188a281dbe3eea423fec8bd0f (diff) | |
download | vyos-documentation-68a335a08633d18e11110e98e5fef7a979d7e850.tar.gz vyos-documentation-68a335a08633d18e11110e98e5fef7a979d7e850.zip |
improve coverage with all real vyos commands exported from iso
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() |