in-test for wip all/again/newer

This commit is contained in:
Cyrille L 2023-04-04 18:16:12 +02:00
parent 7533b83d8a
commit de2533480e
6 changed files with 41 additions and 37 deletions

View File

@ -88,13 +88,15 @@ def check_all(option):
if post_db.endswith('.config'): if post_db.endswith('.config'):
# Load DB # Load DB
post_db = '%s%s'%(dom.articles_db_d, post_db) post_db = '%s%s'%(dom.articles_db_d, post_db)
exec(open(post_db).read(),globals()) try:
args.target = post_src.rsplit('%s/'%db.in_dir)[1] exec(open(post_db).read(),globals())
importlib.reload(db) args.target = post_src.rsplit('%s/'%db.in_dir)[1]
#print(':> [%s] - %s'%(db.title, db.post_src)) importlib.reload(db)
except:
continue
if not db.exists: continue if option == 'all' and not db.old_chk:
if option == 'all' and not db.old_chk: continue continue
found = True found = True
print(' ├ [%s] > %s'%(db.title, db.post_src)) print(' ├ [%s] > %s'%(db.title, db.post_src))

View File

@ -76,14 +76,12 @@ def loop_articles(process):
if process == 'wip': hash_srv = hash_wip if process == 'wip': hash_srv = hash_wip
elif process == 'www': hash_srv = hash_www elif process == 'www': hash_srv = hash_www
# - Now generic for wip and www # - Now generic for wip and www
# - Article has changed and could have different stats # - Article has changed and could have different stats
if not hash_srv or \ if not hash_srv or \
hash_srv != hash_chk: hash_srv != hash_chk:
continue continue
sti_articles += 1 sti_articles += 1
if sti_articles == 1: count_stats(False) if sti_articles == 1: count_stats(False)
else: count_stats(True) else: count_stats(True)
@ -92,6 +90,7 @@ def loop_articles(process):
if sti_articles > 0: create_stats_file(file_uri) if sti_articles > 0: create_stats_file(file_uri)
else: logs.out("28", '%s stats'%process, True) else: logs.out("28", '%s stats'%process, True)
#===============================# #===============================#
# False: Set First statistics # # False: Set First statistics #
# True: Count total statistics # # True: Count total statistics #
@ -191,9 +190,3 @@ def create_stats_file(file_uri):
sti_articles, stats["sti_post_words"] sti_articles, stats["sti_post_words"]
) )
) )
#======================================#
# Show statistics from pages on server #
#--------------------------------------#
def show_stats(process):
show.read_lines(file_uri)

View File

@ -35,7 +35,7 @@
import os, sys, re, subprocess, locale, base64, datetime, shutil import os, sys, re, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b from hashlib import blake2b
import args, dom, logs import args, dom, logs, langs, form
# :D # :D
Tyto = 'Tyto - Littérateur' Tyto = 'Tyto - Littérateur'
@ -552,18 +552,12 @@ def files_to_srv(server):
# #
def process_all(process): def process_all(process):
# if target == 'all': # if target == 'all':
if args.target == "all": if args.target == "again":
ask = '' form.asking("%s%s "%(
try: langs.site.wip_again, langs.site.q
ask = input("%s all already converted articles ? "%process) ), True)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not ask in ['y', 'Y']: elif args.target == "all":
logs.out("255", '', True)
elif args.target == "again":
print('%s again current matches articles'%process) print('%s again current matches articles'%process)
elif args.target == "newer": elif args.target == "newer":
print('%s newer articles'%process) print('%s newer articles'%process)

View File

@ -100,7 +100,7 @@ def wip_all(process):
tyto.process_all('Wip') tyto.process_all('Wip')
# Sort by newer articles (created by last check) # Sort by newer articles (created by last check)
db_articles = sorted(Path(db.articles_db_d).iterdir(), db_articles = sorted(Path(dom.articles_db_d).iterdir(),
key=os.path.getmtime key=os.path.getmtime
) )
@ -108,23 +108,36 @@ def wip_all(process):
option = args.target option = args.target
found = False found = False
for post_db in db_articles: for post_db in db_articles:
if not str(post_db).endswith('.config'): continue if not str(post_db).endswith('.config'):
continue
# Load DB # Load DB
exec(open(post_db).read(),globals()) try:
args.target = post_src.rsplit('%s/'%db.in_dir)[1] exec(open(post_db).read(),globals())
importlib.reload(db) args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
except:
continue
if not db.hash_wip: continue # Article has changed and not check
if option == "again" and db.old_wip: continue
if option == "newer" and not db.old_wip: continue
print(' ├ [%s] > %s'%(db.title, db.post_src))
if db.old_chk: if db.old_chk:
logs.out("9", '', False) logs.out("9", post_db, False)
continue
# newer: article not yet wip
elif option == "newer" and db.hash_wip:
continue
# All: only old wip
elif option == "all" and not db.old_wip:
continue
# again: wip again wip articles
elif option == "again" and not db.hash_wip:
continue continue
found = True found = True
print(' ├ [%s] > %s'%(db.title, db.post_src))
wip_article(db.post_src) wip_article(db.post_src)
if not found: logs.out("28", '(wip)', True) if not found: logs.out("28", '(wip)', True)

View File

@ -71,6 +71,7 @@ post_chg = "Article was edited. Check it"
# Wip # Wip
wip_new = "Create new HTML page in wip" wip_new = "Create new HTML page in wip"
wip_again = "Create again already converted pages"
# Form # Form
#---------------------------------------------------------------------- #----------------------------------------------------------------------

View File

@ -70,6 +70,7 @@ post_chg = "Article édité. Le vérifier"
# Wip # Wip
wip_new = "Créer une nouvelle page HTML dans wip" wip_new = "Créer une nouvelle page HTML dans wip"
wip_again = "Créer encore les pages déjà converties"
# Formulaire # Formulaire
#---------------------------------------------------------------------- #----------------------------------------------------------------------