'%(8 * ' ') + \ - 'Article '%( - title - ) + \ - '%s '%( - tyto.trans[10][tyto.n], date[0], tyto.trans[7][tyto.n] - ) + \ - ' . %s '%( - author, tyto.trans[8][tyto.n] - ) + \ - '' + \ - '
' + post_pub = \ + '%s'%(8 * ' ') + \ + 'Article '%(title) + \ + '%s '%(tyto.trans[10][tyto.n], + date[0], + tyto.trans[7][tyto.n] + ) + \ + ' . %s '%(author, + tyto.trans[8][tyto.n] + ) + \ + '' + \ + '
' # meta search_date= meta_pub = ' \n'%( @@ -498,7 +498,6 @@ def create_user_metas(option): logs.out("255", '', True) user_file = open(db.metas_load, 'r').read() - for line in user_file.rsplit('\n'): if line.startswith(metas_used): if user_metas: user_metas = "%s\n %s"%(user_metas, line) diff --git a/src/var/lib/tyto/program/logs.py b/src/var/lib/tyto/program/logs.py index 9f730cc..4344680 100644 --- a/src/var/lib/tyto/program/logs.py +++ b/src/var/lib/tyto/program/logs.py @@ -71,5 +71,4 @@ def out(nbr, value, out): msg = logs[nbr] print(msg) - if int(nbr) >= 20: nbr = 0 if out: sys.exit(int(nbr)) diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index 3bd52dc..e762804 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -20,7 +20,6 @@ import os, sys, shutil, importlib import logs, args, db, html, tyto, domain, stats, rss - #==============================# # Manage action, get post db # # check if publish can be done # @@ -46,36 +45,17 @@ def manage_publish(target): do[target]('www') return - - # Publish in www server an article - #--------------------------------- - err_pub = False # Default (error to publish) + # Database must exists... if not db.db_exists: logs.out("25", db.uri_file, True) - # Checking if article can be publish - if not db.hash_chk: - logs.out("25", db.uri_file, False) - err_pub = True - elif not db.hash_wip: - logs.out("30", db.uri_file, False) - err_pub = True - - if db.hash_wip: - # wip and current article have different hash - if db.hash_post != db.hash_chk: - logs.out("9", db.uri_file, False) - err_pub = True - elif db.hash_wip != db.hash_chk: - logs.out("30", db.uri_file, False) - err_pub = True - - if not os.path.exists(db.post_wip): - logs.out("1", db.post_wip, True) - - if err_pub: sys.exit(1) + # Publish in www server an article + check_to_publish('one') publish_article() + + # Create new ATOM/RSS file + rss.create_feed() #===============# @@ -96,9 +76,6 @@ def publish_article(): # Replace publish HTML line replace_line_pub() - # Create new ATOM/RSS file - rss.create_feed() - #=================================================# # Replace line in article containing publish date # @@ -207,20 +184,45 @@ def create_all(option): print(':> [%s] | %s'%(db.title, db.post_src)) hash_post = tyto.get_filesum(db.post_src, True) # From content file - if not db.hash_chk: - logs.out("25", db.uri_file, False) - continue + check_to_publish('all') + if err_pub: continue - if db.hash_chk != db.hash_post: - logs.out("9", db.uri_file, False) - continue - - if db.hash_wip != db.hash_chk: - logs.out("30", db.uri_file, False) - continue - published = True publish_article() if not published: logs.out("28", '(publish)', True) + else: + # Create new ATOM/RSS file + rss.create_feed() + + +#==============================# +# Check if it can be published # +#------------------------------# +def check_to_publish(process): + global err_pub + err_pub = False + + # Article must exists in wip server + if not os.path.exists(db.post_wip): + logs.out("1", db.post_wip, True) + + # Checking if article can be publish + if not db.hash_chk: + logs.out("25", db.uri_file, False) + err_pub = 25 + elif not db.hash_wip: + logs.out("30", db.uri_file, False) + err_pub = 30 + elif db.hash_post != db.hash_chk: + logs.out("9", db.uri_file, False) + err_pub = 9 + elif db.hash_wip != db.hash_chk: + logs.out("30", db.uri_file, False) + err_pub = 30 + + if err_pub: + if process == 'all': return + elif process == 'one': sys.exit(err_pub) + diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index c6e2cda..ba83c13 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -214,24 +214,6 @@ def set_file(path, new, text): logs.out("4", path, True) -#========================================================# -# Create DB file with hash from [type]_load file content # -#--------------------------------------------------------# -def create_db_load(file_load, file_db): - hash_load = get_filesum(file_load, True) - if not os.path.exists(file_db): - line = 'file_load_hash = "%s"'%hash_load - set_file(file_db, True, line) - return - - global file_load_hash - file_load_hash = '' - exec(open(file_db, 'r').read(), globals()) - if not file_load_hash == hash_load: - line = 'file_load_hash = "%s"'%hash_load - set_file(file_db, True, line) - - #==========================# # Get CSS from line if set # #--------------------------#