Page MenuHomePhabricator

Take main categories to top
Open, LowPublic

Description

This is already done, but it is made by comparison of page title and category title. This should be handled using Wikidata

Event Timeline

jayvdb created this task.Nov 30 2014, 5:20 PM
jayvdb assigned this task to Ladsgroup.
jayvdb raised the priority of this task from to Needs Triage.
jayvdb updated the task description. (Show Details)
jayvdb changed Security from none to None.
jayvdb moved this task from Backlog to Deactivated code on the Pywikibot-cosmetic-changes.py board.
jayvdb added a subscriber: jayvdb.
Ladsgroup moved this task from Incoming to Later on the User-Ladsgroup board.Aug 12 2016, 8:43 PM
Ladsgroup removed Ladsgroup as the assignee of this task.Aug 12 2016, 8:52 PM
Ladsgroup removed a project: User-Ladsgroup.

@JAnD I remember you worked with main cats once, maybe you would share the code

JAnD added a comment.Feb 4 2018, 7:27 PM

@JAnD I remember you worked with main cats once, maybe you would share the code

I found the script, but the author of code was @Ladsgroup

#!/usr/bin/python
#coding: utf-8
import wikipedia, codecs, re
site = wikipedia.getSite("cs")
f = codecs.open("cswiki.txt","r","utf-8")
rer = re.compile("\[\[(.+?)\]\]")
aaa = rer.findall(f.read())
f.close()
excludes = [u'{{Rozcestník',u'{{rozcestník',u'{{Přesměrování']
for name in aaa:
    page = wikipedia.Page(site,name)
    try:
        text = page.get()
    except:
        continue
    ok = True
    for exclude in excludes:
        if exclude in text:
            ok = False
    if not ok:
        continue
    new_text = re.sub(u"\[\[Kategorie\:%s(\|.*?)? *?]]" % re.escape(page.title()),"",text)
    add_text = u"[[Kategorie:%s| ]]" % page.title()
    if u"\n[[Kategorie" in new_text:
        new_text = new_text.replace(u"\n[[Kategorie",add_text+u"\n[[Kategorie",1)
    else:
        new_text += add_text
    if new_text!= text:
        page.put(new_text, u"Hlavní kategorie: jako první, řadicí klíč")

I see, looks like a code for compat, but could be rewritten easily, thank you!

Dvorapa updated the task description. (Show Details)Apr 20 2018, 6:50 PM
Dvorapa claimed this task.May 24 2018, 7:32 PM
Dvorapa triaged this task as Low priority.
Dvorapa moved this task from Deactivated code to Backlog on the Pywikibot-cosmetic-changes.py board.
Dvorapa added a project: good first task.
Dvorapa moved this task from Backlog to Doing on the good first task board.

Change 434997 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [IMPR] Move main categories to top in cc

https://gerrit.wikimedia.org/r/434997

Change 434997 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Move main categories to top in cc

https://gerrit.wikimedia.org/r/434997

The next step should be to load main categories from Wikidata

Dvorapa renamed this task from category handling standardizePageFooter to Take main categories to top.May 29 2018, 10:41 AM
Dvorapa updated the task description. (Show Details)
Dvorapa moved this task from Doing to Backlog on the good first task board.
Dvorapa removed Dvorapa as the assignee of this task.May 29 2018, 8:36 PM