wip: added option 'again' to wip all already wip articles (indev)

This commit is contained in:
Cyrille L 2023-01-06 16:27:46 +01:00
parent 173eb7027f
commit d008f6e78f
3 changed files with 42 additions and 12 deletions

View File

@ -50,13 +50,14 @@ actions = {
# Dict for Options
options = {
'-a' : 'Add', 'add' : 'Add',
'-R' : "Remove", 'remove' : "Remove",
'-n' : "New", 'new' : "New",
'-e' : "Edit", 'edit' : "Edit",
'-F' : "Force", 'force' : "Force",
'-s' : "Show",
'-d' : 'DB'
'-a' : 'Add', 'add' : 'Add',
'-R' : "Remove", 'remove' : "Remove",
'-n' : "New", 'new' : "New",
'-e' : "Edit", 'edit' : "Edit",
'-F' : "Force", 'force' : "Force",
'-s' : "Show",
'-d' : 'DB',
'again': 'Again'
}
# Set Argument 2 or 3

View File

@ -28,7 +28,8 @@ arguments = (
'-e', 'edit',
'-n', 'new',
'-F', 'force',
'-d'
'-d',
'again'
)
# Settings

View File

@ -20,6 +20,32 @@ import os, re
import tyto, html
def manage_wip(target, option):
global post_db, hash_post
#-----------------------------------------
# Option 'Again' to wip again, based on DB
#-----------------------------------------
if option == 'Again':
ask = ''
ask = input(":? wip again all already converted articles ? ")
if not ask in ['y', 'Y']:
return
# Load domain configuration DB
exec(open(tyto.domain_conf).read(),globals())
for post_db in os.listdir(domain_db):
if post_db.endswith('.conf'):
# Load DB
post_db = '%s%s'%(domain_db, post_db)
exec(open(post_db).read(),globals())
print("->", root_uri)
hash_post = tyto.get_filesum(post_db, True) # From content file
wip_article(root_uri)
return
#------------------------
# Per article with target
#------------------------
# target needed
if not target: tyto.exiting("5", '', True)
@ -30,10 +56,12 @@ def manage_wip(target, option):
tyto.exiting("4", '', True)
# Load DB
exec(open(tyto.post_db).read(),globals())
post_db = tyto.post_db
hash_post = tyto.hash_post
exec(open(post_db).read(),globals())
# Exit if article has changed
if hash_chk != tyto.hash_post: tyto.exiting("9", '', True)
if hash_chk != hash_post: tyto.exiting("9", '', True)
# In any case, if Force
if option == 'Force':
@ -91,11 +119,11 @@ def wip_article(target):
print(article_bottom)
# Get article DB in html.py
html.set_page(tyto.post_db)
html.set_page(post_db)
print(html.main_page)
# Replace in DB hash_wip and date_wip
tyto.replace_in_db(tyto.post_db, 'wip', tyto.hash_post)
tyto.replace_in_db(post_db, 'wip', hash_post)
#=================================#