User:Surjection/inactive sysops.py

Hello, you have come here looking for the meaning of the word User:Surjection/inactive sysops.py. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Surjection/inactive sysops.py, but we will also tell you about its etymology, its characteristics and you will know how to say User:Surjection/inactive sysops.py in singular and plural. Everything you need to know about the word User:Surjection/inactive sysops.py you have here. The definition of the word User:Surjection/inactive sysops.py will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Surjection/inactive sysops.py, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

from pywikibot import Site, Page, Category, Timestamp
from datetime import datetime, timedelta

"removal of admin rights without prejudice (i.e. returnable upon request) ] (no admin tools used in the past five years)"

"""
== Admin rights ==
Hi, I have removed your admin rights due to ], as you have not used any admin tools in the past five years. This removal is without prejudice and you can request your admin rights to be restored at any time. ~~~~
"""



enwikt = Site("en", fam="wiktionary")
enwikt.login()


now = datetime.now()
cutoff = now.replace(year=now.year - 5)
cutoff_iso = cutoff.isoformat()
cutoff_ts = Timestamp.fromISOformat(cutoff_iso)


print("Cutoff:", cutoff_ts)


DEBUG = True
CONTRIB_UPPER_LIMIT = 10000


admins =  for admin in enwikt.allusers(group='sysop')]

for username in admins:
    if username in {"Abuse filter"}:
        # never active, that nerd
        continue

    def is_active(username):
        for event in enwikt.logevents(user=username, end=cutoff_ts):
            action = event.action()
            if "abusefilter" in action:
                if DEBUG:
                    print(username.ljust(50) + "modified abuse filters")
                return True
            if action in {"block", "reblock", "unblock",    # self-explanatory
                          "delete", "restore",              # page (un)deletion
                          "protect", "unprotect", "modify", # page (un)protection or modifying a protection
                          "event",                          # deletion of log events
                          "revision",                       # revision (un)deletion
                          "rights"                          # changing of user rights
                          }:
                if DEBUG:
                    print(username.ljust(50) + "performed admin action {}".format(action))
                return True
            if action in {"move", "move_redir"} and event.suppressedredirect():
                if DEBUG:
                    print(username.ljust(50) + "moved page without redirect")
                return True

        for contribs, page in enumerate(enwikt.preloadpages(Page(enwikt, edit) for edit in enwikt.usercontribs(user=username, end=cutoff_ts))):
            if contribs > CONTRIB_UPPER_LIMIT:
                if DEBUG:
                    print(username.ljust(50) + "has been an active contributor")
                return True
            try:
                if page.ns in {8}:
                    if DEBUG:
                        print(username.ljust(50) + "edited a system message ]".format(page.title()))
                    return True
            except AttributeError:
                continue
            if page.protection().get('edit', None):
                if page.protection().get('edit', None) != 'autoconfirmed':
                    if DEBUG:
                        print(username.ljust(50) + "edited a protected page ]".format(page.title()))
                    return True

        return False

    if not is_active(username):
        print(username)