From cba1abbe8a13aded6e7ed2c1576eb8cbd18c1bdb Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Wed, 5 Apr 2023 08:22:51 +0200 Subject: [PATCH] Add in stats file: authors number --- src/var/lib/tyto/program/check.py | 3 --- src/var/lib/tyto/program/stats.py | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 2959eab..3931a5f 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -435,9 +435,6 @@ def check_opt_tags(post_header): for ln, line in enumerate(post_header, 1): if line.startswith('%s:'%tag): check_3lines(tag, ln, line) - - print("> post_files =", post_files) - print("> post_links =", post_links) #============================================# diff --git a/src/var/lib/tyto/program/stats.py b/src/var/lib/tyto/program/stats.py index ea445ee..a3197f5 100644 --- a/src/var/lib/tyto/program/stats.py +++ b/src/var/lib/tyto/program/stats.py @@ -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"] ) ) +