screenshot (github top 50) and statistics charts support in website output

game engines now counted as frameworks
few additions
This commit is contained in:
Trilarion
2021-10-08 13:34:01 +02:00
parent 32907d0498
commit 8486b618e1
133 changed files with 12015 additions and 23895 deletions

View File

@ -11,9 +11,11 @@ entries_path = os.path.join(root_path, 'entries')
tocs_path = os.path.join(entries_path, 'tocs')
code_path = os.path.join(root_path, 'code')
web_path = os.path.join(root_path, 'docs')
screenshots_path = os.path.join(entries_path, 'screenshots')
web_template_path = os.path.join(code_path, 'html')
web_css_path = os.path.join(web_path, 'css')
web_js_path = os.path.join(web_path, 'js')
web_screenshots_path = os.path.join(web_path, 'screenshots')
private_properties_file = os.path.join(root_path, 'private.properties')
inspirations_file = os.path.join(root_path, 'inspirations.md')
@ -22,6 +24,7 @@ developer_file = os.path.join(root_path, 'developers.md')
backlog_file = os.path.join(code_path, 'backlog.txt')
rejected_file = os.path.join(code_path, 'rejected.txt')
statistics_file = os.path.join(root_path, 'statistics.md')
screenshots_file = os.path.join(screenshots_path, 'README.md')
json_db_file = os.path.join(root_path, 'docs', 'data.json')
# local config

View File

@ -615,4 +615,55 @@ def hg_repo(repo):
return repo
# not hg
return None
return None
def read_screenshots_overview():
"""
:return:
"""
# read screenshots readme and parse
overview = {}
text = utils.read_text(c.screenshots_file)
for entry in text.split('\n# ')[1:]: # skip first paragraph
lines = entry.split('\n') # split into lines
name = lines[0]
if name not in overview:
overview[name] = {}
lines = [line for line in lines[1:] if line] # include only non-empty lines
# for every screenshot
for line in lines:
values = line.split(' ') # split into values
values = [value for value in values if value]
id = int(values[0]) # id (must be there)
width = int(values[1]) # width can be 0, will be updated
height = int(values[2]) # height can be 0, will be updated
if len(values) > 3: # optional an url
url = values[3]
else:
url = None
overview[name][id] = [width, height, url]
return overview
def write_screenshots_overview(overview):
"""
:param overview:
:return:
"""
# get preamble
text = utils.read_text(c.screenshots_file)
text = text.split('\n# ')[0] + '\n'
for name, a in overview.items():
t = '# {}\n\n'.format(name)
for id, ai in a.items():
if ai[-1] is None:
ai = ai[:-1]
t += ' '.join(['{:02d}'.format(id)] + [str(x) for x in ai]) + '\n'
t += '\n'
text += t
utils.write_text(c.screenshots_file, text)

View File

@ -3,6 +3,9 @@ Central place to calculate statistics about the entries. Used for updating the s
of the website.
"""
import os
import matplotlib.pyplot as plt
def get_build_systems(entries):
"""
@ -12,7 +15,7 @@ def get_build_systems(entries):
"""
build_systems = []
for entry in entries:
build_systems.extend(entry['Building'].get('Build system', ['n/a']))
build_systems.extend(entry['Building'].get('Build system', ['N/A']))
unique_build_systems = set(build_systems)
@ -21,3 +24,35 @@ def get_build_systems(entries):
build_systems_stat.sort(key=lambda x: -x[1]) # then sort by occurrence (highest occurrence first)
return build_systems_stat
def truncate_stats(stat, threshold, name='Other'):
"""
Combines all entries (name, count) with a count below the threshold and appends a new entry
"""
a, b = [], []
for s in stat:
(a, b)[s[1] < threshold].append(s)
c = 0
for s in b:
c += s[1]
a.append([name, c])
return a
def export_pie_chart(stat, file):
"""
:param stat:
:return:
"""
labels = [x[0] for x in stat]
sizes = [x[1] for x in stat]
fig, ax = plt.subplots(figsize=[4,4], tight_layout=True)
ax.pie(sizes, labels=labels, autopct='%1.1f%%', pctdistance=0.8, shadow=True, labeldistance=1.2)
# create output directory if necessary
containing_dir = os.path.dirname(file)
if not os.path.isdir(containing_dir):
os.mkdir(containing_dir)
plt.savefig(file, transparent=True)