diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index 9c7340a..4efa14a 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -381,53 +381,53 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom): if not protect_article: protect_article = line else: protect_article = '%s\n%s'%(protect_article, line) + # For wip, bcodes are converted to base64 #---------------------------------------- elif process == 'wip': - - # Convert bcodes and quotes - # include markers in base64, remove from article bcode = quote = '' - for ln, line in enumerate(post_bottom): - # bcode - if line.startswith(words_tags[12][0]): - in_bcode = True - elif line.startswith(words_tags[12][1]): - bcode = '%s\n%s'%(bcode, line) - in_bcode = False - b64_bcode = b64('Encode', bcode, 'B64.', '.B64') - protect_article = '%s\n%s'%(protect_article, b64_bcode) - bcode = '' - continue - elif line.startswith('#'): # As convention - if not line.startswith(titles_tags): - continue + end_bcode = end_quote = False + + for line in post_bottom: + # Bcode + if not in_quote: + if line.startswith(words_tags[12][0]): + in_bcode = True + elif line.startswith(words_tags[12][1]): + bcode = '%s\n%s'%(bcode, line) + b64_bcode = b64('Encode', bcode, 'B64.', '.B64') + line = b64_bcode + end_bcode = True + in_bcode = False - # quote - elif line.startswith(words_tags[11][0]): - if not in_bcode: + # Quote + if not in_bcode: + if line.startswith(words_tags[11][0]): in_quote = True - elif line.startswith(words_tags[11][1]): - if not in_bcode: + elif line.startswith(words_tags[11][1]): quote = '%s\n%s'%(quote, line) + b64_quote = b64('Encode', quote, 'Q64.', '.Q64') + line = b64_quote + end_quote = True in_quote = False - b64_quote = b64('Encode', quote, 'Q64.', '.Q64') - protect_article = '%s\n%s'%(protect_article, b64_quote) - quote = '' - continue - - # Priority to bcode + if in_bcode: - if bcode: bcode = '%s\n%s'%(bcode, line) - else: bcode = line - else: - if in_quote: - if quote: quote = '%s\n%s'%(quote, line) - else: quote = line - else: - if not protect_article: protect_article = line - else: protect_article = '%s\n%s'%(protect_article, line) + if not bcode: bcode = line + else: bcode = '%s\n%s'%(bcode, line) + + elif in_quote: + if not quote: quote = line + else: quote = '%s\n%s'%(quote, line) + + if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False + elif end_quote: quote = ''; end_quote = False ; in_quote = False + if in_quote or in_bcode: + continue + else: + if not protect_article: protect_article = line + else: protect_article = '%s\n%s'%(protect_article, line) + #=====================================# # Encode/Decode string to/from base64 # @@ -455,11 +455,11 @@ def b64(action, content, before, after): sys.exit(1) -# -# Replace in post_db -# Used for wip and publish -# to replace hash and date when done -# +#====================================# +# Replace in post_db # +# Used for wip and publish # +# to replace hash and date when done # +#------------------------------------# def replace_in_db(post_db, process, hash_post): file_db = open(post_db, "r") lines = file_db.readlines() @@ -481,7 +481,6 @@ def replace_in_db(post_db, process, hash_post): file.close() - #================================# # Exit from program with message # #--------------------------------# @@ -500,7 +499,8 @@ def exiting(nbr, value, out): '20' : ':D Article already up-to-date on: %s'%value, '21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip', '22' : ':? Symbols: %s \033[1;33mnot paired\033[0;0m'%value, - '23' : ':< \033[1;33mDatabase was corrupt\033[0;0m: %s'%value, + '23' : ':? \033[1;33mDatabase was corrupt\033[0;0m: %s'%value, + '24' : ':? \033[1;33mMissing wip file\033[0;0m: %s'%value, '255' : ':| Maybe later...' } diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 2821494..dfd7511 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -19,7 +19,7 @@ import os, re import tyto -def manage_wip(target, option): +def manage_wip(target, option): # target needed if not target: tyto.exiting("5", '', True) @@ -51,7 +51,7 @@ def manage_wip(target, option): if do_wip: # Show message if wip was done if hash_wip: - if not is_file: tyto.exiting("1", wip_uri, False) + if not is_file: tyto.exiting("24", wip_uri, False) if is_new: tyto.exiting("9", '', False) wip_article(target) else: