Quote:
Originally Posted by thiago.eec
Thanks so much for finding the problem. I tried appling your fix and noticed it stoped working for me. Then I checked the 'month_abbr' output. Turns out it's lowercase in pt-BR. God knows why!
So, to make sure it will always work, the best thing to do is to keep everything lowercase. So I did this:
Code:
read_pages_month_count = {k.lower(): v for k, v in read_pages_month_count.items()}
Now it is compatible with 'daily_page_count()'.
Please test and confirm it works.
|
I was afraid this would be a locale thing.
Sadly, this does not work.
1. In "get_month_html" function to create "bar" you access m[i] which is still upper case.
So this works:
Code:
if prefs['pages_instead_of_books']: # Read pages
bar = month_bar.format(month_pages_stats[m[i].lower()][0], month_pages_stats[m[i].lower()][1],
'<a href="http://reading_goal/' + m[i].lower() + '">' + m[i] + '</a>',
str(month_books_stats[m[i].lower()][0]))
else: # Read books
bar = month_bar.format(month_books_stats[m[i].lower()][0], month_books_stats[m[i].lower()][1],
'<a href="http://reading_goal/' + m[i].lower() + '">' + m[i] + '</a>',
str(month_pages_stats[m[i].lower()][0]))
only keeping the display of m[i] as is for a correct display to the user.
2. Also an error when updating a book in the function "update_summary"
Code:
if data[book_id]['status'] == 100:
read_books_count += 1
month = data[book_id]['date'].astimezone().strftime('%b')
read_books_month_count[month] += 1
month is uppercase, while the data is now lowercase.
so this I had to change to:
Code:
month = data[book_id]['date'].astimezone().strftime('%b').lower()
With these two changes everything seemed to work. I tried to use all the features and no error was thrown anymore.
----
Is it really necessary to use lowercase? I think it might be easily missable somewhere which might result in an error. But maybe removing lowercase everywhere will also result in other errors ...
Another idea would be to use a new, forced lower case dict of the month abbreviation list ... like defining a global:
Code:
ml = [month.lower() for month in m]
and then use ml instead of m everywhere, which will result in all data/keys to be lowercase without having to call lower() everywhere. Well, except where the date is obtained from the timezone as in codeblock 2.
And then only use m when displaying it to the user, e.g. in "'">' + m[i] + '</a>'"
----
Anyways, fixing the 2 codeblocks as described above worked for me so far.
Again, thank you so much!