From de2533480e72441b2675276aba1f7f1be90f5227 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Tue, 4 Apr 2023 18:16:12 +0200 Subject: [PATCH] in-test for wip all/again/newer --- src/var/lib/tyto/program/check.py | 14 ++++++---- src/var/lib/tyto/program/stats.py | 9 +----- src/var/lib/tyto/program/tyto.py | 18 ++++-------- src/var/lib/tyto/program/wip.py | 35 ++++++++++++++++-------- src/var/lib/tyto/translations/site_en.py | 1 + src/var/lib/tyto/translations/site_fr.py | 1 + 6 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 5daf1c0..63ebe7b 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -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)) diff --git a/src/var/lib/tyto/program/stats.py b/src/var/lib/tyto/program/stats.py index e5652a8..2d9c48e 100644 --- a/src/var/lib/tyto/program/stats.py +++ b/src/var/lib/tyto/program/stats.py @@ -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) diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 309eb0e..1a43c36 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -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) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 234cd18..865c361 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -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) diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py index 0d23dac..37ee1f8 100644 --- a/src/var/lib/tyto/translations/site_en.py +++ b/src/var/lib/tyto/translations/site_en.py @@ -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 #---------------------------------------------------------------------- diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index ed933c5..1f52798 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -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 #----------------------------------------------------------------------