Add in stats file: authors number

This commit is contained in:
Cyrille L 2023-04-05 08:22:51 +02:00
parent b32046e183
commit cba1abbe8a
2 changed files with 21 additions and 4 deletions

View File

@ -436,9 +436,6 @@ def check_opt_tags(post_header):
if line.startswith('%s:'%tag):
check_3lines(tag, ln, line)
print("> post_files =", post_files)
print("> post_links =", post_links)
#============================================#
# Do stats, check 3 lines tags from ln #

View File

@ -98,7 +98,11 @@ def loop_articles(process):
def count_stats(add):
# Set
if not add:
global stats
global stats, authors, author_names
# Specific for Authors (not in database stats)
author_names = author.replace(' ', '').split(",")
authors = 0
stats = { \
"sti_uniq_anchors" : uniq_anchors,
@ -137,6 +141,17 @@ def count_stats(add):
# Count
else:
# Authors are not set in database stats
new_authors = author.replace(' ', '').split(",")
# Do not count author if known
for name in new_authors:
if name in author_names:
continue
author_names = author_names + [name]
# From database stats
for i in stats:
stat_db = i.rsplit("sti_")[1]
stats[i] = stats[i] + eval(stat_db)
@ -146,6 +161,9 @@ def count_stats(add):
# Create stat file in server #
#----------------------------#
def create_stats_file(file_uri):
# Count authors
authors = len(author_names)
sti = \
'# Statistics file created by %s\n'%tyto.Tyto + \
'# Website: %s\n'%domain_srv + \
@ -154,6 +172,7 @@ def create_stats_file(file_uri):
'\n' + \
'# Uniq statistics from articles\' headers\n' + \
'articles = %d\n'%int(sti_articles) + \
'uniq_authors = %d\n'%int(authors) + \
'uniq_anchors = %d\n'%stats["sti_uniq_anchors"] + \
'uniq_abbrs = %d\n'%stats["sti_uniq_abbrs"] + \
'uniq_links = %d\n'%stats["sti_uniq_links"] + \
@ -203,3 +222,4 @@ def create_stats_file(file_uri):
sti_articles, stats["sti_words"]
)
)