From 7982d6030b4509a211f576b156ce40ba4e00e518 Mon Sep 17 00:00:00 2001 From: Cyrille L Date: Sun, 26 Mar 2023 17:30:56 +0200 Subject: [PATCH] check. new translated logs for some tags (image, file, raw) --- src/var/lib/tyto/program/check.py | 80 +++++++++++++++++------- src/var/lib/tyto/program/logs.py | 6 +- src/var/lib/tyto/translations/logs_en.py | 1 + src/var/lib/tyto/translations/logs_fr.py | 5 +- src/var/lib/tyto/translations/site_en.py | 1 + src/var/lib/tyto/translations/site_fr.py | 1 + 6 files changed, 65 insertions(+), 29 deletions(-) diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 1f3b123..dc13493 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -58,8 +58,8 @@ post_err = False # Start checking article # #-------------------------#-------------------------------------------- def manage(target): - if not dom.exists: logs.out("10", '', True) dom.valid() + # target needed if not target: logs.out("5", args.action, True) @@ -246,7 +246,7 @@ def file_to_string(): # Check if separator or exit if not sep: - logs.out("6", db.uri_file, True) + logs.out("6", '----- > %s'%db.uri_file, True) if not content: if db.exists and tyto.exists(db.config): @@ -495,30 +495,42 @@ def check_headers(post_header): stat_images += 1 var_tag = 'image_%s'%stat_images + # NAME image_name = post_header[ln - 1] image_name = image_name.rsplit(tag)[1].lstrip().rsplit(' ')[0] 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 - if not isin(r'\b_%s%s\b'%(tag, image_name), post_bottom): - logs.out("6", '_%s%s'%(tag, image_name), False) + if not post_err and \ + 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 + # URI image_uri = post_header[ln].lstrip() if image_uri.startswith(tyto.headers): 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 else: check_file_uri('image', image_uri, ln + 1) if not post_err: f_uri = web_uri[1:len(web_uri)] files_post = (files_post + "'%s', "%f_uri) - + + # ALT image_alt = post_header[ln + 1].lstrip() if image_alt.startswith(tyto.headers): 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 if not post_err: @@ -535,19 +547,28 @@ def check_headers(post_header): stat_raws += 1 var_tag = 'raw_%s'%stat_raws + # NAME raw_name = post_header[ln - 1] raw_name = raw_name.rsplit(tag)[1].lstrip().rsplit(' ')[0] 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 - if not isin(r'\b_%s%s\b'%(tag, raw_name), post_bottom): - logs.out("6", "_%s%s"%(tag, raw_name), False) + if not post_err and \ + 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 + # URI raw_uri = post_header[ln].lstrip() if raw_uri.startswith(tyto.headers): 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 else: 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)] files_post = (files_post + "'%s', "%f_uri) + # ALT raw_alt = post_header[ln + 1].lstrip() if raw_alt.startswith(tyto.headers): 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 if not post_err: @@ -575,18 +599,23 @@ def check_headers(post_header): stat_files += 1 var_tag = 'file_%s'%stat_files + # NAME file_name = post_header[ln - 1].rsplit(tag)[1].lstrip() if not file_name: logs.out("2", "Line %s (Name, %s)"%(ln, tag), False) 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) post_err = True - + + # URI file_uri = post_header[ln].lstrip() if file_uri.startswith(tyto.headers): 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 else: 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)] files_post = (files_post + "'%s', "%f_uri) + # ALT file_alt = post_header[ln + 1].lstrip() if file_alt.startswith(tyto.headers): 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 if not post_err: @@ -669,9 +701,9 @@ def check_file_uri(filetype, filename, ln): # (@ = images/, / = articles/, else = post_dir) if filename.startswith('@'): if filetype == 'image': - fileuri = db.domain_images + filename[1: len(filename)] + fileuri = dom.images_d + filename[1: len(filename)] elif filetype == 'file': - fileuri = db.domain_files + filename[1: len(filename)] + fileuri = dom.files_d + filename[1: len(filename)] else: post_dir = db.uri_file.split("/")[-1] @@ -683,11 +715,11 @@ def check_file_uri(filetype, filename, ln): # Check if file exists 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 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 # #---------------------# def isin(term, post_bottom): - for x in post_bottom: + for x in post_bottom.rsplit('\n'): if re.search(r'%s'%term, x): - return True - return False + return(True) + return(False) diff --git a/src/var/lib/tyto/program/logs.py b/src/var/lib/tyto/program/logs.py index 8c0f91d..6320d84 100644 --- a/src/var/lib/tyto/program/logs.py +++ b/src/var/lib/tyto/program/logs.py @@ -32,17 +32,17 @@ CG = '\033[1;32m' def out(nbr, value, out): logs = { '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), '4' : ' ╘ %sUnable to create file%s: %s'%(CR, 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), '8' : ' ╞ %s%s%s %s'%(CR, lang.mark_np, CS, value), '9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS), '10' : ' ╘ %s%s%s'%(CR, lang.dom_no, CS), '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), '14' : ' ╞ %sMismatch%s program start'%(CR, CS), '15' : ' ╞ Anchor %snot uniq%s: %s'%(CR, CS, value), diff --git a/src/var/lib/tyto/translations/logs_en.py b/src/var/lib/tyto/translations/logs_en.py index 1fd4389..41340f2 100644 --- a/src/var/lib/tyto/translations/logs_en.py +++ b/src/var/lib/tyto/translations/logs_en.py @@ -33,6 +33,7 @@ dir_c = "Directory created" dir_e = "Directory exists" check_on = "Article was check the" +post_inc = "Unused in article" post_inv = "Article not valid" post_val = "Article is valid" sep_inv = "Unused separator in article" diff --git a/src/var/lib/tyto/translations/logs_fr.py b/src/var/lib/tyto/translations/logs_fr.py index 287456d..f0b184d 100644 --- a/src/var/lib/tyto/translations/logs_fr.py +++ b/src/var/lib/tyto/translations/logs_fr.py @@ -33,12 +33,13 @@ dir_c = "Dossier créé" dir_e = "Dossier présent" check_on = "Article vérifié le" +post_inc = "Donnée manquante dans l'article" post_inv = "Article non valide" post_val = "Article valide" sep_inv = "Séparateur manquant dans l'article" unused_v = "Valeur manquante dans l'article" unused_p = "L'article est vide" -mark_np = "Marqueurs non pairs" -symb_np = "Symboles non pairs" +mark_np = "Marqueurs non jumelés" +symb_np = "Symboles non jumelés" laterout = "Pour plus tard..." diff --git a/src/var/lib/tyto/translations/site_en.py b/src/var/lib/tyto/translations/site_en.py index f4e64e8..23b83b8 100644 --- a/src/var/lib/tyto/translations/site_en.py +++ b/src/var/lib/tyto/translations/site_en.py @@ -27,6 +27,7 @@ metas = 'HTML Metas Tags' footer = 'Footer' title = 'Title' File = 'File' +name = 'Name' q = '?' i = '!' pp = ":" diff --git a/src/var/lib/tyto/translations/site_fr.py b/src/var/lib/tyto/translations/site_fr.py index 98830fd..783ea43 100644 --- a/src/var/lib/tyto/translations/site_fr.py +++ b/src/var/lib/tyto/translations/site_fr.py @@ -27,6 +27,7 @@ metas = 'Balises Metas HTML' footer = "Pied de Page" title = 'Titre' File = 'Fichier' +name = 'Nom' q = ' ?' i = ' !' pp = " :"