wip: fix. Protected quotes and bcodes
This commit is contained in:
parent
cee1c67739
commit
6877d67533
|
@ -381,53 +381,53 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom):
|
||||||
if not protect_article: protect_article = line
|
if not protect_article: protect_article = line
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
else: protect_article = '%s\n%s'%(protect_article, line)
|
||||||
|
|
||||||
|
|
||||||
# For wip, bcodes are converted to base64
|
# For wip, bcodes are converted to base64
|
||||||
#----------------------------------------
|
#----------------------------------------
|
||||||
elif process == 'wip':
|
elif process == 'wip':
|
||||||
|
|
||||||
# Convert bcodes and quotes
|
|
||||||
# include markers in base64, remove from article
|
|
||||||
bcode = quote = ''
|
bcode = quote = ''
|
||||||
for ln, line in enumerate(post_bottom):
|
end_bcode = end_quote = False
|
||||||
# bcode
|
|
||||||
if line.startswith(words_tags[12][0]):
|
for line in post_bottom:
|
||||||
in_bcode = True
|
# Bcode
|
||||||
elif line.startswith(words_tags[12][1]):
|
if not in_quote:
|
||||||
bcode = '%s\n%s'%(bcode, line)
|
if line.startswith(words_tags[12][0]):
|
||||||
in_bcode = False
|
in_bcode = True
|
||||||
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
elif line.startswith(words_tags[12][1]):
|
||||||
protect_article = '%s\n%s'%(protect_article, b64_bcode)
|
bcode = '%s\n%s'%(bcode, line)
|
||||||
bcode = ''
|
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
||||||
continue
|
line = b64_bcode
|
||||||
elif line.startswith('#'): # As convention
|
end_bcode = True
|
||||||
if not line.startswith(titles_tags):
|
in_bcode = False
|
||||||
continue
|
|
||||||
|
|
||||||
# quote
|
# Quote
|
||||||
elif line.startswith(words_tags[11][0]):
|
if not in_bcode:
|
||||||
if not in_bcode:
|
if line.startswith(words_tags[11][0]):
|
||||||
in_quote = True
|
in_quote = True
|
||||||
elif line.startswith(words_tags[11][1]):
|
elif line.startswith(words_tags[11][1]):
|
||||||
if not in_bcode:
|
|
||||||
quote = '%s\n%s'%(quote, line)
|
quote = '%s\n%s'%(quote, line)
|
||||||
|
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
|
||||||
|
line = b64_quote
|
||||||
|
end_quote = True
|
||||||
in_quote = False
|
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 in_bcode:
|
||||||
if bcode: bcode = '%s\n%s'%(bcode, line)
|
if not bcode: bcode = line
|
||||||
else: bcode = line
|
else: bcode = '%s\n%s'%(bcode, line)
|
||||||
else:
|
|
||||||
if in_quote:
|
elif in_quote:
|
||||||
if quote: quote = '%s\n%s'%(quote, line)
|
if not quote: quote = line
|
||||||
else: quote = line
|
else: quote = '%s\n%s'%(quote, line)
|
||||||
else:
|
|
||||||
if not protect_article: protect_article = line
|
if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
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 #
|
# Encode/Decode string to/from base64 #
|
||||||
|
@ -455,11 +455,11 @@ def b64(action, content, before, after):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
#
|
#====================================#
|
||||||
# Replace in post_db
|
# Replace in post_db #
|
||||||
# Used for wip and publish
|
# Used for wip and publish #
|
||||||
# to replace hash and date when done
|
# to replace hash and date when done #
|
||||||
#
|
#------------------------------------#
|
||||||
def replace_in_db(post_db, process, hash_post):
|
def replace_in_db(post_db, process, hash_post):
|
||||||
file_db = open(post_db, "r")
|
file_db = open(post_db, "r")
|
||||||
lines = file_db.readlines()
|
lines = file_db.readlines()
|
||||||
|
@ -481,7 +481,6 @@ def replace_in_db(post_db, process, hash_post):
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#================================#
|
#================================#
|
||||||
# Exit from program with message #
|
# Exit from program with message #
|
||||||
#--------------------------------#
|
#--------------------------------#
|
||||||
|
@ -500,7 +499,8 @@ def exiting(nbr, value, out):
|
||||||
'20' : ':D Article already up-to-date on: %s'%value,
|
'20' : ':D Article already up-to-date on: %s'%value,
|
||||||
'21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip',
|
'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,
|
'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...'
|
'255' : ':| Maybe later...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import os, re
|
import os, re
|
||||||
import tyto
|
import tyto
|
||||||
|
|
||||||
def manage_wip(target, option):
|
def manage_wip(target, option):
|
||||||
# target needed
|
# target needed
|
||||||
if not target: tyto.exiting("5", '', True)
|
if not target: tyto.exiting("5", '', True)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def manage_wip(target, option):
|
||||||
if do_wip:
|
if do_wip:
|
||||||
# Show message if wip was done
|
# Show message if wip was done
|
||||||
if hash_wip:
|
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)
|
if is_new: tyto.exiting("9", '', False)
|
||||||
wip_article(target)
|
wip_article(target)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue