diff --git a/src/var/lib/tyto/program/check.py b/src/var/lib/tyto/program/check.py index 8f79bcc..4027cb3 100644 --- a/src/var/lib/tyto/program/check.py +++ b/src/var/lib/tyto/program/check.py @@ -553,11 +553,20 @@ def check_files(line, ln, stats_files_uniq): global stats_files_p # Create variable array + try: file_name = line.split('file:')[1].lstrip() + except: file_name = '' + try: file_uri = headers.rsplit('\n')[ln].lstrip() + except: file_uri = '' + try: file_alt = headers.rsplit('\n')[ln+1].lstrip() + except: file_alt = '' + + if not file_name: + msg_log = 'Line %s. Unused NAME for marker "image:"'%ln + log.append_f(post_logs,msg_log,1) + Post_Err = True + return(1) + file_nbr = 'file_%s'%stats_files_uniq - file_name = line.split('file:')[1].lstrip() - file_uri = headers.rsplit('\n')[ln].lstrip() - file_alt = headers.rsplit('\n')[ln+1].lstrip() - # Check 2nd line check_new_marker(file_uri) if new_marker: file_uri = '' @@ -639,11 +648,20 @@ def check_bruts(line, ln, stats_files_uniq): global stats_bruts_p # Create variable array - brut_nbr = 'brut_%s'%stats_bruts_uniq - brut_name = line.split('brut:')[1].lstrip().rsplit(' ')[0] - brut_uri = headers.rsplit('\n')[ln].lstrip() - brut_alt = headers.rsplit('\n')[ln+1].lstrip() + try: brut_name = line.split('brut:')[1].lstrip().rsplit(' ')[0] + except: brut_name = '' + try: brut_uri = headers.rsplit('\n')[ln].lstrip() + except: brut_uri = '' + try: brut_alt = headers.rsplit('\n')[ln+1].lstrip() + except: brut_alt = '' + if not brut_name: + msg_log = 'Line %s. Unused NAME for marker "brut:"'%ln + log.append_f(post_logs,msg_log,1) + Post_Err = True + return(1) + + brut_nbr = 'brut_%s'%stats_bruts_uniq # Check 2nd line check_new_marker(brut_uri) if new_marker: brut_uri = '' @@ -725,11 +743,21 @@ def check_images(line, ln, stats_images_uniq): global stats_images_p # Create variable array - image_nbr = 'image_%s'%stats_images_uniq - image_name = line.split('image:')[1].lstrip().rsplit(' ')[0] - image_uri = headers.rsplit('\n')[ln].lstrip() - image_alt = headers.rsplit('\n')[ln+1].lstrip() + + try: image_name = line.split('image:')[1].lstrip().rsplit(' ')[0] + except: image_name = '' + try: image_uri = headers.rsplit('\n')[ln].lstrip() + except: image_uri = '' + try: image_alt = headers.rsplit('\n')[ln+1].lstrip() + except: image_alt = '' + if not image_name: + msg_log = 'Line %s. Unused NAME for marker "image:"'%ln + log.append_f(post_logs,msg_log,1) + Post_Err = True + return(1) + + image_nbr = 'image_%s'%stats_images_uniq # Check 2nd line check_new_marker(image_uri) if new_marker: image_uri = '' @@ -811,15 +839,19 @@ def check_abbrs(line, ln, stats_abbrs_uniq): global stats_abbrs_p # Create variable array - abbr_name = line.split('abbr:')[1].lstrip() - abbr_alt = headers.rsplit('\n')[ln].lstrip() - abbr_rep = headers.rsplit('\n')[ln+1].lstrip() + try: abbr_name = line.split('abbr:')[1].lstrip() + except: abbr_name = '' + try: abbr_alt = headers.rsplit('\n')[ln].lstrip() + except: abbr_alt = '' + try: abbr_rep = headers.rsplit('\n')[ln+1].lstrip() + except: abbr_rep = '' # Set/Check values to check in header if not abbr_name: msg_log = 'Line %s. Unused NAME for marker "abbr:"'%ln log.append_f(post_logs,msg_log,1) Post_Err = True + return(1) elif abbr_name.isupper() is False: msg_log = 'Line %s. NAME not in CAPITAL for marker "abbr:"'%ln log.append_f(post_logs,msg_log,1) diff --git a/src/var/lib/tyto/program/wip.py b/src/var/lib/tyto/program/wip.py index 454d681..6dbcb83 100644 --- a/src/var/lib/tyto/program/wip.py +++ b/src/var/lib/tyto/program/wip.py @@ -120,8 +120,16 @@ def manage_wip(file_post, Force): wip_html = html.page print('> Article HTML:\n', wip_html) - print(">", file_post) + # Create file to wip srv (replace file, if exists) + wip_file = '%s%s'%(domain.srv_wip, file_post.replace('.tyto','.html')) + if os.path.exists(wip_file): + os.remove(wip_file) + page_file = open(wip_file, 'w') + page_file.write(wip_html) + page_file.close() + + #============================#