From f4bcacdac6448e35318878ffe16b9add1d62b05d Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Thu, 2 Mar 2023 15:53:29 +0100 Subject: [PATCH] target: all. fix with wip action --- README.md | 1 + src/usr/bin/tyto | 3 +- src/var/lib/tyto/program/args.py | 2 +- src/var/lib/tyto/program/db.py | 10 +++--- src/var/lib/tyto/program/infos.py | 1 + src/var/lib/tyto/program/wip.py | 53 ++++++++++++++++--------------- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 355a99c..8691781 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Tyto +Pour obtenir de l'aide, taper juste la commande tyto ## RĂ©pertoire de code du projet Tyto diff --git a/src/usr/bin/tyto b/src/usr/bin/tyto index a2af7cb..ccc8ed9 100755 --- a/src/usr/bin/tyto +++ b/src/usr/bin/tyto @@ -56,7 +56,8 @@ actions = { 'show-db' : show.manage_show, 'show-wip' : show.manage_show, 'show-www' : show.manage_show, - 'wip' : wip.manage_wip + 'wip' : wip.manage_wip, + 'all' : wip.manage_wip } diff --git a/src/var/lib/tyto/program/args.py b/src/var/lib/tyto/program/args.py index ec26e56..409b6c0 100644 --- a/src/var/lib/tyto/program/args.py +++ b/src/var/lib/tyto/program/args.py @@ -57,11 +57,11 @@ pass_db = \ 'show-wip', 'show-www', 'wip', - ) pass_targets = \ ( + 'all', 'domain', 'footer', 'metas', diff --git a/src/var/lib/tyto/program/db.py b/src/var/lib/tyto/program/db.py index ee97d65..15b0ec3 100644 --- a/src/var/lib/tyto/program/db.py +++ b/src/var/lib/tyto/program/db.py @@ -18,7 +18,7 @@ #********************************************************************** import os, sys -import args, logs, tyto, domain +import args, logs, tyto, domain, wip, publish action = args.action target = args.target @@ -164,15 +164,17 @@ else: #------------------# #================================# # Get post DB from target # +# Conditions from command line # # Get some post settings fom uri # #--------------------------------# -# Conditions from command line if args.target \ and args.action in args.pass_db \ and not args.target in args.pass_targets: - + uri_file = '%s/%s'%(in_dir, args.target) - if not os.path.exists(uri_file): logs.out("1", uri_file, True) + + if not os.path.exists(uri_file): + logs.out("1", uri_file, True) # Get hash for uri and content file post_exists = True diff --git a/src/var/lib/tyto/program/infos.py b/src/var/lib/tyto/program/infos.py index c42fe06..4686c26 100644 --- a/src/var/lib/tyto/program/infos.py +++ b/src/var/lib/tyto/program/infos.py @@ -73,6 +73,7 @@ def tyto(target): ' wip : Create page in wip server\n' ' publish : Create page in www server\n\n' '- [target] according to [action]\n' + ' all : Convert again all already converted articles' ' domain : Create/Show config file\n' ' [file] : URI of an article\'s file (autocompletion is your friend)\n' ' footer : Create/Show footer HTML config\'s file\n' diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index e222ed4..5594b74 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -17,7 +17,7 @@ #********************************************************************** -import os, re, shutil +import os, re, shutil, importlib import logs, args, db, tyto, html, domain @@ -25,12 +25,36 @@ import logs, args, db, tyto, html, domain # Manage wip action with option as target # #-----------------------------------------# def manage_wip(target): - global post_db, hash_post + global post_db, hash_post, target_all # Check if can process domain.domain_needed() + + + # Option 'all' to wip again, based on DB + #--------------------------------------- + if target == 'all': + ask = '' + ask = input(":? wip again all already converted articles ? ") + if not ask in ['y', 'Y']: + return + # Load domain configuration DB + for post_db in os.listdir(db.articles_db): + if post_db.endswith('.conf'): + # Load DB + post_db = '%s%s'%(db.articles_db, post_db) + args.target = 'index.tyto' + importlib.reload(db) + print(':> [%s] | %s'%(db.title, db.post_src)) + if not db.hash_wip: continue + hash_post = tyto.get_filesum(db.post_src, True) # From content file + wip_article(db.post_src) + return + + # Target is footer, sidebar, navbar, metas + #----------------------------------------- if target in args.pass_targets: do = { 'sidebar' : html.create_sidebar, @@ -42,29 +66,7 @@ def manage_wip(target): do[target]('wip') return - #----------------------------------------- - # Option 'Again' to wip again, based on DB - #----------------------------------------- - if target == 'all': - ask = '' - ask = input(":? wip again all already converted articles ? ") - if not ask in ['y', 'Y']: - return - - # Load domain configuration DB - for post_db in os.listdir(db.domain_db): - if post_db.endswith('.conf'): - # Load DB - post_db = '%s%s'%(db.domain_db, post_db) - exec(open(post_db).read(),globals()) - if not hash_wip: continue - print("->", post_src) - hash_post = tyto.get_filesum(post_src, True) # From content file - wip_article(post_src) - return - - #------------------------ # Per article with target #------------------------ if not target: logs.out("5", '', True) @@ -87,9 +89,10 @@ def manage_wip(target): if not ask in ['y', 'Y']: return wip_article(db.uri_file) + #===================# # Start wip modules # -# Set Db # +# Set DB # #-------------------# def wip_article(target): # Convert file to strings