lahwaacz / wiki-scripts

Framework for writing bots, maintenance scripts or performing data analysis on wikis powered by MediaWiki
http://lahwaacz.github.io/wiki-scripts/
GNU General Public License v3.0
27 stars 12 forks source link

toc.py: KeyError: 'Category:Maintenance' #72

Closed kynikos closed 3 years ago

kynikos commented 3 years ago

Hi, I think maybe toc.py has problems creating root categories? The following could be because of the new https://wiki.archlinux.org/index.php/Category:Pages_or_sections_flagged_with_Template:Translateme_(Suomi)

% python toc.py -s
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (Ελληνικά)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (Español)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (Português)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (Русский)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (Українська)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (简体中文)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Translateme (正體中文)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Unsupported (Português)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Unsupported (简体中文)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (Ελληνικά)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (Español)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (Português)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (Русский)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (Українська)]]...
INFO     Fixing language of categories on page [[Category:Pages or sections flagged with Template:Bad translation (简体中文)]]...
INFO     All pages are categorized under correct language.
Traceback (most recent call last):
  File "toc.py", line 363, in <module>
    toc.run()
  File "toc.py", line 300, in run
    graph.init_wanted_categories()
  File "/home/dario/dev/arch/wiki-scripts/ws/interlanguage/CategoryGraph.py", line 200, in init_wanted_categories
    self.create_category(page["title"])
  File "/home/dario/dev/arch/wiki-scripts/ws/interlanguage/CategoryGraph.py", line 189, in create_category
    parents = [localized_category(p, langname) for p in self.parents[local]]
KeyError: 'Category:Maintenance'

I suppose I could just create the Category manually, it's nothing that's going to happen frequently at all, but I thought maybe it's an easy fix for you (I guess I could debug this myself and open a PR, but... :) )

EDIT: This happens on 7723798f3253a102ef2a3c0fa6c8b26ffeb8f3f5

lahwaacz commented 3 years ago

Thanks for the report, it was quite easy to fix the code. However, Category:Maintenance is special, since it aggregates all maintenance subcategories for all languages, so I had to do this and this. I don't know if this can be reasonably handled automatically. Of course if you have suggestions, I'd like to hear them :wink:

lahwaacz commented 3 years ago

Actually, the correct things to do were this and this...

kynikos commented 3 years ago

Oh you're right, that exception scared me too much, so I forgot we don't have localized Maintenance categories :P Thank you!