Updated code for stats in function count_stats(). Thx neox for help

This commit is contained in:
Cyrille L 2023-04-04 17:22:26 +02:00
parent 7b9d4cf89c
commit 7533b83d8a
2 changed files with 108 additions and 160 deletions

View File

@ -103,17 +103,17 @@ def manage(target):
# as edit* &nd show* [action] have same target file
actions = \
{
'show' : 'src',
'edit' : 'src',
'post' : 'src',
'show-db' : 'db',
'edit-db' : 'db',
'show-about' : 'about',
'edit-about' : 'about',
'show-wip' : 'wip',
'edit-wip' : 'wip',
'show-www' : 'www',
'edit-www' : 'www'
"show" : 'src',
"edit" : 'src',
"post" : 'src',
"show-db" : 'db',
"edit-db" : 'db',
"show-about" : 'about',
"edit-about" : 'about',
"show-wip" : 'wip',
"edit-wip" : 'wip',
"show-www" : 'www',
"edit-www" : 'www'
}
action = actions[args.action]
@ -121,46 +121,46 @@ def manage(target):
do = \
{
'src' : {
'domain' : dom.config,
'footer' : dom.footer_f,
'metas' : dom.metas_f,
'navbar' : dom.navbar_f,
'sidebar' : dom.sidebar_f,
'post' : post_src
"domain" : dom.config,
"footer" : dom.footer_f,
"metas" : dom.metas_f,
"navbar" : dom.navbar_f,
"sidebar" : dom.sidebar_f,
"post" : post_src
},
'db' : {
'domain' : dom.config,
'footer' : dom.footer_f,
'metas' : dom.metas_f,
'navbar' : dom.navbar_f,
'sidebar' : dom.sidebar_f,
'post' : post_db
"domain" : dom.config,
"footer" : dom.footer_f,
"metas" : dom.metas_f,
"navbar" : dom.navbar_f,
"sidebar" : dom.sidebar_f,
"post" : post_db
},
'about' : {
'domain' : dom.config,
'footer' : dom.footer_about_f,
'metas' : dom.metas_f,
'navbar' : dom.navbar_f,
'sidebar' : dom.sidebar_f,
'post' : post_db
"domain" : dom.config,
"footer" : dom.footer_about_f,
"metas" : dom.metas_f,
"navbar" : dom.navbar_f,
"sidebar" : dom.sidebar_f,
"post" : post_db
},
'wip' : {
'domain' : dom.config,
'footer' : dom.wip_footer_f,
'metas' : dom.wip_metas_f,
'navbar' : dom.wip_navbar_f,
'sidebar' : dom.wip_sidebar_f,
'post' : post_wip,
'stats' : dom.wip_stats_f,
"domain" : dom.config,
"footer" : dom.wip_footer_f,
"metas" : dom.wip_metas_f,
"navbar" : dom.wip_navbar_f,
"sidebar" : dom.wip_sidebar_f,
"post" : post_wip,
"stats" : dom.wip_stats_f,
},
'www' : {
'domain' : dom.config,
'footer' : dom.www_footer_f,
'metas' : dom.www_metas_f,
'navbar' : dom.www_navbar_f,
'sidebar' : dom.www_sidebar_f,
'post' : post_www,
'stats' : dom.www_stats_f,
"domain" : dom.config,
"footer" : dom.www_footer_f,
"metas" : dom.www_metas_f,
"navbar" : dom.www_navbar_f,
"sidebar" : dom.www_sidebar_f,
"post" : post_www,
"stats" : dom.www_stats_f,
},
}

View File

@ -97,97 +97,45 @@ def loop_articles(process):
# True: Count total statistics #
#-------------------------------#
def count_stats(add):
global sti_uniq_anchors
global sti_uniq_abbrs
global sti_uniq_links
global sti_uniq_images
global sti_uniq_files
global sti_uniq_codes
global sti_uniq_raws
global sti_posts_coms
global sti_posts_tags
global sti_posts_lines
global sti_posts_words
global sti_posts_titles
global sti_posts_paragraphs
global sti_posts_anchors
global sti_posts_abbrs
global sti_posts_strongs
global sti_posts_bolds
global sti_posts_emphasis
global sti_posts_italics
global sti_posts_dels
global sti_posts_underlines
global sti_posts_cites
global sti_posts_customs
global sti_posts_icodes
global sti_posts_bcodes
global sti_posts_quotes
global sti_posts_lists
# Set
if not add:
sti_uniq_anchors = uniq_anchors
sti_uniq_abbrs = uniq_abbrs
sti_uniq_links = uniq_links
sti_uniq_images = uniq_images
sti_uniq_files = uniq_files
sti_uniq_codes = uniq_codes
sti_uniq_raws = uniq_raws
global stats
sti_posts_coms = post_coms
sti_posts_tags = post_tags
sti_posts_lines = post_lines
sti_posts_words = post_words
sti_posts_titles = post_titles
sti_posts_paragraphs = post_paragraphs
sti_posts_anchors = post_anchors
sti_posts_abbrs = post_abbrs
sti_posts_strongs = post_strongs
sti_posts_bolds = post_bolds
sti_posts_emphasis = post_emphasis
sti_posts_italics = post_italics
sti_posts_dels = post_dels
sti_posts_underlines = post_underlines
sti_posts_cites = post_cites
sti_posts_customs = post_customs
sti_posts_icodes = post_icodes
sti_posts_bcodes = post_bcodes
sti_posts_quotes = post_quotes
sti_posts_lists = post_lists
stats = { \
"sti_uniq_anchors" : uniq_anchors,
"sti_uniq_abbrs" : uniq_abbrs,
"sti_uniq_links" : uniq_links,
"sti_uniq_images" : uniq_images,
"sti_uniq_files" : uniq_files,
"sti_uniq_codes" : uniq_codes,
"sti_uniq_raws" : uniq_raws,
"sti_post_coms" : post_coms,
"sti_post_tags" : post_tags,
"sti_post_lines" : post_lines,
"sti_post_words" : post_words,
"sti_post_titles" : post_titles,
"sti_post_paragraphs" : post_paragraphs,
"sti_post_anchors" : post_anchors,
"sti_post_abbrs" : post_abbrs,
"sti_post_strongs" : post_strongs,
"sti_post_bolds" : post_bolds,
"sti_post_emphasis" : post_emphasis,
"sti_post_italics" : post_italics,
"sti_post_dels" : post_dels,
"sti_post_underlines" : post_underlines,
"sti_post_cites" : post_cites,
"sti_post_customs" : post_customs,
"sti_post_icodes" : post_icodes,
"sti_post_bcodes" : post_bcodes,
"sti_post_quotes" : post_quotes,
"sti_post_lists" : post_lists,
}
# Count
else:
sti_uniq_anchors = sti_uniq_anchors + uniq_anchors
sti_uniq_abbrs = sti_uniq_abbrs + uniq_abbrs
sti_uniq_links = sti_uniq_links + uniq_links
sti_uniq_images = sti_uniq_images + uniq_images
sti_uniq_files = sti_uniq_files + uniq_files
sti_uniq_codes = sti_uniq_codes + uniq_codes
sti_uniq_raws = sti_uniq_raws + uniq_raws
sti_posts_coms = sti_posts_coms + post_coms
sti_posts_tags = sti_posts_tags + post_tags
sti_posts_lines = sti_posts_lines + post_lines
sti_posts_words = sti_posts_words + post_words
sti_posts_titles = sti_posts_titles + post_titles
sti_posts_paragraphs = sti_posts_paragraphs + post_paragraphs
sti_posts_anchors = sti_posts_anchors + post_anchors
sti_posts_abbrs = sti_posts_abbrs + post_abbrs
sti_posts_strongs = sti_posts_strongs + post_strongs
sti_posts_bolds = sti_posts_bolds + post_bolds
sti_posts_emphasis = sti_posts_emphasis + post_emphasis
sti_posts_italics = sti_posts_italics + post_italics
sti_posts_dels = sti_posts_dels + post_dels
sti_posts_underlines = sti_posts_underlines + post_underlines
sti_posts_cites = sti_posts_cites + post_cites
sti_posts_customs = sti_posts_customs + post_customs
sti_posts_icodes = sti_posts_icodes + post_icodes
sti_posts_bcodes = sti_posts_bcodes + post_bcodes
sti_posts_quotes = sti_posts_quotes + post_quotes
sti_posts_lists = sti_posts_lists + post_lists
for i in stats:
stat_db = i.rsplit("sti_")[1]
stats[i] = stats[i] + eval(stat_db)
#============================#
@ -202,45 +150,45 @@ def create_stats_file(file_uri):
'\n' + \
'# Uniq statistics from articles\' headers\n' + \
'stats_articles = %d\n'%int(sti_articles) + \
'stats_uniq_anchors = %d\n'%int(sti_uniq_anchors) + \
'stats_uniq_abbrs = %d\n'%int(sti_uniq_abbrs) + \
'stats_uniq_links = %d\n'%int(sti_uniq_links) + \
'stats_uniq_images = %d\n'%int(sti_uniq_images) + \
'stats_uniq_files = %d\n'%int(sti_uniq_files) + \
'stats_uniq_codes = %d\n'%int(sti_uniq_codes) + \
'stats_uniq_raws = %d\n'%int(sti_uniq_raws) + \
'stats_uniq_anchors = %d\n'%stats["sti_uniq_anchors"] + \
'stats_uniq_abbrs = %d\n'%stats["sti_uniq_abbrs"] + \
'stats_uniq_links = %d\n'%stats["sti_uniq_links"] + \
'stats_uniq_images = %d\n'%stats["sti_uniq_images"] + \
'stats_uniq_files = %d\n'%stats["sti_uniq_files"] + \
'stats_uniq_codes = %d\n'%stats["sti_uniq_codes"] + \
'stats_uniq_raws = %d\n'%stats["sti_uniq_raws"] + \
'\n' + \
'# Statistics from articles\' contents\n' + \
'stats_posts_coms = %d\n'%int(sti_posts_coms) + \
'stats_posts_tags = %d\n'%int(sti_posts_tags) + \
'stats_posts_lines = %d\n'%int(sti_posts_lines) + \
'stats_posts_words = %d\n'%int(sti_posts_words) + \
'stats_posts_titles = %d\n'%int(sti_posts_titles) + \
'stats_posts_paragraphs = %d\n'%int(sti_posts_paragraphs) + \
'stats_posts_anchors = %d\n'%int(sti_posts_anchors) + \
'stats_posts_abbrs = %d\n'%int(sti_posts_abbrs) + \
'stats_posts_strongs = %d\n'%int(sti_posts_strongs) + \
'stats_posts_bolds = %d\n'%int(sti_posts_bolds) + \
'stats_posts_emphasis = %d\n'%int(sti_posts_emphasis) + \
'stats_posts_italics = %d\n'%int(sti_posts_italics) + \
'stats_posts_dels = %d\n'%int(sti_posts_dels) + \
'stats_posts_underlines = %d\n'%int(sti_posts_underlines) + \
'stats_posts_cites = %d\n'%int(sti_posts_cites) + \
'stats_posts_customs = %d\n'%int(sti_posts_customs) + \
'stats_posts_icodes = %d\n'%int(sti_posts_icodes) + \
'stats_posts_bcodes = %d\n'%int(sti_posts_bcodes) + \
'stats_posts_quotes = %d\n'%int(sti_posts_quotes) + \
'stats_posts_lists = %d\n'%int(sti_posts_lists)
'stats_posts_coms = %d\n'%stats["sti_post_coms"] + \
'stats_posts_tags = %d\n'%stats["sti_post_tags"] + \
'stats_posts_lines = %d\n'%stats["sti_post_lines"] + \
'stats_posts_words = %d\n'%stats["sti_post_words"] + \
'stats_posts_titles = %d\n'%stats["sti_post_titles"] + \
'stats_posts_paragraphs = %d\n'%stats["sti_post_paragraphs"] + \
'stats_posts_anchors = %d\n'%stats["sti_post_anchors"] + \
'stats_posts_abbrs = %d\n'%stats["sti_post_abbrs"] + \
'stats_posts_strongs = %d\n'%stats["sti_post_strongs"] + \
'stats_posts_bolds = %d\n'%stats["sti_post_bolds"] + \
'stats_posts_emphasis = %d\n'%stats["sti_post_emphasis"] + \
'stats_posts_italics = %d\n'%stats["sti_post_italics"] + \
'stats_posts_dels = %d\n'%stats["sti_post_dels"] + \
'stats_posts_underlines = %d\n'%stats["sti_post_underlines"] + \
'stats_posts_cites = %d\n'%stats["sti_post_cites"] + \
'stats_posts_customs = %d\n'%stats["sti_post_customs"] + \
'stats_posts_icodes = %d\n'%stats["sti_post_icodes"] + \
'stats_posts_bcodes = %d\n'%stats["sti_post_bcodes"] + \
'stats_posts_quotes = %d\n'%stats["sti_post_quotes"] + \
'stats_posts_lists = %d\n'%stats["sti_post_lists"]
tyto.set_file(file_uri, 'New', sti)
try:
print('', langs.site.stats_f%(
sti_articles, sti_posts_words
sti_articles, stats["sti_post_words"]
)
)
except:
print(' └ Articles = %s ; Words = %s'%(
sti_articles, sti_posts_words
sti_articles, stats["sti_post_words"]
)
)