Statoolinfos: indev to create contents file

This commit is contained in:
Cyrille L 2023-03-10 15:49:22 +01:00
parent 8a43b795bb
commit 6a06c07419
1 changed files with 33 additions and 8 deletions

View File

@ -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
@ -116,3 +127,17 @@ def count_stats():
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)