From 2f0b03c65639d499b529b3adcfcd39836ecdb7f0 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 6 Apr 2023 15:36:51 +0200 Subject: [PATCH] add arguments check [modules] and template. + Some fixes --- src/var/lib/tyto/program/args.py | 4 +- src/var/lib/tyto/program/check.py | 32 +++++++++++++++- src/var/lib/tyto/program/dom.py | 47 ++++++++++++++++++++++++ src/var/lib/tyto/program/logs.py | 1 + src/var/lib/tyto/program/show.py | 2 +- src/var/lib/tyto/program/wip.py | 6 +-- src/var/lib/tyto/translations/logs_en.py | 3 +- src/var/lib/tyto/translations/logs_fr.py | 3 +- src/var/lib/tyto/translations/site_fr.py | 2 +- 9 files changed, 90 insertions(+), 10 deletions(-) diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index 7914fa7..3cc2cc0 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -84,7 +84,7 @@ pass_db = \ pass_targets = \ ( -'all', +'updated', 'again', 'newer', 'domain', @@ -96,7 +96,7 @@ pass_targets = \ 'template' ) -multi_chk = ('all', 'again', 'newer') +multi_chk = ('updated', 'again', 'newer') action = '' target = '' diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 3c689d7..7bc940a 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -54,9 +54,16 @@ def manage(target): if not target: logs.out("5", '[target]', True) + # update, again, newer elif target in args.multi_chk: check_all(target) + + # modules (sidebar...) + elif target in args.pass_targets: + check_module(target) + return + # Unused file elif not db.post: logs.out("1", db.uri_file, True) @@ -72,10 +79,33 @@ def manage(target): else: check_process(target) + # Article is not valid if post_err and not target in args.multi_chk: logs.out("7", db.uri_file, True) +#===============================# +# Argument is a module name # +# Check if modules files exists # +#-------------------------------# +def check_module(target): + if target == "domain": + status.check(target) + return + + try: + unused_f = False + logs.out("60", '', False) + for t in dom.modules[target]: + if not os.path.exists(t): + logs.out("24", t, False) + unused_f = True + if not unused_f: + logs.out("28", "%s"%langs.log.all_ok, False) + except: + logs.out("28", "%s + %s"%(args.action, target), True) + + #==============================================# # Argument all # # check all realdy checkded articles # @@ -116,7 +146,7 @@ def check_all(option): except: continue - if option == 'all' and not db.old_chk: + if option == 'updated' and not db.old_chk: continue found = True diff --git a/src/var/lib/tyto/program/dom.py b/src/var/lib/tyto/program/dom.py index 911d705..5b8ee6e 100644 --- a/src/var/lib/tyto/program/dom.py +++ b/src/var/lib/tyto/program/dom.py @@ -201,6 +201,53 @@ if not hole: if active: ready = True + metas = ( + eval(str('metas_f')), + eval(str('wip_metas_f')), + eval(str('www_metas_f')) + ) + navbars = ( + eval(str('navbar_f')), + eval(str('wip_navbar_f')), + eval(str('www_navbar_f')) + ) + sidebars = ( + eval(str('sidebar_f')), + eval(str('wip_sidebar_f')), + eval(str('www_sidebar_f')) + ) + footers = ( + eval(str('footer_f')), + eval(str('wip_footer_f')), + eval(str('www_footer_f')), + eval(str('footer_about_f')) + ) + + templates = ( + eval(str('wip_logo_f')), + eval(str('wip_css_f')), + eval(str('wip_navbar_f')), + eval(str('wip_sidebar_f')), + eval(str('wip_metas_f')), + eval(str('wip_footer_f')), + eval(str('wip_stats_f')), + eval(str('www_logo_f')), + eval(str('www_css_f')), + eval(str('www_navbar_f')), + eval(str('www_sidebar_f')), + eval(str('www_metas_f')), + eval(str('www_footer_f')), + eval(str('www_stats_f')), + eval(str('www_rss_f')), + ) + + modules = { + "metas" : metas, + "navbar" : navbars, + "sidebar" : sidebars, + "footer" : footers, + "template": templates, + } #====================================# # Check if domain is ready and ready # diff --git a/src/var/lib/tyto/program/logs.py b/src/var/lib/tyto/program/logs.py index c90aec9..5e041fe 100644 --- a/src/var/lib/tyto/program/logs.py +++ b/src/var/lib/tyto/program/logs.py @@ -95,6 +95,7 @@ def out(nbr, value, out): '46' : ' ╞ %s%s %s%s > %s'%(CY, langs.log.time_t, langs.log.no_up, CS, value), '51' : ' ╞ %s%s%s > %s'%(CY, langs.log.data_inc, CS, value), '60' : ' │\n ╞ %s'%langs.log.status_r, + '61' : ' ╞ %s%s%s > %s'%(CG, langs.log.file_e, CS, value), '255' : ' ╘ %s'%langs.log.laterout } diff --git a/src/var/lib/tyto/program/show.py b/src/var/lib/tyto/program/show.py index 80b17e9..1b044d5 100644 --- a/src/var/lib/tyto/program/show.py +++ b/src/var/lib/tyto/program/show.py @@ -176,7 +176,7 @@ def manage(target): tyto.edit_file(file) except: - logs.out("28", '%s + %s'%(action, target), True) + logs.out("28", '%s + %s'%(args.action, target), True) # If edit article and hash changed, ask to check diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index f8e9705..dc734e1 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -55,7 +55,7 @@ def manage(target): elif target in args.pass_targets: do = { - 'all' : wip_all, + 'updated' : wip_all, 'again' : wip_all, 'newer' : wip_all, 'sidebar' : html.create_sidebar, @@ -102,7 +102,7 @@ def wip_all(process): langs.site.wip_again, langs.site.q ), True) - elif args.target == "all": + elif args.target == "updated": print(' │ %s'%langs.site.wip_older) elif args.target == "newer": @@ -138,7 +138,7 @@ def wip_all(process): continue # All: only old wip - elif option == "all" and not db.old_wip: + elif option == "updated" and not db.old_wip: continue # again: wip again wip articles diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index d922ef6..c53c2e3 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -21,6 +21,7 @@ line = "Ligne" no_up = "not updated" ntd = "Nothing to do" +all_ok = "All is OK" unused_r = "Unused ressource" unused_c = "Unused database value" db_inv = "Corrupted article's database" @@ -41,7 +42,7 @@ file_e = "File exists" dir_c = "Directory created" dir_e = "Directory exists" -was_chk = "Article 'check'" +was_chk = "Article 'check'" was_wip = "Article already 'wip'" check_m = "Check manually" post_inc = "Unused in article" diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 5a89e07..2ddbbd4 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -21,6 +21,7 @@ line = "Line" no_up = "non mise à jour" ntd = "Rien à faire" +all_ok = "Tout va bien" unused_r = "Ressource manquante" unused_c = "Valeur de la base de donnée manquante" db_inv = "Base de donnée de l'article corrompue" @@ -55,7 +56,7 @@ mark_np = "Marqueurs non jumelés" symb_np = "Symboles non jumelés" snpic_d = "snpic utilisé par défaut. Manquant" anch_nu = "Ancre non unique" -nyfile = "Fichier pas encore créé" +nyfile = "Fichier pas encore créé" nycheck = "Article pas encore 'check'" nywip = "Article pas encore 'wip'" add = "Ajout:" diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index 8d3bd58..21b33e0 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -276,7 +276,7 @@ args_helps = """\n# Nouveau domaine : - [target] > Selon l'action [action] # Traitement en masse - all : Mise à jour des articles modifiés (déjà vérifiés) + updated : Mise à jour des articles modifiés (déjà vérifiés) again : Forcer TOUS les articles déjà vérifiés newer : [check] Vérifier tous les article .tyto dans le domaine qui n'ont pas été déjà vérifiés