check: Protected quotes and bcodes (+stats) in main fonction protect_bcodes_quotes()
This commit is contained in:
parent
6877d67533
commit
739236bc47
|
@ -345,88 +345,72 @@ def protect_icodes(post_bottom, article_bottom):
|
||||||
def protect_bcodes_quotes(process, post_bottom, article_bottom):
|
def protect_bcodes_quotes(process, post_bottom, article_bottom):
|
||||||
|
|
||||||
global protect_article
|
global protect_article
|
||||||
|
global nbr_titles, nbr_bcodes, nbr_quotes # Stats for DB
|
||||||
in_bcode = in_quote = False
|
in_bcode = in_quote = False
|
||||||
protect_article = ''
|
protect_article = ''
|
||||||
temp_article = article_bottom
|
temp_article = article_bottom
|
||||||
|
nbr_titles = nbr_bcodes = nbr_quotes = 0
|
||||||
|
bcode = quote = ''
|
||||||
|
end_bcode = end_quote = False
|
||||||
|
|
||||||
if process == 'check':
|
for line in post_bottom:
|
||||||
global nbr_titles, nbr_bcodes, nbr_quotes # Stats for DB
|
# Bcode
|
||||||
nbr_titles = nbr_bcodes = nbr_quotes = 0
|
if not in_quote:
|
||||||
|
|
||||||
for line in post_bottom:
|
|
||||||
if line.startswith(words_tags[12][0]):
|
if line.startswith(words_tags[12][0]):
|
||||||
in_bcode = True
|
in_bcode = True
|
||||||
nbr_bcodes += 1
|
if process == 'check':
|
||||||
continue
|
if not protect_article: protect_article = line
|
||||||
|
else: protect_article = '%s\n%s'%(protect_article, line)
|
||||||
|
nbr_bcodes += 1
|
||||||
elif line.startswith(words_tags[12][1]):
|
elif line.startswith(words_tags[12][1]):
|
||||||
in_bcode = False
|
if process == "wip":
|
||||||
continue
|
|
||||||
elif line.startswith('#'): # As convention
|
|
||||||
if line.startswith(titles_tags): nbr_titles += 1
|
|
||||||
else: continue
|
|
||||||
|
|
||||||
if in_bcode: continue
|
|
||||||
elif line.startswith(words_tags[11][0]):
|
|
||||||
in_quote = True
|
|
||||||
nbr_quotes += 1
|
|
||||||
continue
|
|
||||||
elif line.startswith(words_tags[11][1]):
|
|
||||||
in_quote = False
|
|
||||||
continue
|
|
||||||
|
|
||||||
if in_quote:
|
|
||||||
if not line in (words_tags[10][0], words_tags[10][1]):
|
|
||||||
continue
|
|
||||||
|
|
||||||
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':
|
|
||||||
bcode = quote = ''
|
|
||||||
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)
|
bcode = '%s\n%s'%(bcode, line)
|
||||||
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
b64_bcode = b64('Encode', bcode, 'B64.', '.B64')
|
||||||
line = b64_bcode
|
line = b64_bcode
|
||||||
end_bcode = True
|
end_bcode = True
|
||||||
in_bcode = False
|
in_bcode = False
|
||||||
|
|
||||||
# Quote
|
# Quote
|
||||||
if not in_bcode:
|
if not in_bcode:
|
||||||
if line.startswith(words_tags[11][0]):
|
if line.startswith(words_tags[11][0]):
|
||||||
in_quote = True
|
in_quote = True
|
||||||
elif line.startswith(words_tags[11][1]):
|
if process == 'check':
|
||||||
|
if not protect_article: protect_article = line
|
||||||
|
else: protect_article = '%s\n%s'%(protect_article, line)
|
||||||
|
nbr_quotes += 1
|
||||||
|
elif line.startswith(words_tags[11][1]):
|
||||||
|
if process == "wip":
|
||||||
quote = '%s\n%s'%(quote, line)
|
quote = '%s\n%s'%(quote, line)
|
||||||
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
|
b64_quote = b64('Encode', quote, 'Q64.', '.Q64')
|
||||||
line = b64_quote
|
line = b64_quote
|
||||||
end_quote = True
|
end_quote = True
|
||||||
in_quote = False
|
in_quote = False
|
||||||
|
|
||||||
if in_bcode:
|
# Count titles for check
|
||||||
if not bcode: bcode = line
|
# Pass if line is a comment
|
||||||
else: bcode = '%s\n%s'%(bcode, line)
|
if not in_bcode or not in_quote:
|
||||||
|
if line.startswith(titles_tags):
|
||||||
|
if process == 'check':
|
||||||
|
nbr_titles += 1
|
||||||
|
elif line.startswith('#'):
|
||||||
|
continue
|
||||||
|
|
||||||
elif in_quote:
|
if in_bcode:
|
||||||
if not quote: quote = line
|
if not bcode: bcode = line
|
||||||
else: quote = '%s\n%s'%(quote, line)
|
else: bcode = '%s\n%s'%(bcode, line)
|
||||||
|
|
||||||
if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False
|
elif in_quote:
|
||||||
elif end_quote: quote = ''; end_quote = False ; in_quote = False
|
if not quote: quote = line
|
||||||
|
else: quote = '%s\n%s'%(quote, line)
|
||||||
|
|
||||||
if in_quote or in_bcode:
|
if end_bcode: bcode = ''; end_bcode = False ; in_bcode = False
|
||||||
continue
|
elif end_quote: quote = ''; end_quote = False ; in_quote = False
|
||||||
else:
|
|
||||||
if not protect_article: protect_article = line
|
if in_quote or in_bcode:
|
||||||
else: protect_article = '%s\n%s'%(protect_article, line)
|
continue
|
||||||
|
else:
|
||||||
|
if not protect_article: protect_article = line
|
||||||
|
else: protect_article = '%s\n%s'%(protect_article, line)
|
||||||
|
|
||||||
|
|
||||||
#=====================================#
|
#=====================================#
|
||||||
|
|
Loading…
Reference in New Issue