summaryrefslogtreecommitdiffstats
path: root/gen_requirement_changes.py
diff options
context:
space:
mode:
authorHagop Bozawglanian <hagop.bozawglanian@att.com>2019-03-26 21:57:36 +0000
committerHagop Bozawglanian <hagop.bozawglanian@att.com>2019-03-26 22:05:51 +0000
commit759a27ffda47ca7e95230708227e6be80301e589 (patch)
tree58739e8c2f81c87eebbd51d1c552ff1fac38d62a /gen_requirement_changes.py
parent7ad41f849aea3f875327e9892f35b8d9e4f7265e (diff)
VNFRQTS - JSON toolchain finishes
Change-Id: I9a7556e40cf0ffbc49bad033f8668268ddfef496 Issue-ID: VNFRQTS-541 Signed-off-by: Hagop Bozawglanian <hagop.bozawglanian@att.com>
Diffstat (limited to 'gen_requirement_changes.py')
-rw-r--r--gen_requirement_changes.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/gen_requirement_changes.py b/gen_requirement_changes.py
index d0600e6..f206f4b 100644
--- a/gen_requirement_changes.py
+++ b/gen_requirement_changes.py
@@ -43,11 +43,13 @@ import os
import re
import sys
import argparse
+import requests
+import warnings
from operator import itemgetter
import jinja2
-REQ_JSON_URL = "https://onap.readthedocs.io/en/latest/_downloads/needs.json"
+NEEDS_JSON_URL = "https://nexus.onap.org/service/local/repositories/raw/content/org.onap.vnfrqts.requirements/master/needs.json"
NEEDS_PATH = "docs/data/needs.json"
JINJA_TEMPLATE = "release-requirement-changes.rst.jinja2"
@@ -192,6 +194,26 @@ def load_requirements(path):
return json.load(req_file)
+def load_current_requirements():
+ """Loads dict of current requirements or empty dict if file doesn't exist"""
+ try:
+ r = requests.get(NEEDS_JSON_URL)
+ if r.headers.get("content-type") == "application/json":
+ with open(NEEDS_PATH, "wb") as needs:
+ needs.write(r.content)
+ else:
+ warnings.warn(
+ (
+ "Unexpected content-type ({}) encountered downloading "
+ + "requirements.json, using last saved copy"
+ ).format(r.headers.get("content-type"))
+ )
+ except requests.exceptions.RequestException as e:
+ warnings.warn("Error downloading latest JSON, using last saved copy.")
+ warnings.warn(UserWarning(e))
+ with open(NEEDS_PATH, "r") as f:
+ return json.load(f)
+
def parse_args():
"""Parse the command-line arguments and return the arguments:
@@ -276,7 +298,7 @@ def render_to_file(template_path, output_path, **context):
def print_invalid_metadata_report(difference_finder, current_version):
"""Write a report to the console for any instances where differences
- are detected, but teh appropriate :introduced: or :updated: metadata
+ are detected, but the appropriate :introduced: or :updated: metadata
is not applied to the requirement."""
print("Validating Metadata...")
print()
@@ -301,7 +323,7 @@ def print_invalid_metadata_report(difference_finder, current_version):
if __name__ == "__main__":
args = parse_args()
- requirements = load_requirements(NEEDS_PATH)
+ requirements = load_current_requirements()
differ = DifferenceFinder(requirements,
args.current_version,
args.prior_version)
@@ -320,4 +342,3 @@ if __name__ == "__main__":
num_changed=len(differ.changed_requirements),
)
-