check: fixed for empty markers in header post

This commit is contained in:
Cyrille L 2022-11-25 17:09:37 +01:00
parent 9f43f9a8a0
commit 0560c4665c
2 changed files with 56 additions and 16 deletions

View File

@ -553,11 +553,20 @@ def check_files(line, ln, stats_files_uniq):
global stats_files_p global stats_files_p
# Create variable array # Create variable array
file_nbr = 'file_%s'%stats_files_uniq try: file_name = line.split('file:')[1].lstrip()
file_name = line.split('file:')[1].lstrip() except: file_name = ''
file_uri = headers.rsplit('\n')[ln].lstrip() try: file_uri = headers.rsplit('\n')[ln].lstrip()
file_alt = headers.rsplit('\n')[ln+1].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
# Check 2nd line # Check 2nd line
check_new_marker(file_uri) check_new_marker(file_uri)
if 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 global stats_bruts_p
# Create variable array # Create variable array
brut_nbr = 'brut_%s'%stats_bruts_uniq try: brut_name = line.split('brut:')[1].lstrip().rsplit(' ')[0]
brut_name = line.split('brut:')[1].lstrip().rsplit(' ')[0] except: brut_name = ''
brut_uri = headers.rsplit('\n')[ln].lstrip() try: brut_uri = headers.rsplit('\n')[ln].lstrip()
brut_alt = headers.rsplit('\n')[ln+1].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 2nd line
check_new_marker(brut_uri) check_new_marker(brut_uri)
if 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 global stats_images_p
# Create variable array # 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 2nd line
check_new_marker(image_uri) check_new_marker(image_uri)
if 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 global stats_abbrs_p
# Create variable array # Create variable array
abbr_name = line.split('abbr:')[1].lstrip() try: abbr_name = line.split('abbr:')[1].lstrip()
abbr_alt = headers.rsplit('\n')[ln].lstrip() except: abbr_name = ''
abbr_rep = headers.rsplit('\n')[ln+1].lstrip() 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 # Set/Check values to check in header
if not abbr_name: if not abbr_name:
msg_log = 'Line %s. Unused NAME for marker "abbr:"'%ln msg_log = 'Line %s. Unused NAME for marker "abbr:"'%ln
log.append_f(post_logs,msg_log,1) log.append_f(post_logs,msg_log,1)
Post_Err = True Post_Err = True
return(1)
elif abbr_name.isupper() is False: elif abbr_name.isupper() is False:
msg_log = 'Line %s. NAME not in CAPITAL for marker "abbr:"'%ln msg_log = 'Line %s. NAME not in CAPITAL for marker "abbr:"'%ln
log.append_f(post_logs,msg_log,1) log.append_f(post_logs,msg_log,1)

View File

@ -120,7 +120,15 @@ def manage_wip(file_post, Force):
wip_html = html.page wip_html = html.page
print('> Article HTML:\n', wip_html) 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()