[DEV] add counting of images

This commit is contained in:
Edouard DUPIN 2020-09-02 12:24:47 +02:00
parent 4528de5235
commit 15d2722381

View File

@ -70,8 +70,13 @@ def transcode_part2(value):
value = value.replace(":IMAGE:SLASH:", "/") value = value.replace(":IMAGE:SLASH:", "/")
return value return value
element_type_count={"Image":0}
def replace_image(match): def replace_image(match):
global image_base_path global image_base_path
global element_type_count
if match.group() == "": if match.group() == "":
return "" return ""
debug.verbose("Image parse: " + str(match.group())) debug.verbose("Image parse: " + str(match.group()))
@ -116,14 +121,15 @@ def replace_image(match):
else: else:
debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'") debug.warning("not manage element '" + key_alt + "' in '" + str(match.group()) + "'")
value += '/>' value += '/>'
value = value.replace("_", ":IMAGE:UNDER:SCORE:")
value = value.replace("*", ":IMAGE:STAR:") if type in element_type_count.keys():
value = value.replace("[", ":IMAGE:BRACKET:START:") element_type_count[type] += 1
value = value.replace("]", ":IMAGE:BRACKET:STOP:") else:
value = value.replace(":BASE:IMAGE:UNDER:SCORE:PATH:", ":BASE_PATH:") element_type_count[type] = 1
if showTitle == True: if showTitle == True:
value = "<br/>" + value + "<br/><u><b>Image: </b>" + title + "</u><br/>" value = "<br/>" + value + "<br/>[" + str(element_type_count[type]) + "] <u><b>" + type + ": </b>" + title + "</u><br/>"
if center == True: if center == True:
value = "<center>" + value + "</center>" value = "<center>" + value + "</center>"
@ -132,6 +138,12 @@ def replace_image(match):
elif left == True: elif left == True:
value = "<left>" + value + "</left>" value = "<left>" + value + "</left>"
value = value.replace("_", ":IMAGE:UNDER:SCORE:")
value = value.replace("*", ":IMAGE:STAR:")
value = value.replace("[", ":IMAGE:BRACKET:START:")
value = value.replace("]", ":IMAGE:BRACKET:STOP:")
value = value.replace(":BASE:IMAGE:UNDER:SCORE:PATH:", ":BASE_PATH:")
return value return value