check. new translated logs for some tags (image, file, raw)

This commit is contained in:
Cyrille L 2023-03-26 17:30:56 +02:00
parent bb187ce438
commit 7982d6030b
6 changed files with 65 additions and 29 deletions

View File

@ -58,8 +58,8 @@ post_err = False
# Start checking article # # Start checking article #
#-------------------------#-------------------------------------------- #-------------------------#--------------------------------------------
def manage(target): def manage(target):
if not dom.exists: logs.out("10", '', True)
dom.valid() dom.valid()
# target needed # target needed
if not target: if not target:
logs.out("5", args.action, True) logs.out("5", args.action, True)
@ -246,7 +246,7 @@ def file_to_string():
# Check if separator or exit # Check if separator or exit
if not sep: if not sep:
logs.out("6", db.uri_file, True) logs.out("6", '----- > %s'%db.uri_file, True)
if not content: if not content:
if db.exists and tyto.exists(db.config): if db.exists and tyto.exists(db.config):
@ -495,19 +495,28 @@ def check_headers(post_header):
stat_images += 1 stat_images += 1
var_tag = 'image_%s'%stat_images var_tag = 'image_%s'%stat_images
# NAME
image_name = post_header[ln - 1] image_name = post_header[ln - 1]
image_name = image_name.rsplit(tag)[1].lstrip().rsplit(' ')[0] image_name = image_name.rsplit(tag)[1].lstrip().rsplit(' ')[0]
if not image_name: if not image_name:
logs.out("2", "Line %s (Name, %s)"%(ln, tag), False) logs.out("2", 'L=%s. "%s %s" > %s'%(
ln, tag, tr.name, db.uri_file
), False)
post_err = True post_err = True
if not isin(r'\b_%s%s\b'%(tag, image_name), post_bottom): if not post_err and \
logs.out("6", '_%s%s'%(tag, image_name), False) not isin(r'\b_%s%s\b'%(tag, image_name), post_bottom):
logs.out("12", '"_%s%s" > %s'%(
tag, image_name, db.uri_file
), False)
post_err = True post_err = True
# URI
image_uri = post_header[ln].lstrip() image_uri = post_header[ln].lstrip()
if image_uri.startswith(tyto.headers): image_uri = '' if image_uri.startswith(tyto.headers): image_uri = ''
if not image_uri: if not image_uri:
logs.out("2", "Line %s (URI, %s)"%(ln + 1, tag), False) logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file
), False)
post_err = True post_err = True
else: else:
check_file_uri('image', image_uri, ln + 1) check_file_uri('image', image_uri, ln + 1)
@ -515,10 +524,13 @@ def check_headers(post_header):
f_uri = web_uri[1:len(web_uri)] f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT
image_alt = post_header[ln + 1].lstrip() image_alt = post_header[ln + 1].lstrip()
if image_alt.startswith(tyto.headers): image_alt = '' if image_alt.startswith(tyto.headers): image_alt = ''
if not image_alt: if not image_alt:
logs.out("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False) logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file
), False)
post_err = True post_err = True
if not post_err: if not post_err:
@ -535,19 +547,28 @@ def check_headers(post_header):
stat_raws += 1 stat_raws += 1
var_tag = 'raw_%s'%stat_raws var_tag = 'raw_%s'%stat_raws
# NAME
raw_name = post_header[ln - 1] raw_name = post_header[ln - 1]
raw_name = raw_name.rsplit(tag)[1].lstrip().rsplit(' ')[0] raw_name = raw_name.rsplit(tag)[1].lstrip().rsplit(' ')[0]
if not raw_name: if not raw_name:
logs.out("2", "Line %s (Name, %s)"%(ln, tag), False) logs.out("2", 'L=%s. "%s %s" > %s'%(
ln, tag, tr.name, db.uri_file
), False)
post_err = True post_err = True
if not isin(r'\b_%s%s\b'%(tag, raw_name), post_bottom): if not post_err and \
logs.out("6", "_%s%s"%(tag, raw_name), False) not isin(r'\b_%s%s\b'%(tag, raw_name), post_bottom):
logs.out("12", '"_%s%s" > %s'%(
tag, raw_name, db.uri_file
), False)
post_err = True post_err = True
# URI
raw_uri = post_header[ln].lstrip() raw_uri = post_header[ln].lstrip()
if raw_uri.startswith(tyto.headers): raw_uri = '' if raw_uri.startswith(tyto.headers): raw_uri = ''
if not raw_uri: if not raw_uri:
logs.out("2", "Line %s (URI, %s)"%(ln + 1, tag), False) logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file
), False)
post_err = True post_err = True
else: else:
check_file_uri('file', raw_uri, ln + 1) check_file_uri('file', raw_uri, ln + 1)
@ -555,10 +576,13 @@ def check_headers(post_header):
f_uri = web_uri[1:len(web_uri)] f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT
raw_alt = post_header[ln + 1].lstrip() raw_alt = post_header[ln + 1].lstrip()
if raw_alt.startswith(tyto.headers): raw_alt = '' if raw_alt.startswith(tyto.headers): raw_alt = ''
if not raw_alt: if not raw_alt:
logs.out("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False) logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file
), False)
post_err = True post_err = True
if not post_err: if not post_err:
@ -575,18 +599,23 @@ def check_headers(post_header):
stat_files += 1 stat_files += 1
var_tag = 'file_%s'%stat_files var_tag = 'file_%s'%stat_files
# NAME
file_name = post_header[ln - 1].rsplit(tag)[1].lstrip() file_name = post_header[ln - 1].rsplit(tag)[1].lstrip()
if not file_name: if not file_name:
logs.out("2", "Line %s (Name, %s)"%(ln, tag), False) logs.out("2", "Line %s (Name, %s)"%(ln, tag), False)
post_err = True post_err = True
if not isin(r'\b__%s\b'%file_name, post_bottom): if not post_err and \
not isin(r'\b__%s\b'%file_name, post_bottom):
logs.out("6", "__%s"%file_name, False) logs.out("6", "__%s"%file_name, False)
post_err = True post_err = True
# URI
file_uri = post_header[ln].lstrip() file_uri = post_header[ln].lstrip()
if file_uri.startswith(tyto.headers): file_uri = '' if file_uri.startswith(tyto.headers): file_uri = ''
if not file_uri: if not file_uri:
logs.out("2", "Line %s (URI, %s)"%(ln + 1, tag), False) logs.out("2", 'L=%s. "%s URI" > %s)'%(
ln + 1, tag, db.uri_file
), False)
post_err = True post_err = True
else: else:
check_file_uri('file', file_uri, ln + 1) check_file_uri('file', file_uri, ln + 1)
@ -594,10 +623,13 @@ def check_headers(post_header):
f_uri = web_uri[1:len(web_uri)] f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri) files_post = (files_post + "'%s', "%f_uri)
# ALT
file_alt = post_header[ln + 1].lstrip() file_alt = post_header[ln + 1].lstrip()
if file_alt.startswith(tyto.headers): file_alt = '' if file_alt.startswith(tyto.headers): file_alt = ''
if not file_alt: if not file_alt:
logs.out("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False) logs.out("2", 'L=%s. "%s Alt-Text" > %s'%(
ln + 2, tag, db.uri_file
), False)
post_err = True post_err = True
if not post_err: if not post_err:
@ -669,9 +701,9 @@ def check_file_uri(filetype, filename, ln):
# (@ = images/, / = articles/, else = post_dir) # (@ = images/, / = articles/, else = post_dir)
if filename.startswith('@'): if filename.startswith('@'):
if filetype == 'image': if filetype == 'image':
fileuri = db.domain_images + filename[1: len(filename)] fileuri = dom.images_d + filename[1: len(filename)]
elif filetype == 'file': elif filetype == 'file':
fileuri = db.domain_files + filename[1: len(filename)] fileuri = dom.files_d + filename[1: len(filename)]
else: else:
post_dir = db.uri_file.split("/")[-1] post_dir = db.uri_file.split("/")[-1]
@ -683,11 +715,11 @@ def check_file_uri(filetype, filename, ln):
# Check if file exists # Check if file exists
if not tyto.exists(fileuri): if not tyto.exists(fileuri):
logs.out("1", "Line %s, %s"%(ln, fileuri), False) logs.out("1", "L=%s. %s > %s"%(ln, fileuri, db.uri_file), False)
post_err = True post_err = True
return return
web_uri = '/' + fileuri.replace(db.domain_articles, "") web_uri = '/' + fileuri.replace(dom.articles_d, "")
#===========================# #===========================#
@ -904,7 +936,7 @@ def create_database():
# Find in post_bottom # # Find in post_bottom #
#---------------------# #---------------------#
def isin(term, post_bottom): def isin(term, post_bottom):
for x in post_bottom: for x in post_bottom.rsplit('\n'):
if re.search(r'%s'%term, x): if re.search(r'%s'%term, x):
return True return(True)
return False return(False)

View File

@ -32,17 +32,17 @@ CG = '\033[1;32m'
def out(nbr, value, out): def out(nbr, value, out):
logs = { logs = {
'1' : '%s%s%s > %s'%(CR, lang.unused_r, CS, value), '1' : '%s%s%s > %s'%(CR, lang.unused_r, CS, value),
'2' : ' %s%s%s > %s'%(CR, lang.data_inc, CS, value), '2' : ' %s%s%s > %s'%(CR, lang.data_inc, CS, value),
'3' : '%s%s%s %s'%(CR, lang.data_inv, CS, value), '3' : '%s%s%s %s'%(CR, lang.data_inv, CS, value),
'4' : '%sUnable to create file%s: %s'%(CR, CS, value), '4' : '%sUnable to create file%s: %s'%(CR, CS, value),
'5' : '%s%s%s > "%s"'%(CR, lang.no_arg, CS, value), '5' : '%s%s%s > "%s"'%(CR, lang.no_arg, CS, value),
'6' : '%s%s%s "-----" > %s'%(CR, lang.sep_inv, CS, value), '6' : '%s%s%s > "%s"'%(CR, lang.sep_inv, CS, value),
'7' : '%s%s%s > %s'%(CR, lang.post_inv, CS, value), '7' : '%s%s%s > %s'%(CR, lang.post_inv, CS, value),
'8' : '%s%s%s %s'%(CR, lang.mark_np, CS, value), '8' : '%s%s%s %s'%(CR, lang.mark_np, CS, value),
'9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS), '9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS),
'10' : '%s%s%s'%(CR, lang.dom_no, CS), '10' : '%s%s%s'%(CR, lang.dom_no, CS),
'11' : '%s%s%s > %s'%(CR, lang.err_arg, CS, value), '11' : '%s%s%s > %s'%(CR, lang.err_arg, CS, value),
'12' : '%sUnused "%s"%s in article\'s header'%(CR, value, CS), '12' : '%s%s%s > %s'%(CR, lang.post_inc, CS, value),
'13' : '%s%s%s'%(CR, lang.no_fidi, CS), '13' : '%s%s%s'%(CR, lang.no_fidi, CS),
'14' : '%sMismatch%s program start'%(CR, CS), '14' : '%sMismatch%s program start'%(CR, CS),
'15' : ' ╞ Anchor %snot uniq%s: %s'%(CR, CS, value), '15' : ' ╞ Anchor %snot uniq%s: %s'%(CR, CS, value),

View File

@ -33,6 +33,7 @@ dir_c = "Directory created"
dir_e = "Directory exists" dir_e = "Directory exists"
check_on = "Article was check the" check_on = "Article was check the"
post_inc = "Unused in article"
post_inv = "Article not valid" post_inv = "Article not valid"
post_val = "Article is valid" post_val = "Article is valid"
sep_inv = "Unused separator in article" sep_inv = "Unused separator in article"

View File

@ -33,12 +33,13 @@ dir_c = "Dossier créé"
dir_e = "Dossier présent" dir_e = "Dossier présent"
check_on = "Article vérifié le" check_on = "Article vérifié le"
post_inc = "Donnée manquante dans l'article"
post_inv = "Article non valide" post_inv = "Article non valide"
post_val = "Article valide" post_val = "Article valide"
sep_inv = "Séparateur manquant dans l'article" sep_inv = "Séparateur manquant dans l'article"
unused_v = "Valeur manquante dans l'article" unused_v = "Valeur manquante dans l'article"
unused_p = "L'article est vide" unused_p = "L'article est vide"
mark_np = "Marqueurs non pairs" mark_np = "Marqueurs non jumelés"
symb_np = "Symboles non pairs" symb_np = "Symboles non jumelés"
laterout = "Pour plus tard..." laterout = "Pour plus tard..."

View File

@ -27,6 +27,7 @@ metas = 'HTML Metas Tags'
footer = 'Footer' footer = 'Footer'
title = 'Title' title = 'Title'
File = 'File' File = 'File'
name = 'Name'
q = '?' q = '?'
i = '!' i = '!'
pp = ":" pp = ":"

View File

@ -27,6 +27,7 @@ metas = 'Balises Metas HTML'
footer = "Pied de Page" footer = "Pied de Page"
title = 'Titre' title = 'Titre'
File = 'Fichier' File = 'Fichier'
name = 'Nom'
q = ' ?' q = ' ?'
i = ' !' i = ' !'
pp = " :" pp = " :"