Skip to content

Commit 9886986

Browse files
committed
Fix logging
Fixed logging so that now *only* unblocked users are logged. Previously, the entire category was logged every time. This made it hard to keep track of statistics of how many were removed.
1 parent 759c73a commit 9886986

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

remove_blocked.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
if __name__ == "__main__":
55
site = pywikibot.Site(fam="wikipedia", code="en", user="TheSandBot")
66
pattern = r'(?:User talk:)([^/\n]+)'
7+
count = 0
78
for page in pywikibot.Category(site, "Wikipedia usernames with possible policy issues").articles():
89
if page.title() == "Template:Uw-corpname":
910
continue
1011
m = re.search(pattern, str(page.title()))
1112
user_raw = m.group(1)
1213
user = pywikibot.User(site, user_raw)
1314
if user.isBlocked():
14-
with open("block_removed_mar_9_2020.txt", 'a+') as f:
15-
f.write(str(page.title()) + "\n")
15+
with open("block_removed_mar_14_2020.txt", 'a+') as f:
16+
count += 1
17+
f.write(str(count) + " " + str(page.title()) + "\n")
1618
page.text = page.text.replace("[[Category:Wikipedia usernames with possible policy issues|{{PAGENAME}}]]",
1719
"")
1820
page.save(

0 commit comments

Comments
 (0)