def setUp(self): self.noisebridge = wikipedia.Site('en') self.browser = mechanize.Browser() f = 'file://' + os.path.abspath( os.path.join(os.path.dirname(os.path.realpath(__file__)), 't/index.php.htm')) self.r = self.browser.open(f)
def main(args): noisebridge = wikipedia.Site('en') if len(args) > 0: lastUser = args[0] else: f = open("/tmp/death_to_wikispammers_last_spammer", "r") lastUser = f.readline().strip() f.close() users = user_list_since_user(noisebridge, lastUser).getUsers() for i in users: print ">>> ", i.name() if i.isBlocked(): continue try: m = i.contributions(limit=1).next() print "Last edit:", m except StopIteration: pass decision = raw_input("Spam? [y/N]") if decision.upper() == "Y": print "Despamming" for each_page in i.contributions(): print each_page each_page[0].delete("Spam (deleted by [Secretaribot] )", prompt=False) i.block(reason="Spam: deleted by [Secretaribot]", expiry="infinite", onAutoblock=True, allowUsertalk=False, anon=False) f = open("/tmp/death_to_wikispammers_last_spammer", "w") f.write(i.name()) f.close()
def main(args): if not args: initial_user = "******" else: initial_user = args[0] nb = wikipedia.Site('en', "noisebridge") spam_user = userlib.User(nb, "SpammerHellDontDelete") ul = userlistpage.user_list_since_user(nb, initial_user).getUsers() for i in ul: print i if i.isBlocked(): print "Merging", i (merged, deleted) = mergeUser(nb, i, spam_user, delete=True) print "Merged:", merged print "Deleted:", deleted
def main(args): site = wikipedia.Site("en") last_page = "Meeting Notes " + str(past_tuesday()).replace("-", " ") next_page = "Meeting Notes " + str(future_tuesday()).replace("-", " ") create_new_notes(site, last_page, next_page) redirect_pages(site, last_page, next_page)
p1 = subprocess.Popen([command] + args, stdout=subprocess.PIPE) output = p1.communicate()[0] return output i = open("README.intro", 'r') o = open("README.md", 'w') o.write(i.read(-1)) for i in glob.glob('*.py') + glob.glob('*.agi'): cm = get_intro(i) o.write(cm) o.close() m = pipeout("pandoc", ["-f", "markdown", "-t", "mediawiki", "README.md"]) site = wikipedia.Site("en") wikipedia.Page(site, "Secretaribot").put(m, u"New README at github") def main(args): """ FIXME put your command runner here """ pass import getopt class Main(): """ Encapsulates option handling. Subclass to add new options, add 'handle_x' method for an -x option, add 'handle_xlong' method for an --xlong option