Difference between revisions of "User:TidB/Operation Cleanup/Filters"

From Team Fortress Wiki
Jump to: navigation, search
m
(I may be misunderstading you a bit, but this should be correct (?))
Line 5: Line 5:
 
def check_displaytitle(t, **kwargs):
 
def check_displaytitle(t, **kwargs):
 
     displaytitle_notrequired = ["Cosmetic items", "Weapons", "Patches", "Tools", "Action items"]
 
     displaytitle_notrequired = ["Cosmetic items", "Weapons", "Patches", "Tools", "Action items"]
     displaytitle_required = ["Major updates"]  # Set because major updates are also in the "patches" category
+
     displaytitle_required = ["Major updates", "Content Packs"]  # Set because major updates are also in the "patches" category
 
     if t.getName().startswith("DISPLAYTITLE:"):  # why do we need a getter method btw?
 
     if t.getName().startswith("DISPLAYTITLE:"):  # why do we need a getter method btw?
 
         categories = kwargs["page"].getCategories()  # I'm just guessing the return type is a list, will check later
 
         categories = kwargs["page"].getCategories()  # I'm just guessing the return type is a list, will check later
 
         language = kwargs["page"].title.split()[1]  # I know it's ugly, but I dunno if there are easier sources to get the language code
 
         language = kwargs["page"].title.split()[1]  # I know it's ugly, but I dunno if there are easier sources to get the language code
         if [c for c in displaytitle_required
+
         if c:
 +
            for c in displaytitle_required:
 
                 if "Category:{}/{}".format(c, language) in categories]:
 
                 if "Category:{}/{}".format(c, language) in categories]:
            return t
+
                    return t
 
         for category in displaytitle_notrequired:
 
         for category in displaytitle_notrequired:
 
             if "Category:{}/{}".format(category, language) in categories:
 
             if "Category:{}/{}".format(category, language) in categories:

Revision as of 04:23, 4 November 2014

Test page; will poot filter concepts for User:WindBOT here. Later (my favorite word).

As I haven't looked into both wikitools' and WindBOT's code too much, this is really just a concept.

def check_displaytitle(t, **kwargs):
    displaytitle_notrequired = ["Cosmetic items", "Weapons", "Patches", "Tools", "Action items"]
    displaytitle_required = ["Major updates", "Content Packs"]  # Set because major updates are also in the "patches" category
    if t.getName().startswith("DISPLAYTITLE:"):  # why do we need a getter method btw?
        categories = kwargs["page"].getCategories()  # I'm just guessing the return type is a list, will check later
        language = kwargs["page"].title.split()[1]  # I know it's ugly, but I dunno if there are easier sources to get the language code
        if c:
            for c in displaytitle_required:
                if "Category:{}/{}".format(c, language) in categories]:
                    return t
        for category in displaytitle_notrequired:
            if "Category:{}/{}".format(category, language) in categories:
                return None
addTemplateFilter(check_displaytitle)