diff --git a/refstack/api/app.py b/refstack/api/app.py index 410596d5..a22a4635 100644 --- a/refstack/api/app.py +++ b/refstack/api/app.py @@ -82,14 +82,14 @@ API_OPTS = [ ), cfg.StrOpt('opendev_api_capabilities_url', default='https://opendev.org/api/v1/repos/osf/interop/contents/' - 'previous_guidelines', + 'guidelines', help='The GitHub API URL of the repository and location of the ' 'Interop Working Group capability files. This URL is used ' 'to get a listing of all capability files.' ), cfg.StrOpt('additional_capability_urls', default='https://opendev.org/api/v1/repos/osf/interop/contents/' - 'add-ons/previous_guidelines', + 'add-ons/guidelines', help=('The GitHub API URL of the repository and location of ' 'any additional guideline sources which will need to ' 'be parsed by the refstack API.')), diff --git a/refstack/api/guidelines.py b/refstack/api/guidelines.py index d252ab0d..38735a92 100755 --- a/refstack/api/guidelines.py +++ b/refstack/api/guidelines.py @@ -16,13 +16,15 @@ """Class for retrieving Interop WG guideline information.""" import itertools -from oslo_config import cfg -from oslo_log import log from operator import itemgetter +import os import re import requests import requests_cache +from oslo_config import cfg +from oslo_log import log + CONF = cfg.CONF LOG = log.getLogger(__name__) @@ -77,19 +79,6 @@ class Guidelines: for src_url in self.guideline_sources: try: resp = requests.get(src_url) - # The following if-statement enables a transition period for - # moving the guidelines to a new location by - # https://review.opendev.org/c/osf/interop/+/786116 - # TODO(kopecmartin) remove this if-statement after the review - # is merged. - if resp.status_code == 404: - if src_url == CONF.api.additional_capability_urls: - src_url = 'https://opendev.org/api/v1/repos/osf/' - src_url += 'interop/contents/add-ons' - elif src_url == CONF.api.opendev_api_capabilities_url: - src_url = 'https://opendev.org/api/v1/repos/osf/' - src_url += 'interop/contents' - resp = requests.get(src_url) LOG.debug("Response Status: %s / Used Requests Cache: %s" % (resp.status_code, @@ -108,8 +97,9 @@ class Guidelines: elif 'add-ons' not in rfile['path'] and \ rfile['name'] not in map(itemgetter('name'), powered_files): + basename = os.path.basename(rfile['path']) file_dict = {'name': rfile['name'], - 'file': rfile['path']} + 'file': basename} powered_files.append(file_dict) else: LOG.warning('Guidelines repo URL (%s) returned ' @@ -134,9 +124,9 @@ class Guidelines: gl_file = '.'.join((gl_file, 'json')) regex = re.compile("[a-z]*\.([0-9]{4}\.[0-9]{2}|next)\.json") if regex.search(gl_file): - guideline_path = 'add-ons/' + gl_file + guideline_path = 'add-ons/guidelines/' + gl_file else: - guideline_path = gl_file + guideline_path = 'guidelines/' + gl_file file_url = ''.join((self.raw_url.rstrip('/'), '/', guideline_path))