target: all. fix with wip action

This commit is contained in:
Cyrille L 2023-03-02 15:53:29 +01:00
parent 0edcd4609b
commit f4bcacdac6
6 changed files with 39 additions and 31 deletions

View File

@ -1,4 +1,5 @@
# Tyto
Pour obtenir de l'aide, taper juste la commande tyto
## Répertoire de code du projet Tyto

View File

@ -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
}

View File

@ -57,11 +57,11 @@ pass_db = \
'show-wip',
'show-www',
'wip',
)
pass_targets = \
(
'all',
'domain',
'footer',
'metas',

View File

@ -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

View File

@ -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'

View File

@ -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