From 4925650c45b053df3e4cf7b45b568d30a2e34fde Mon Sep 17 00:00:00 2001 From: michael vincerra <37549381+mvincerx@users.noreply.github.com> Date: Thu, 29 Aug 2019 13:50:30 -0700 Subject: [PATCH] Add code to show status and assign status color-code for available bundles. (#748) * Add code to show status and assign color-coding to available bundles. - Add regex PATTERN4 to capture bundle status values - Add code to process capture groups in for loop - Rename bundler() to main() to follow Python convention - Add conditional blocks to filter tags based on below status indicators - Add css classes for active-status, wip-status, and pending-delete-status - Closes #747 Signed-off-by: Michael Vincerra * Programs "Deprecated" status for such bundles; color-codes it in css. Signed-off-by: Michael Vincerra * Adds #ce2029 color for "Deprecated" status to css; reorders css classes. Signed-off-by: Michael Vincerra * Revises HTML relative link in template.html to tcs_theme.css. Signed-off-by: Michael Vincerra --- source/_scripts/_python/bundle_lister.py | 13 +++++++++---- source/_scripts/_python/template.html | 17 ++++++++++++++++- .../otc_tcs_sphinx_theme/static/tcs_theme.css | 16 ++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/source/_scripts/_python/bundle_lister.py b/source/_scripts/_python/bundle_lister.py index 8d7f533b..5d84288a 100644 --- a/source/_scripts/_python/bundle_lister.py +++ b/source/_scripts/_python/bundle_lister.py @@ -15,6 +15,7 @@ GITHUB_BASE = "https://github.com/clearlinux/clr-bundles/tree/master/bundles/" PATTERN1 = re.compile(r"#\s?\[TITLE]:\w?(.*)") PATTERN2 = re.compile(r"#\s?\[DESCRIPTION]:\w?(.*)") PATTERN3 = re.compile(r"(?<=include)\(.*\)", re.MULTILINE) +PATTERN4 = re.compile(r"(#\s?\[STATUS]):\s?(.*)") def extractor(lines): bundle_title = "title" @@ -22,25 +23,28 @@ def extractor(lines): url = "url" include_list = [] include_unique = [] + status = "status" for i in lines: title = PATTERN1.match(i) desc = PATTERN2.match(i) includes = PATTERN3.findall(i) - + curr_status = PATTERN4.match(i) if title: bundle_title = title.groups(0)[0].strip() if desc: data_desc = desc.groups(0)[0].strip() if url: url = os.path.join(GITHUB_BASE, bundle_title) + if curr_status: + status = curr_status.group(2) if includes: include_text = includes[0].strip("()") include_list.append(include_text) include_unique = set(include_list) - return {"title": bundle_title, "data_desc": data_desc, "include_list": include_unique, "url": url} + return {"title": bundle_title, "data_desc": data_desc, "include_list": include_unique, "url": url, "status": status} -def bundler(): +def main(): data = [] try: git.Git("./cloned_repo/").clone("https://github.com/clearlinux/clr-bundles.git") @@ -62,4 +66,5 @@ def bundler(): with io.open('bundles.html.txt', 'w') as file: file.write(output) -bundler() +if __name__ == "__main__": + main() diff --git a/source/_scripts/_python/template.html b/source/_scripts/_python/template.html index 3173b56b..c3ed182d 100644 --- a/source/_scripts/_python/template.html +++ b/source/_scripts/_python/template.html @@ -5,7 +5,7 @@ Bundles in Clear Linux* OS - + @@ -31,6 +31,21 @@ {{d.title}} {{d.data_desc}}
+ +
Status: + {% if d.status=="Pending-Delete" %} + {{d.status}} + {% elif d.status=="Active" %} + {{d.status}} + {% elif d.status=="WIP" %} + {{d.status}} + {% elif d.status=="Deprecated"%} + {{d.status}} + {% else %} + {{d.status}} + {% endif %} +
+ {% if d.include_list %}
Includes bundle(s):
    diff --git a/source/_themes/otc_tcs_sphinx_theme/static/tcs_theme.css b/source/_themes/otc_tcs_sphinx_theme/static/tcs_theme.css index d3a39bee..2a7a173d 100644 --- a/source/_themes/otc_tcs_sphinx_theme/static/tcs_theme.css +++ b/source/_themes/otc_tcs_sphinx_theme/static/tcs_theme.css @@ -291,3 +291,19 @@ div#trademarks { background: url(./mag-glass.png) left no-repeat; background-size: 15px 15px; } + +.active-status { + color:#358ccb; +} + +.wip-status { + color:#59ca6b; +} + +.deprecated-status { + color:#f94f24; +} + +.pending-delete-status { + color:#ce2029; +}