Commit c7d8c961 authored by David Spencer's avatar David Spencer

Redo variable names, more flexible rendering.

parent 7b9372a9
......@@ -63,10 +63,10 @@ def repology_by_maintainer(email,sess):
#-----------------------------------------------------------------------
def setlatest(mname,cdate,commit):
# Record commit details into Maintainerinfo[mname]
if "latest" not in Maintainerinfo[mname].keys() or Maintainerinfo[mname]["latest"]["date"] < cdate:
Maintainerinfo[mname]["latest"]={"date":cdate, "commit":commit}
def setlatest(mntnam,cdate,commit):
# Record commit details into Maintainerinfo[mntnam]
if "latest" not in Maintainerinfo[mntnam].keys() or Maintainerinfo[mntnam]["latest"]["date"] < cdate:
Maintainerinfo[mntnam]["latest"]={"date":cdate, "commit":commit}
#-----------------------------------------------------------------------
......@@ -82,7 +82,7 @@ def update_maintainers():
# maintainer in the following dictionaries:
#
Maintainerinfo={}
# Maintainerinfo[primary]={ "mnames": ["secondary1","secondary2"...],
# Maintainerinfo[primary]={ "mntnams": ["secondary1","secondary2"...],
# "emails": ["email1","email2"...],
# "latest": { "date":cdate,"commit":commit } }
# where 'primary' is the primary maintainer name,
......@@ -92,8 +92,8 @@ def update_maintainers():
# are fickle. The primary name is just the first variant to be discovered.
# It might be obsolete or a typo, but we don't care :)
#
mname_lookup={}
# mname_lookup[secondary]="primary"
mntnam_lookup={}
# mntnam_lookup[secondary]="primary"
#
email_lookup={}
# email_lookup[email]="primary"
......@@ -102,41 +102,41 @@ def update_maintainers():
for prgnam, prginfo in slackbuilds.SBinfo.items():
mname=prginfo["maintainer"]
mntnam=prginfo["maintainer"]
email=utils.unspamtrap(prginfo["email"])
if mname not in mname_lookup and email not in email_lookup:
# completely new mname+email combo
maintainer=mname
mname_lookup[mname]=maintainer
if mntnam not in mntnam_lookup and email not in email_lookup:
# completely new mntnam+email combo
maintainer=mntnam
mntnam_lookup[mntnam]=maintainer
email_lookup[email]=maintainer
Maintainerinfo[maintainer]={"mnames":[maintainer],"emails":[email],"slackbuilds":[prgnam]}
elif mname in mname_lookup and email not in email_lookup:
# mname is known, so it's a variant email for an existing maintainer
maintainer=mname_lookup[mname]
Maintainerinfo[maintainer]={"mntnams":[maintainer],"emails":[email],"slackbuilds":[prgnam]}
elif mntnam in mntnam_lookup and email not in email_lookup:
# mntnam is known, so it's a variant email for an existing maintainer
maintainer=mntnam_lookup[mntnam]
email_lookup[email]=maintainer
Maintainerinfo[maintainer]["emails"].append(email)
Maintainerinfo[maintainer]["slackbuilds"].append(prgnam)
elif mname not in mname_lookup and email in email_lookup:
elif mntnam not in mntnam_lookup and email in email_lookup:
# email is known, so it's a variant name for an existing maintainer
maintainer=email_lookup[email]
mname_lookup[mname]=maintainer
Maintainerinfo[maintainer]["mnames"].append(mname)
mntnam_lookup[mntnam]=maintainer
Maintainerinfo[maintainer]["mntnams"].append(mntnam)
Maintainerinfo[maintainer]["slackbuilds"].append(prgnam)
else: # mname in mname_lookup and email in email_lookup:
# we know both the mname and the email,
else: # mntnam in mntnam_lookup and email in email_lookup:
# we know both the mntnam and the email,
# but do we need to merge two Maintainerinfo records into one?
maintainer=mname_lookup[mname]
maintainer=mntnam_lookup[mntnam]
synonym=email_lookup[email]
if maintainer != synonym:
# yes, we need to merge them :(
Maintainerinfo[maintainer]["mnames"].extend(Maintainerinfo[synonym]["mnames"])
Maintainerinfo[maintainer]["mntnams"].extend(Maintainerinfo[synonym]["mntnams"])
Maintainerinfo[maintainer]["emails"].extend(Maintainerinfo[synonym]["emails"])
Maintainerinfo[maintainer]["slackbuilds"].extend(Maintainerinfo[synonym]["slackbuilds"])
Maintainerinfo[maintainer]["slackbuilds"].append(prgnam)
for k in mname_lookup.keys():
if mname_lookup[k] == synonym:
mname_lookup[k]=maintainer
for k in mntnam_lookup.keys():
if mntnam_lookup[k] == synonym:
mntnam_lookup[k]=maintainer
for k in email_lookup.keys():
if email_lookup[k] == synonym:
email_lookup[k]=maintainer
......@@ -179,11 +179,11 @@ def update_maintainers():
logline=rawline.decode("latin-1")
date, commit, author, email = logline.split(SEP)
if author in mname_lookup:
setlatest(mname_lookup[author],date,commit)
if author in mntnam_lookup:
setlatest(mntnam_lookup[author],date,commit)
elif email in email_lookup:
setlatest(email_lookup[email],date,commit)
# Ignore git authors that are in the log but not in mname_lookup or email_lookup.
# Ignore git authors that are in the log but not in mntnam_lookup or email_lookup.
# They are either retired maintainers, or randoms with a nice git mention :)
# (3) Add details from repology (if available) and format some html table cells.
......@@ -197,45 +197,45 @@ def update_maintainers():
inactivedate="2016-06-30"
# Maintainer number to identify the modal popup of slackbuilds
mnum=0
mntnum=0
sess = requests.session()
for mname, mdeets in Maintainerinfo.items():
for mntnam, mntdeets in Maintainerinfo.items():
mdeets["tdmaintainer"]=mname
mdeets["mnum"]=mnum ; mnum+=1
mdeets["tdslackbuilds"]="{:d}".format(len(mdeets["slackbuilds"]))
mntdeets["tdmaintainer"]=mntnam
mntdeets["mntnum"]=mntnum ; mntnum+=1
mntdeets["tdslackbuilds"]="{:d}".format(len(mntdeets["slackbuilds"]))
mdeets["status"]="inactive"
if "latest" in mdeets:
mdeets["tdlatest"]="<a class=\"c\" target=\"_blank\" href=\"https://git.slackbuilds.org/slackbuilds/commit/?id={:s}\">{:s}</a>".format(mdeets["latest"]["commit"],mdeets["latest"]["date"])
if mdeets["latest"]["date"] >= inactivedate:
mdeets["status"]="active"
mntdeets["status"]="inactive"
if "latest" in mntdeets:
mntdeets["tdlatest"]="<a class=\"c\" target=\"_blank\" href=\"https://git.slackbuilds.org/slackbuilds/commit/?id={:s}\">{:s}</a>".format(mntdeets["latest"]["commit"],mntdeets["latest"]["date"])
if mntdeets["latest"]["date"] >= inactivedate:
mntdeets["status"]="active"
stats.addStats("maintainers.active")
if mdeets["latest"]["date"] >= recentdate:
mdeets["status"]="recent"
if mntdeets["latest"]["date"] >= recentdate:
mntdeets["status"]="recent"
stats.addStats("maintainers.recent")
else:
mdeets["tdlatest"]="Never"
mntdeets["tdlatest"]="Never"
repology_slackbuilds=0; repology_newest=0; repology_outofdate=0
for email in mdeets["emails"]:
for email in mntdeets["emails"]:
count, new, old = repology_by_maintainer(email,sess)
repology_slackbuilds+=count; repology_newest+=new; repology_outofdate+=old
stats.addStats("slackbuilds.uptodate",new); stats.addStats("slackbuilds.outofdate",old)
if repology_slackbuilds != 0:
mdeets["tdmaintainer"]+="<br><a class=\"e\" target=\"_blank\" href=\"http://repology.org/metapackages/?maintainer={:s}\">{:s}</a>".format(urllib.parse.quote(email),email)
mdeets["tdnewest"]="{:d}".format(repology_newest)
mdeets["tdnewestpct"]="{:.1f}%".format(repology_newest*100/repology_slackbuilds)
mdeets["tdoutofdate"]="{:d}".format(repology_outofdate)
mdeets["tdoutofdatepct"]="{:.1f}%".format(repology_outofdate*100/repology_slackbuilds)
mntdeets["tdmaintainer"]+="<br><a class=\"e\" target=\"_blank\" href=\"http://repology.org/metapackages/?maintainer={:s}\">{:s}</a>".format(urllib.parse.quote(email),email)
mntdeets["tdnewest"]="{:d}".format(repology_newest)
mntdeets["tdnewestpct"]="{:.1f}%".format(repology_newest*100/repology_slackbuilds)
mntdeets["tdoutofdate"]="{:d}".format(repology_outofdate)
mntdeets["tdoutofdatepct"]="{:.1f}%".format(repology_outofdate*100/repology_slackbuilds)
else:
mdeets["tdmaintainer"]+="<br><span class=\"e\">{:s}</span>".format(email)
mdeets["tdnewest"]="-"
mdeets["tdnewestpct"]="-"
mdeets["tdoutofdate"]="-"
mdeets["tdoutofdatepct"]="-"
mntdeets["tdmaintainer"]+="<br><span class=\"e\">{:s}</span>".format(email)
mntdeets["tdnewest"]="-"
mntdeets["tdnewestpct"]="-"
mntdeets["tdoutofdate"]="-"
mntdeets["tdoutofdatepct"]="-"
logging.info("finished")
......@@ -249,7 +249,7 @@ def render_maintainers():
utils.renderer( page_name="maintainers",
page_subdir="reports",
page_title="SBo Maintainers",
Table=Maintainerinfo )
TemplateData=Maintainerinfo )
logging.info("finished")
#-----------------------------------------------------------------------
......@@ -114,7 +114,7 @@ def render_problems():
utils.renderer( page_name="problems",
page_subdir="reports",
page_title="SBo Problems",
Table=Problems )
TemplateData=Problems )
logging.info("finished")
#-----------------------------------------------------------------------
<footer>
<p>Page updated: {{ page_datetime }}</p>
</footer>
......@@ -6,7 +6,7 @@
<body>
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
<p>Site updated: {{ page_datetime }} </p>
<h3>Reports</h3>
<ul>
......@@ -16,8 +16,8 @@
<h3>Details</h3>
<ul>
<li><a href="{{ siteurl }}/maintainers/">Maintainers</a></li>
<li><a href="{{ siteurl }}/slackbuilds/">SlackBuilds</a></li>
<li><a href="{{ siteurl }}/maintainers/">Browse Maintainer details</a></li>
<li><a href="{{ siteurl }}/slackbuilds/">Browse SlackBuild details</a></li>
</ul>
</body>
......
......@@ -6,8 +6,6 @@
<body>
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
<p>SlackBuilds
<br>&nbsp;&nbsp;&nbsp;total: {{ "{:d}".format(Stats["slackbuilds.count"]) }}
<br>&nbsp;&nbsp;&nbsp;newest: {{ "{:d} ({:.1f}%)".format(Stats["slackbuilds.uptodate"],Stats["slackbuilds.uptodate"]*100/Stats["slackbuilds.count"]) }}
......@@ -34,30 +32,32 @@
</thead>
<tbody>
{% for mname, mdeets in Table|dictsort(true) %}
<tr id="m{{ mdeets['mnum'] }}" class="{{ 'm-'+mdeets['status'] }}">
<td class="m">{{ mdeets["tdmaintainer"] }}</td>
<td class="l">{{ mdeets["tdlatest"] }}</td>
<td class="s"><a href="#sb{{ mdeets["mnum"] }}">{{ mdeets["tdslackbuilds"] }}</a></td>
<td class="n">{{ mdeets["tdnewest"] }}</td>
<td class="np">{{ mdeets["tdnewestpct"] }}</td>
<td class="o">{{ mdeets["tdoutofdate"] }}</td>
<td class="op">{{ mdeets["tdoutofdatepct"] }}</td>
{% for mntnam, mntdeets in TemplateData|dictsort(true) %}
<tr id="m{{ mntdeets['mntnum'] }}" class="{{ 'm-'+mntdeets['status'] }}">
<td class="m">{{ mntdeets["tdmaintainer"] }}</td>
<td class="l">{{ mntdeets["tdlatest"] }}</td>
<td class="s"><a href="#sb{{ mntdeets["mntnum"] }}">{{ mntdeets["tdslackbuilds"] }}</a></td>
<td class="n">{{ mntdeets["tdnewest"] }}</td>
<td class="np">{{ mntdeets["tdnewestpct"] }}</td>
<td class="o">{{ mntdeets["tdoutofdate"] }}</td>
<td class="op">{{ mntdeets["tdoutofdatepct"] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% for mname, mdeets in Table.items() %}
<div id="sb{{ mdeets['mnum'] }}" class="modal">
{% for mntnam, mntdeets in TemplateData.items() %}
<div id="sb{{ mntdeets['mntnum'] }}" class="modal">
<div>
<a href="#close" title="Close" class="closebutton">&otimes;</a>
<h3>{{ mname }}</h3>
<p class="t">{{ mdeets["slackbuilds"]|sort|join("<br>") }}</p>
<h3>{{ mntnam }}</h3>
<p class="t">{{ mntdeets["slackbuilds"]|sort|join("<br>") }}</p>
</div>
</div>
{% endfor %}
{% include 'footer.jinja2' %}
</body>
</html>
......@@ -6,8 +6,6 @@
<body>
<h1>{{ page_title }}</h1>
<p>Updated: {{ page_datetime }}</p>
<p>Problems: {{ "{:d}".format(Stats["problems.count"]) }}</p>
......@@ -26,7 +24,7 @@
</thead>
<tbody>
{% for problem in Table %}
{% for problem in TemplateData %}
<tr id="{{ problem['catnam']+'/'+problem['prgnam'] }}">
<td class="catnam">{{ problem['catnam'] }}</td>
<td class="prgnam"><a href="{{ siteurl }}/slackbuilds/{{ problem['catnam']+"/"+problem['prgnam'] }}" target="_blank">{{ problem['prgnam'] }}</a></td>
......@@ -41,5 +39,7 @@
</table>
{% include 'footer.jinja2' %}
</body>
</html>
......@@ -56,19 +56,22 @@ def unspamtrap(address):
def renderer( page_name,
page_subdir="",
page_title="",
Table=[] ):
template="",
TemplateData=[] ):
"""
Render a page
"""
if page_title == "":
page_title = page_name.capitalize()
if template == "":
template = page_name
page_path=os.path.join(globals.sitedir,page_subdir,page_name+".html")
os.makedirs(os.path.dirname(page_path),exist_ok=True)
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(globals.templatesdir),autoescape=None)
mytemplate = jenv.get_template(page_name+".jinja2")
mytemplate = jenv.get_template(template+".jinja2")
with open(page_path,"w",encoding="utf-8") as page_file:
print(
......@@ -76,7 +79,7 @@ def renderer( page_name,
siteurl=globals.siteurl,
page_title=page_title,
page_datetime=globals.updateref.strftime("%Y-%m-%d %T %Z"),
Table=Table,
TemplateData=TemplateData,
Stats=stats.Stats
),
file=page_file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment