def evaluate(self, formatter, kwargs, mi, locals, val, is_read_pct,
test_val = int(is_read_pct)
return 'is_read_pct is not a number'
pattern = u'.*(\d+[-/]\d+[-/]\d+).*?Dernière page lue : Emplacement \d+ \((\d+)%\)'
mg = re.match(pattern, val, re.U + re.I + re.DOTALL);
if mg is None:
date = mg.group(1)
pct = mg.group(2)
f = int(pct)
if f > test_val:
elif f > 0:
return is_reading_str + ': ' + pct + '%'
1) Your sample string from the comment has no space before the date. The original function required that space ('\s' before the '(' in the pattern).
2) You must tell python that the strings contain unicode (the u' in the pattern).
3) You should tell the re.match function that the arguments are unicode (re.U).
4) The character after 'lue' is very strange. It is not a space. I had to change it to be a real space character. You might be able to change it back if you put that same character into the pattern.
I cannot guarantee that this function will work with your data because the comments are in html. What you see might not be what is actually in the comment.