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'):
# Load DB
post_db = '%s%s'%(dom.articles_db_d, post_db)
exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
#print(':> [%s] - %s'%(db.title, db.post_src))
try:
exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
except:
continue
if not db.exists: continue
if option == 'all' and not db.old_chk: continue
if option == 'all' and not db.old_chk:
continue
found = True
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
elif process == 'www': hash_srv = hash_www
# - Now generic for wip and www
# - Article has changed and could have different stats
if not hash_srv or \
hash_srv != hash_chk:
continue
sti_articles += 1
if sti_articles == 1: count_stats(False)
else: count_stats(True)
@ -92,6 +90,7 @@ def loop_articles(process):
if sti_articles > 0: create_stats_file(file_uri)
else: logs.out("28", '%s stats'%process, True)
#===============================#
# False: Set First statistics #
# True: Count total statistics #
@ -191,9 +190,3 @@ def create_stats_file(file_uri):
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
from hashlib import blake2b
import args, dom, logs
import args, dom, logs, langs, form
# :D
Tyto = 'Tyto - Littérateur'
@ -552,18 +552,12 @@ def files_to_srv(server):
#
def process_all(process):
# if target == 'all':
if args.target == "all":
ask = ''
try:
ask = input("%s all already converted articles ? "%process)
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not ask in ['y', 'Y']:
logs.out("255", '', True)
if args.target == "again":
form.asking("%s%s "%(
langs.site.wip_again, langs.site.q
), True)
elif args.target == "again":
elif args.target == "all":
print('%s again current matches articles'%process)
elif args.target == "newer":
print('%s newer articles'%process)

View File

@ -100,7 +100,7 @@ def wip_all(process):
tyto.process_all('Wip')
# 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
)
@ -108,23 +108,36 @@ def wip_all(process):
option = args.target
found = False
for post_db in db_articles:
if not str(post_db).endswith('.config'): continue
if not str(post_db).endswith('.config'):
continue
# Load DB
exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
try:
exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
except:
continue
if not db.hash_wip: continue
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))
# Article has changed and not check
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
found = True
print(' ├ [%s] > %s'%(db.title, db.post_src))
wip_article(db.post_src)
if not found: logs.out("28", '(wip)', True)

View File

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

View File

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