check: fixes for tags + brut: to raw:
This commit is contained in:
parent
3e8ca0e643
commit
ebdeac513f
|
@ -24,7 +24,7 @@ file: Nom du lien
|
||||||
URL
|
URL
|
||||||
Texte Alternatif
|
Texte Alternatif
|
||||||
|
|
||||||
brut: Nom
|
raw : Nom
|
||||||
URI
|
URI
|
||||||
Texte Alternatif
|
Texte Alternatif
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ def check_icodes(article):
|
||||||
def check_headers(post_header):
|
def check_headers(post_header):
|
||||||
global post_err, err, web_uri, date_check
|
global post_err, err, web_uri, date_check
|
||||||
global date, title, author, tags, about
|
global date, title, author, tags, about
|
||||||
global stat_links, stat_images, stat_files, stat_bruts, stat_abbrs
|
global stat_links, stat_images, stat_files, stat_raws, stat_abbrs
|
||||||
global post_tags
|
global post_tags
|
||||||
|
|
||||||
# Needed Tags
|
# Needed Tags
|
||||||
|
@ -165,7 +165,7 @@ def check_headers(post_header):
|
||||||
date = ()
|
date = ()
|
||||||
|
|
||||||
# Statistics
|
# Statistics
|
||||||
stat_links = stat_images = stat_files = stat_bruts = stat_abbrs = 0
|
stat_links = stat_images = stat_files = stat_raws = stat_abbrs = 0
|
||||||
|
|
||||||
###
|
###
|
||||||
# First session for needed tags #
|
# First session for needed tags #
|
||||||
|
@ -176,32 +176,32 @@ def check_headers(post_header):
|
||||||
# Set each needed tag #
|
# Set each needed tag #
|
||||||
# Only the first one is set #
|
# Only the first one is set #
|
||||||
#---------------------------#
|
#---------------------------#
|
||||||
tag = 'title:'
|
tag = tyto.headers[0] # title:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
if title: continue
|
if title: continue
|
||||||
title = line.rsplit(tag)[1].lstrip()
|
title = line.rsplit(tag)[1].lstrip()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tag = 'about:'
|
tag = tyto.headers[1] # about:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
if about: continue
|
if about: continue
|
||||||
about = line.rsplit(tag)[1].lstrip()
|
about = line.rsplit(tag)[1].lstrip()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tag = 'tags:'
|
tag = tyto.headers[2] # author:
|
||||||
|
if line.startswith(tag):
|
||||||
|
if author: continue
|
||||||
|
author = line.rsplit(tag)[1].lstrip()
|
||||||
|
continue
|
||||||
|
|
||||||
|
tag = tyto.headers[3] # tags:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
if tags: continue
|
if tags: continue
|
||||||
tags = line.rsplit(tag)[1].lstrip()
|
tags = line.rsplit(tag)[1].lstrip()
|
||||||
post_tags = len(tags.strip().split(","))
|
post_tags = len(tags.strip().split(","))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tag = 'author:'
|
|
||||||
if line.startswith(tag):
|
|
||||||
if author: continue
|
|
||||||
author = line.rsplit(tag)[1].lstrip()
|
|
||||||
continue
|
|
||||||
|
|
||||||
tag = 'date:'
|
tag = tyto.headers[4] # date:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
if date: continue
|
if date: continue
|
||||||
date = line.rsplit(tag)[1].lstrip()
|
date = line.rsplit(tag)[1].lstrip()
|
||||||
|
@ -219,11 +219,11 @@ def check_headers(post_header):
|
||||||
#-------------------#
|
#-------------------#
|
||||||
# Set needed tags
|
# Set needed tags
|
||||||
need_headers = {
|
need_headers = {
|
||||||
'title:' : title,
|
tyto.headers[0] : title,
|
||||||
'anout:' : about,
|
tyto.headers[1] : about,
|
||||||
'tags:' : tags,
|
tyto.headers[2] : author,
|
||||||
'author:': author,
|
tyto.headers[3] : tags,
|
||||||
'date:' : date
|
tyto.headers[4] : date
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if set needed tags
|
# Check if set needed tags
|
||||||
|
@ -245,7 +245,7 @@ def check_headers(post_header):
|
||||||
|
|
||||||
# ABBR
|
# ABBR
|
||||||
#-----
|
#-----
|
||||||
tag = 'abbr:'
|
tag = tyto.headers[8] # abbr:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
stat_abbrs += 1
|
stat_abbrs += 1
|
||||||
var_tag = 'abbr_%s'%stat_abbrs
|
var_tag = 'abbr_%s'%stat_abbrs
|
||||||
|
@ -282,7 +282,7 @@ def check_headers(post_header):
|
||||||
|
|
||||||
# LINK
|
# LINK
|
||||||
#-----
|
#-----
|
||||||
tag = 'link:'
|
tag = tyto.headers[5] # link:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
stat_links += 1
|
stat_links += 1
|
||||||
var_tag = 'link_%s'%stat_links
|
var_tag = 'link_%s'%stat_links
|
||||||
|
@ -318,7 +318,7 @@ def check_headers(post_header):
|
||||||
|
|
||||||
# IMAGE
|
# IMAGE
|
||||||
#------
|
#------
|
||||||
tag = 'image:'
|
tag = tyto.headers[6] # image:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
stat_images += 1
|
stat_images += 1
|
||||||
var_tag = 'image_%s'%stat_images
|
var_tag = 'image_%s'%stat_images
|
||||||
|
@ -353,41 +353,41 @@ def check_headers(post_header):
|
||||||
image_alt
|
image_alt
|
||||||
)
|
)
|
||||||
|
|
||||||
# BRUT
|
# RAW File
|
||||||
#-----
|
#---------
|
||||||
tag = 'brut:'
|
tag = tyto.headers[9] # raw:
|
||||||
if line.startswith(tag):
|
if line.startswith(tag):
|
||||||
stat_bruts += 1
|
stat_raws += 1
|
||||||
var_tag = 'brut_%s'%stat_bruts
|
var_tag = 'raw_%s'%stat_raws
|
||||||
|
|
||||||
brut_name = post_header[ln - 1]
|
raw_name = post_header[ln - 1]
|
||||||
brut_name = brut_name.rsplit(tag)[1].lstrip().rsplit(' ')[0]
|
raw_name = raw_name.rsplit(tag)[1].lstrip().rsplit(' ')[0]
|
||||||
if not brut_name:
|
if not raw_name:
|
||||||
tyto.exiting("2", "Line %s (Name, %s)"%(ln, tag), False)
|
tyto.exiting("2", "Line %s (Name, %s)"%(ln, tag), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
if not isin(r'\b_%s%s\b'%(tag, brut_name), post_bottom):
|
if not isin(r'\b_%s%s\b'%(tag, raw_name), post_bottom):
|
||||||
tyto.exiting("6", "_%s%s"%(tag, brut_name), False)
|
tyto.exiting("6", "_%s%s"%(tag, raw_name), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
brut_uri = post_header[ln].lstrip()
|
raw_uri = post_header[ln].lstrip()
|
||||||
if brut_uri.startswith(tyto.headers): brut_uri = ''
|
if raw_uri.startswith(tyto.headers): raw_uri = ''
|
||||||
if not brut_uri:
|
if not raw_uri:
|
||||||
tyto.exiting("2", "Line %s (URI, %s)"%(ln + 1, tag), False)
|
tyto.exiting("2", "Line %s (URI, %s)"%(ln + 1, tag), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
else:
|
else:
|
||||||
check_file_uri('file', brut_uri, ln + 1)
|
check_file_uri('file', raw_uri, ln + 1)
|
||||||
|
|
||||||
brut_alt = post_header[ln + 1].lstrip()
|
raw_alt = post_header[ln + 1].lstrip()
|
||||||
if brut_alt.startswith(tyto.headers): brut_alt = ''
|
if raw_alt.startswith(tyto.headers): raw_alt = ''
|
||||||
if not brut_alt:
|
if not raw_alt:
|
||||||
tyto.exiting("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False)
|
tyto.exiting("2", "Line %s (Alt-Text, %s)"%(ln + 2, tag), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
if not post_err:
|
if not post_err:
|
||||||
globals()['brut_%s'%stat_bruts] = (
|
globals()['raw_%s'%stat_raws] = (
|
||||||
'_%s%s'%(tag, brut_name),
|
'_%s%s'%(tag, raw_name),
|
||||||
web_uri,
|
web_uri,
|
||||||
brut_alt
|
raw_alt
|
||||||
)
|
)
|
||||||
|
|
||||||
# FILE
|
# FILE
|
||||||
|
@ -568,7 +568,7 @@ def check_content(post_bottom):
|
||||||
|
|
||||||
match = False
|
match = False
|
||||||
for hline in post_header:
|
for hline in post_header:
|
||||||
if hline.startswith('image:'):
|
if hline.startswith(htag):
|
||||||
htag_id = hline.rsplit(':', 1)[1].lstrip()
|
htag_id = hline.rsplit(':', 1)[1].lstrip()
|
||||||
if htag_id == tag_id:
|
if htag_id == tag_id:
|
||||||
match = True
|
match = True
|
||||||
|
@ -642,10 +642,10 @@ def create_database():
|
||||||
database, i, globals()['file_%s'%i]
|
database, i, globals()['file_%s'%i]
|
||||||
)
|
)
|
||||||
|
|
||||||
if stat_bruts > 0:
|
if stat_raws > 0:
|
||||||
for i in range(1, stat_bruts + 1):
|
for i in range(1, stat_raws + 1):
|
||||||
database = '%s\nbrut_%s = %s'%(
|
database = '%s\nraw_%s = %s'%(
|
||||||
database, i, globals()['brut_%s'%i]
|
database, i, globals()['raw_%s'%i]
|
||||||
)
|
)
|
||||||
|
|
||||||
db_stats = '\n# Statistics from optional tags\n' + \
|
db_stats = '\n# Statistics from optional tags\n' + \
|
||||||
|
@ -654,7 +654,7 @@ def create_database():
|
||||||
'uniq_links = %s\n'%(int(stat_links)) + \
|
'uniq_links = %s\n'%(int(stat_links)) + \
|
||||||
'uniq_images = %s\n'%(int(stat_images)) + \
|
'uniq_images = %s\n'%(int(stat_images)) + \
|
||||||
'uniq_files = %s\n'%(int(stat_files)) + \
|
'uniq_files = %s\n'%(int(stat_files)) + \
|
||||||
'uniq_bruts = %s\n'%(int(stat_bruts)) + \
|
'uniq_raws = %s\n'%(int(stat_raws)) + \
|
||||||
'\n# Statistics from post content\n' + \
|
'\n# Statistics from post content\n' + \
|
||||||
'stat_tags = %s\n'%(int(post_tags)) + \
|
'stat_tags = %s\n'%(int(post_tags)) + \
|
||||||
'stat_words = %s\n'%(int(post_words)) + \
|
'stat_words = %s\n'%(int(post_words)) + \
|
||||||
|
|
|
@ -101,7 +101,7 @@ headers = (
|
||||||
'image:',
|
'image:',
|
||||||
'file:',
|
'file:',
|
||||||
'abbr:',
|
'abbr:',
|
||||||
'brut:',
|
'raw:',
|
||||||
'#'
|
'#'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ quote_tags = [
|
||||||
]
|
]
|
||||||
|
|
||||||
# Tags to check for header in content
|
# Tags to check for header in content
|
||||||
content_tags = ("_image:", '_brut:')
|
content_tags = ("_image:", '_raw:')
|
||||||
|
|
||||||
|
|
||||||
#=======#
|
#=======#
|
||||||
|
|
Loading…
Reference in New Issue