mirror of
https://github.com/clearlinux/clear-linux-documentation.git
synced 2026-11-21 19:15:51 +00:00
Bundle lister update (#725)
* Revises to simplify and refine code: - Removes regex PATTERN4 and 5 - Revises PATTERN3 to exclude comments on custom additions - Removes pundler() because no longer a clr-bundles directory Signed-off-by: Michael Vincerra <michael.vincerra@intel.com> Removes cruft code. Signed-off-by: Michael Vincerra <michael.vincerra@intel.com> Edit for rebase. Signed-off-by: Michael Vincerra <michael.vincerra@intel.com> * Removes decode() for string in extractor(). Signed-off-by: Michael Vincerra <michael.vincerra@intel.com> * Applies .bundledesc css to <p> tag on includes(). Signed-off-by: Michael Vincerra <michael.vincerra@intel.com> * Modifies html tags in template and styles.css. Signed-off-by: Michael Vincerra <michael.vincerra@intel.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
@@ -9,13 +11,10 @@ from operator import itemgetter
|
||||
from datetime import datetime
|
||||
|
||||
GITHUB_BASE = "https://github.com/clearlinux/clr-bundles/tree/master/bundles/"
|
||||
PUNDLES = "https://github.com/clearlinux/clr-bundles/blob/master/packages"
|
||||
|
||||
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"^((?:(?!#)\w+[^-\s][-])\w+|\w+[^\s-])", re.MULTILINE)
|
||||
PATTERN5 = re.compile(r"^\w.+\s[#]\s(\w?.*)?", re.MULTILINE)
|
||||
PATTERN3 = re.compile(r"(?<=include)\(.*\)", re.MULTILINE)
|
||||
|
||||
def extractor(lines):
|
||||
bundle_title = "title"
|
||||
@@ -41,32 +40,6 @@ def extractor(lines):
|
||||
include_unique = set(include_list)
|
||||
return {"title": bundle_title, "data_desc": data_desc, "include_list": include_unique, "url": url}
|
||||
|
||||
def pundler():
|
||||
with io.open("./cloned_repo/clr-bundles/packages") as file_obj:
|
||||
lines = file_obj.readlines()
|
||||
pundle_title = "pundle_title"
|
||||
pundle_desc = "pundle_desc"
|
||||
purl = "purl"
|
||||
pundle_list = []
|
||||
pun_desc = []
|
||||
pundle_master = []
|
||||
|
||||
for i in lines:
|
||||
pundle = PATTERN4.findall(i)
|
||||
pundle_plus = PATTERN5.findall(i)
|
||||
|
||||
if pundle:
|
||||
pundle_title = pundle[0]
|
||||
pundle_list.append(pundle_title)
|
||||
|
||||
if pundle_plus:
|
||||
pundle_desc = pundle_plus[0].strip("[]")
|
||||
pun_desc.append(pundle_desc)
|
||||
|
||||
for pun, desc in zip(pundle_list, pun_desc):
|
||||
pundle_master.append({"title": pun, "pun_desc": desc, "purl": PUNDLES})
|
||||
return pundle_master
|
||||
|
||||
def bundler():
|
||||
data = []
|
||||
try:
|
||||
@@ -79,16 +52,12 @@ def bundler():
|
||||
lines = file_obj.readlines()
|
||||
data.append(extractor(lines))
|
||||
|
||||
pundle_master = pundler()
|
||||
data = data + pundle_master
|
||||
filtered = list(filter(lambda x: x.get('title'), data))
|
||||
sortedData = sorted(filtered, key=lambda x:x['title'].lower())
|
||||
#ALT sortedData2 = sorted(sortedData, key=itemgetter('title'))
|
||||
loader = jinja2.FileSystemLoader(searchpath='./')
|
||||
env = jinja2.Environment(loader=loader)
|
||||
template = env.get_template('template.html')
|
||||
template.globals['now'] = datetime.utcnow
|
||||
|
||||
output = template.render(data=sortedData, now=datetime.utcnow())
|
||||
with io.open('bundles.html.txt', 'w') as file:
|
||||
file.write(output)
|
||||
|
||||
@@ -1,48 +1,49 @@
|
||||
table {
|
||||
margin: 32px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-collapse: collapse;
|
||||
width: auto;
|
||||
}
|
||||
th {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
align-content: center;
|
||||
padding: 5px;
|
||||
border: #ccc solid 1px;
|
||||
background-color: #555;
|
||||
color: #fff;
|
||||
text-transform: uppercase;
|
||||
font-size: 18px;
|
||||
}
|
||||
tr {
|
||||
padding-top: 20px ;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
tbody tr:nth-child(odd) {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
.bundlename {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: bolder;
|
||||
padding-left: 6px;
|
||||
line-height: 18px;
|
||||
padding-top:7px ;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.bundledesc {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
font: italic;
|
||||
font-size: 16px;
|
||||
padding-left: 6px;
|
||||
line-height: 18px;
|
||||
padding-top: 7px ;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
ul, li {
|
||||
margin-left: 8px;
|
||||
/* padding: 0; */
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
line-height: 16px;
|
||||
}
|
||||
table {
|
||||
margin: 32px;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-collapse: collapse;
|
||||
width: auto;
|
||||
}
|
||||
th {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
align-content: center;
|
||||
padding: 5px;
|
||||
border: #ccc solid 1px;
|
||||
background-color: #555;
|
||||
color: #fff;
|
||||
text-transform: uppercase;
|
||||
font-size: 18px !important;
|
||||
}
|
||||
tr {
|
||||
padding-top: 20px ;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
tbody tr:nth-child(odd) {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
.bundlename {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
font-size: 16px !important;
|
||||
font-weight: bolder;
|
||||
padding-left: 6px;
|
||||
line-height: 18px;
|
||||
padding-top:7px ;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.bundledesc, p {
|
||||
font-family: IntelClear-Regular,Helvetica,Arial,sans-serif;
|
||||
/* font: italic;*/
|
||||
font-size: 16px !important;
|
||||
padding-left: 6px;
|
||||
line-height: normal;
|
||||
padding-top: 7px ;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
ul, li {
|
||||
line-height: normal;
|
||||
font-size: 16px;
|
||||
padding: 0;
|
||||
padding-left: 5px;
|
||||
padding-top: 2px;
|
||||
/* margin-left: 8px;*/
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Bundles in Clear Linux* OS</title>
|
||||
<link rel="stylesheet" type="text/css" href="./styles.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -31,11 +32,13 @@
|
||||
<td class="bundlename" id="bundle"><a href="{{d.url}}">{{d.title}}</a></td>
|
||||
<td class="bundledesc">{{d.data_desc}} <br />
|
||||
{% if d.include_list %}
|
||||
<p>Includes bundle(s):
|
||||
{% for include in d.include_list %}
|
||||
<li>{{include}}</li>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<div class="bundledesc">Includes bundle(s):
|
||||
<ul>
|
||||
{% for include in d.include_list %}
|
||||
<li>{{include}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user