From 6a06c074191862acc34ff23d44149dcba8c642d9 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Fri, 10 Mar 2023 15:49:22 +0100 Subject: [PATCH] Statoolinfos: indev to create contents file --- src/var/lib/tyto/program/stats.py | 41 +++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/var/lib/tyto/program/stats.py b/src/var/lib/tyto/program/stats.py index 6179bf2..7f4fe2a 100644 --- a/src/var/lib/tyto/program/stats.py +++ b/src/var/lib/tyto/program/stats.py @@ -25,7 +25,8 @@ sti_images = sti_files = sti_raws = 0 sti_tags = sti_words = sti_titles = sti_paragraphs = sti_anclink = 0 sti_strongs = sti_bolds = sti_emphasis = sti_italics = sti_dels = 0 sti_underlines = sti_cites = sti_customs = sti_icodes = 0 -sti_bcodes = sti_quotes = sti_lists = 0 +sti_bcodes = sti_quotes = sti_lists = sti_articles = 0 + #=======================# # Manage "stats" option # @@ -43,11 +44,19 @@ def manage_stats(process): do[args.action](process) +#==========================# +# Check databases' article # +#--------------------------# def loop_articles(process): + global file_uri, domain_srv + global sti_articles + if process == 'wip': - file_stats = '%s%s'%(db.srv_wip, tyto.stats_f) + file_uri = '%s%s'%(db.srv_wip, tyto.stats_f) + domain_srv = db.domain_wip_url elif process == 'www': - file_stats = '%s%s'%(db.srv_www, tyto.stats_f) + file_uri = '%s%s'%(db.srv_www, tyto.stats_f) + domain_srv = db.domain_www_url # Get databases of wip's articles for post_db in os.listdir(db.articles_db): @@ -70,18 +79,20 @@ def loop_articles(process): logs.out("9", db.post_src, False) continue + sti_articles += 1 count_stats() # www elif process == 'www': if not db.hash_www: continue - print("> anchors", sti_anchors, sti_strongs) - logs.out("33", file_stats, False) + create_stats_file(file_uri) -# -# Set Statistics and count -# + +#================================# +# Set Statistics and count # +# in a loop, from loop_article() # +#--------------------------------# def count_stats(): # Set Statistics global sti_anchors, sti_abbrs, sti_links @@ -115,4 +126,18 @@ def count_stats(): sti_bcodes = sti_bcodes + db.stat_bcodes sti_quotes = sti_quotes + db.stat_quotes sti_lists = sti_lists + db.stat_lists + + +#============================# +# Create stat file in server # +#----------------------------# +def create_stats_file(file_uri): + sti = \ + '# Statistics file created by %s\n'%tyto.Tyto + \ + '# Website: %s\n'%domain_srv + \ + '\n' + \ + 'stats_articles = %d\n'%int(sti_articles) + + tyto.set_file(file_uri, 'New', sti) + logs.out("33", file_uri, False)