rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
pageTxt = pageTxt.replace(ltxt, newTitle) pageTxt = pageTxt.replace(ltxt[0].lower() + ltxt[1:], newTitle[0].lower() + newTitle[1:]) pageTxt = pageTxt.replace(ltxt.replace(u' ', '_'), newTitle) | frmParts = self.wordBreaker.split(ltxt) toParts = self.wordBreaker.split(newTitle) if len(frmParts) != len(toParts): raise u'Splitting parts do not match counts' for i in range(0, len(frmParts)): if len(frmParts[i]) != len(toParts[i]): raise u'Splitting parts do not match word length' if len(frmParts[i]) > 0: pageT... | def Run(self): try: count = 0 for namespace in self.namespaces: self.params['apnamespace'] = namespace self.apfrom = self.apfrom title = None while True: # Get data self.params['apfrom'] = self.apfrom data = query.GetData(self.site.lang, self.params, self.verbose) try: self.apfrom = data['query']['allpages']['next'] e... | d7ae8d783a650481e56e5f8027b09cf5b7a199dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d7ae8d783a650481e56e5f8027b09cf5b7a199dc/casechecker.py |
self.WikiLog(u"* Error: Text replacement failed in [[:%s]] (%s)" % (title, u', '.join(msg))) | self.WikiLog(u"* Error: Text replacement failed in [[:%s]] (%s)" % (title, coloredMsg)) | def Run(self): try: count = 0 for namespace in self.namespaces: self.params['apnamespace'] = namespace self.apfrom = self.apfrom title = None while True: # Get data self.params['apfrom'] = self.apfrom data = query.GetData(self.site.lang, self.params, self.verbose) try: self.apfrom = data['query']['allpages']['next'] e... | d7ae8d783a650481e56e5f8027b09cf5b7a199dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d7ae8d783a650481e56e5f8027b09cf5b7a199dc/casechecker.py |
self.WikiLog(u"* Error: Could not save updated page [[:%s]] (%s)" % (title, u', '.join(msg))) | self.WikiLog(u"* Error: Could not save updated page [[:%s]] (%s)" % (title, coloredMsg)) | def Run(self): try: count = 0 for namespace in self.namespaces: self.params['apnamespace'] = namespace self.apfrom = self.apfrom title = None while True: # Get data self.params['apfrom'] = self.apfrom data = query.GetData(self.site.lang, self.params, self.verbose) try: self.apfrom = data['query']['allpages']['next'] e... | d7ae8d783a650481e56e5f8027b09cf5b7a199dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d7ae8d783a650481e56e5f8027b09cf5b7a199dc/casechecker.py |
reptxt = new_page_title | newlink = "[[%s]]" % new_page_title | def treat(refpl, thispl): try: reftxt=refpl.get() except wikipedia.IsRedirectPage: pass else: n = 0 curpos = 0 while 1: m=linkR.search(reftxt, pos = curpos) if not m: if n == 0: print "Not found in %s"%refpl elif not debug: refpl.put(reftxt) return True # Make sure that next time around we will not find this same hit. ... | be1da88d860fe956e2b028ef2b5d1aa2108a21ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/be1da88d860fe956e2b028ef2b5d1aa2108a21ab/solve_disambiguation.py |
substring. which matches the exception. Otherwise it returns None. | substring which matches the exception. Otherwise it returns None. | def checkExceptions(self, original_text): """ If one of the exceptions applies for the given text, returns the substring. which matches the exception. Otherwise it returns None. """ for exception in self.exceptions: if self.regex: exception = re.compile(exception, re.UNICODE) hit = exception.search(original_text) if hi... | 69bfeb5695828061b35d869f9b68d046ed750197 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/69bfeb5695828061b35d869f9b68d046ed750197/replace.py |
def allowedbot(site): | def allowedbot(username, site): | def allowedbot(site): """Checks whether the bot is listed on Wikipedia:bots""" pl = wikipedia.PageLink(site, "Wikipedia:Bots") text = pl.get() return "[[User:%s" % username in text | 4ba12208d4a9716769b1276d90261b2d674fc18c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4ba12208d4a9716769b1276d90261b2d674fc18c/login.py |
return "[[User:%s" % username in text | return "[[user:%s" % username in text.lower() | def allowedbot(site): """Checks whether the bot is listed on Wikipedia:bots""" pl = wikipedia.PageLink(site, "Wikipedia:Bots") text = pl.get() return "[[User:%s" % username in text | 4ba12208d4a9716769b1276d90261b2d674fc18c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4ba12208d4a9716769b1276d90261b2d674fc18c/login.py |
if not allowedbot(ensite): | if not allowedbot(username, ensite): | def main(args): username = password = None for arg in args:#sys.argv[1:]: arg = wikipedia.argHandler(arg) if arg is None: continue if arg.startswith("-user:"): username = arg[6:] elif arg.startswith("-pass:"): # not recommended password = arg[6:] else: sys.exit("Unknown argument: %s" % arg) mysite = wikipedia.getSite... | 4ba12208d4a9716769b1276d90261b2d674fc18c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4ba12208d4a9716769b1276d90261b2d674fc18c/login.py |
if namespace == -1 or namespace != entry.namespace : | if namespace != -1 and namespace != entry.namespace: | def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex, namespace): ''' Generator which will yield PageLinks to pages that might contain text to replace. These pages will be retrieved from a local sql dump file (cur table). Arguments: * sqlfilename - the dump's path, either absolute or relative * r... | 618d97ddd802effc981771552f0cfc90c6f4f9af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/618d97ddd802effc981771552f0cfc90c6f4f9af/replace.py |
lineR = re.compile('<li> \(.+?\) \(.+?\) <a href=".+?" title=".+?">(?P<datetime>.+?)</a> . . <a href=".+?" title=".+?">(?P<username>.+?)</a> \(<a href=".+?" title=".+?">.+?</a>\) . . (?P<resolution>\d+.+?\d+) \((?P<size>\d+) .+?\)( <span class=\'comment\'>(?P<comment>.*?)</span>)?</li>') | lineR = re.compile('<li> \(.+?\) \(.+?\) <a href=".+?" title=".+?">(?P<datetime>.+?)</a> . . <a href=".+?" title=".+?">(?P<username>.+?)</a> \(<a href=".+?" title=".+?">.+?</a>\) . . (?P<resolution>\d+.+?\d+) \((?P<size>[\d,]+) .+?\)( <span class="comment">(?P<comment>.*?)</span>)?</li>') | def getFileVersionHistory(self): result = [] history = re.search('(?s)<ul class="special">.+?</ul>', self.getImagePageContents()).group() lineR = re.compile('<li> \(.+?\) \(.+?\) <a href=".+?" title=".+?">(?P<datetime>.+?)</a> . . <a href=".+?" title=".+?">(?P<username>.+?)</a> \(<a href=".+?" title=".+?">.+?</a>\) . .... | 504b082c9548a6a659105956710bec75032117af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/504b082c9548a6a659105956710bec75032117af/wikipedia.py |
pl3 = wikipedia.Page(pl.site(),arg.args[0]) wikipedia.output(u"NOTE: %s is redirect to %s" % (pl.aslink(forceInterwiki = True), pl3.aslink(forceInterwiki = True))) if pl == self.inpl: isredirect = 1 for pl2 in self.todo: counter.minus(pl2.site()) self.todo = {} pass elif not globalvar.followredirect: print "NOTE: no... | try: pl3 = wikipedia.Page(pl.site(),arg.args[0]) wikipedia.output(u"NOTE: %s is redirect to %s" % (pl.aslink(forceInterwiki = True), pl3.aslink(forceInterwiki = True))) if pl == self.inpl: isredirect = 1 for pl2 in self.todo: counter.minus(pl2.site()) self.todo = {} pass elif not globalvar.followredirect: print "NOT... | def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ... | bdf1d24a639a2a24fab020ac6bef32a2b3dac649 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bdf1d24a639a2a24fab020ac6bef32a2b3dac649/interwiki.py |
first = first.lower() | first = first.lower().strip() | def isInterwikiLink(self, s): """ Try to check whether s is in the form "foo:bar" or ":foo:bar" where foo is a known language code or family. In such a case we are dealing with an interwiki link. """ s = s.lstrip(":") if not ':' in s: return False first, rest = s.split(':',1) # interwiki codes are case-insensitive firs... | f4ea6226675be38ece3e9650abba9731b15619d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f4ea6226675be38ece3e9650abba9731b15619d6/wikipedia.py |
return False | return self.isInterwikiLink(rest) | def isInterwikiLink(self, s): """ Try to check whether s is in the form "foo:bar" or ":foo:bar" where foo is a known language code or family. In such a case we are dealing with an interwiki link. """ s = s.lstrip(":") if not ':' in s: return False first, rest = s.split(':',1) # interwiki codes are case-insensitive firs... | f4ea6226675be38ece3e9650abba9731b15619d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f4ea6226675be38ece3e9650abba9731b15619d6/wikipedia.py |
data = {"wpName": self.username, | data = {"wpName": self.username.encode(self.site.encoding()), | def getCookie(self, remember=True): """Login to wikipedia. remember Remember login (default: True) Returns cookie data if succesful, None otherwise.""" data = {"wpName": self.username, "wpPassword": self.password, "wpLoginattempt": "Aanmelden & Inschrijven", # dutch button label seems to work for all wikis "wpRem... | 5ddc188ac9f9b44767c872a4d4b2c0e8c11792c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/5ddc188ac9f9b44767c872a4d4b2c0e8c11792c8/login.py |
fam Wikimedia family (optional: defaults to configured) | fam Wikimedia family (optional: defaults to configured). Can either be a string or a Family object. | def __init__(self, code, fam=None, user=None): """Constructor takes three arguments: | 7b53868b9b739a43b411b49889d02e6d60ef916f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b53868b9b739a43b411b49889d02e6d60ef916f/wikipedia.py |
family = Family(fam) if code in family.obsolete and family.obsolete[code]: code = family.obsolete[code] | def getSite(code = None, fam = None, user=None): if code == None: code = default_code if fam == None: fam = default_family # if we got an outdated code, use the new one instead. family = Family(fam) if code in family.obsolete and family.obsolete[code]: code = family.obsolete[code] key = '%s:%s'%(fam,code) if not _sites... | 7b53868b9b739a43b411b49889d02e6d60ef916f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b53868b9b739a43b411b49889d02e6d60ef916f/wikipedia.py | |
self.problem(u"%s: %s gives duplicate interwiki on same site %s" % (self.originPage.aslink(), page.aslink(True), linkedPage.aslink(True))) if globalvar.autonomous: self.todo = [] return | wikipedia.output(u"NOTE: %s: %s gives duplicate interwiki on same site %s" % (self.originPage.aslink(), page.aslink(True), linkedPage.aslink(True))) | def workDone(self, counter): """ This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo. """ # Loop over all the pages that should have been taken care o... | 3c98355a5ba484241f70324847be4ac1aa3e2b32 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3c98355a5ba484241f70324847be4ac1aa3e2b32/interwiki.py |
print "The specified page is not a redirect." sys.exit(1) | print "The specified page is not a redirect. Skipping." continue | def run(self): if self.main_only: if ignore_title.has_key(self.mylang): ignore_title[self.mylang] += self.mysite.namespaces() else: ignore_title[self.mylang] = self.mysite.namespaces() for disambTitle in self.page_list: # when run with -redir argument, there's another summary message if self.solve_redirect: wikipedia.... | c9ced41134489c1f1a6d7c2aa3d5a181db7b2ffa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c9ced41134489c1f1a6d7c2aa3d5a181db7b2ffa/solve_disambiguation.py |
replacements.append((templateR, '{{subst:' + self.old + '}}')) | replacements.append((templateR, '{{subst:' + self.old + '\g<parameters>}}')) | def run(self): # regular expression to find the original template. # {{msg:vfd}} does the same thing as {{msg:Vfd}}, so both will be found. # The new syntax, {{vfd}}, will also be found. # The group 'parameters' will either match the parameters, or an # empty string if there are none. if not wikipedia.getSite().nocapit... | 8aa0286a98ce80d9902bc836e2cde651e77db7c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/8aa0286a98ce80d9902bc836e2cde651e77db7c3/template.py |
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % oldCatTitle) | wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % oldCat.title()) | def __init__(self, oldCatTitle, newCatTitle): self.oldCat = catlib.Category(wikipedia.getSite(), 'Category:' + oldCatTitle) self.newCatTitle = newCatTitle # get edit summary message wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % oldCatTitle) | cf4bb0d4333510322f9737aa60b809a089d6ff18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/cf4bb0d4333510322f9737aa60b809a089d6ff18/category.py |
def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): | def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex, namespace): | def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): ''' Generator which will yield PageLinks to pages that might contain text to replace. These pages will be retrieved from a local sql dump file (cur table). Arguments: * sqlfilename - the dump's path, either absolute or relative * replacements... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
for exception in exceptions: if regex: exception = re.compile(exception) if exception.search(entry.text): skip_page = True break else: if entry.text.find(exception) != -1: skip_page = True break | if namespace == -1 or namespace != entry.namespace : continue else: for exception in exceptions: if regex: exception = re.compile(exception) if exception.search(entry.text): skip_page = True break else: if entry.text.find(exception) != -1: skip_page = True break | def read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): ''' Generator which will yield PageLinks to pages that might contain text to replace. These pages will be retrieved from a local sql dump file (cur table). Arguments: * sqlfilename - the dump's path, either absolute or relative * replacements... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): | def generator(source, replacements, exceptions, regex, namespace, textfilename = None, sqlfilename = None, pagenames = None): | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
for pl in read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex): | for pl in read_pages_from_sql_dump(sqlfilename, replacements, exceptions, regex, namespace): | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
namespace = -1 | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py | |
wikipedia.setAction(wikipedia.translate(wikipedia.mylang, msg)+change) | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py | |
for pl in generator(source, replacements, exceptions, regex, textfilename, sqlfilename, pagenames): | for pl in generator(source, replacements, exceptions, regex, namespace, textfilename, sqlfilename, pagenames): | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
print 'No changes were necessary in %s' % pl.linkname() | try: print 'No changes were necessary in %s' % pl.linkname() except UnicodeEncodeError: print 'Error decoding pl.linkname()' continue | def generator(source, replacements, exceptions, regex, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by the user. ... | d4b4944c8e5c69f758d1be95405dc813ac10b3da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d4b4944c8e5c69f758d1be95405dc813ac10b3da/replace.py |
def resolveRedirect(self): | def resolveRedirect(self, useHEAD = True): | def resolveRedirect(self): ''' Requests the header from the server. If the page is an HTTP redirect, returns the redirect target URL as a string. Otherwise returns None. ''' if self.scheme == 'http': conn = httplib.HTTPConnection(self.host) elif self.scheme == 'https': conn = httplib.HTTPSConnection(self.host) conn.req... | f389d16ab34b6f2834424d596326436eb58228e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f389d16ab34b6f2834424d596326436eb58228e4/weblinkchecker.py |
conn.request('HEAD', '%s%s' % (self.path, self.query), None, self.header) response = conn.getresponse() | try: if useHEAD: conn.request('HEAD', '%s%s' % (self.path, self.query), None, self.header) else: conn.request('GET', '%s%s' % (self.path, self.query), None, self.header) response = conn.getresponse() except httplib.BadStatusLine: return self.resolveRedirect(useHEAD = False) | def resolveRedirect(self): ''' Requests the header from the server. If the page is an HTTP redirect, returns the redirect target URL as a string. Otherwise returns None. ''' if self.scheme == 'http': conn = httplib.HTTPConnection(self.host) elif self.scheme == 'https': conn = httplib.HTTPSConnection(self.host) conn.req... | f389d16ab34b6f2834424d596326436eb58228e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f389d16ab34b6f2834424d596326436eb58228e4/weblinkchecker.py |
nerr += 1 | nerr += 1 | def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the code as key. # Each value will be a list. new = {} for pl in self.done.keys(): code = pl.code() if code == wikipedia.mylang and pl.exists() and not pl.isRedirectPage() and not pl.isEmpty(): if pl != self.... | 4c83ef2d1fc33f6061f57e637d53575f39cf5334 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4c83ef2d1fc33f6061f57e637d53575f39cf5334/interwiki.py |
choice = wikipedia.input('WARNING: %s is a disambiguation page, but %s doesn\'t seem to be one. Follow it anyway? [y|N]' % (self.inpl.aslink(), pl.aslink())) | choice = wikipedia.inputChoice('WARNING: %s is a disambiguation page, but %s doesn\'t seem to be one. Follow it anyway?' % (self.inpl.aslink(), pl.aslink()), ['Yes', 'No'], ['y', 'N'], 'N') | def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
choice = wikipedia.input('WARNING: %s doesn\'t seem to be a disambiguation page, but %s is one. Follow it anyway? [y|N]' % (self.inpl.aslink(), pl.aslink())) | choice = wikipedia.inputChoice('WARNING: %s doesn\'t seem to be a disambiguation page, but %s is one. Follow it anyway?' % (self.inpl.aslink(), pl.aslink()), ['Yes', 'No'], ['y', 'N'], 'N') | def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
choice = wikipedia.input('WARNING: %s is in namespace %i, but %s is in namespace %i. Follow it anyway? [y|N]' % (self.inpl.aslink(), self.inpl.namespace(), page2.aslink(), page2.namespace())) | choice = wikipedia.inputChoice('WARNING: %s is in namespace %i, but %s is in namespace %i. Follow it anyway?' % (self.inpl.aslink(), self.inpl.namespace(), page2.aslink(), page2.namespace()), ['Yes', 'No'], ['y', 'N'], 'N') | def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
answer = wikipedia.input(u"What should be done [(a)ccept, (r)eject, (g)ive up, accept a(l)l] :") | answer = wikipedia.inputChoice(u'What should be done?', ['accept', 'reject', 'give up', 'accept all'], ['a', 'r', 'G', 'l'], 'G') | def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the site as key. # Each value will be a list. mysite = wikipedia.getSite() new = {} for pl in self.done.keys(): site = pl.site() if site == mysite and pl.exists() and not pl.isRedirectPage(): if pl != self.i... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
answer = wikipedia.input(u'Submit? [y|N]') | answer = wikipedia.inputChoice(u'Submit?', ['Yes', 'No'], ['y', 'N'], 'N') | def finish(self, sa = None): """Round up the subject, making any necessary changes. This method should be called exactly once after the todo list has gone empty. | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
start = wikipedia.input(u'Which page to start from: ', wikipedia.myencoding()) | start = wikipedia.input(u'Which page to start from: ') | def readWarnfile(filename, sa): import warnfile reader = warnfile.WarnfileReader(filename) # we won't use removeHints (hints, removeHints) = reader.getHints() for pagename in hints.iterkeys(): pl = wikipedia.Page(wikipedia.getSite(), pagename) # The WarnfileReader gives us a list of pagelinks, but titletranslate.py exp... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
inname = wikipedia.input(u'Which page to check: ', wikipedia.myencoding()) | inname = wikipedia.input(u'Which page to check: ') | def readWarnfile(filename, sa): import warnfile reader = warnfile.WarnfileReader(filename) # we won't use removeHints (hints, removeHints) = reader.getHints() for pagename in hints.iterkeys(): pl = wikipedia.Page(wikipedia.getSite(), pagename) # The WarnfileReader gives us a list of pagelinks, but titletranslate.py exp... | 6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/6b8ea9c735b1ac81d36c149cb1ad028fdb959a3b/interwiki.py |
print repr(s),repr(s2[:100]) | def treesearch(pl): arr = {pl:None} # First make one step based on the language itself try: n = treestep(arr, pl, abort_on_redirect = 1) except wikipedia.IsRedirectPage: print "Is redirect page" return if n == 0 and not arr[pl]: print "Mother doesn't exist" return if untranslated: if len(arr) > 1: print "Already has tr... | 087ecda76b1e9e6ceec82fea33c371d36ef6b25b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/087ecda76b1e9e6ceec82fea33c371d36ef6b25b/treelang.py | |
'ru' : [u'disambig'], | 'ru' : [u'disambig',u'значения'], | def __init__(self): | 1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f/family.py |
namespaces.append(namespace_title.lower()) | if namespace_title != namespace_title.lower(): namespaces.append(namespace_title.lower()) | def category_namespaces(self, code): namespaces = [] namespace_title = self.namespace(code, 14) namespaces.append(namespace_title) namespaces.append(namespace_title.lower()) default_namespace_title = self.namespace('_default', 14) if namespace_title != default_namespace_title: namespaces.append(default_namespace_title)... | 1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f/family.py |
namespaces.append(default_namespace_title.lower()) | if default_namespace_title != default_namespace_title.lower(): namespaces.append(default_namespace_title.lower()) | def category_namespaces(self, code): namespaces = [] namespace_title = self.namespace(code, 14) namespaces.append(namespace_title) namespaces.append(namespace_title.lower()) default_namespace_title = self.namespace('_default', 14) if namespace_title != default_namespace_title: namespaces.append(default_namespace_title)... | 1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1034e8d4252f91b7ba7a70d4e8d89ce355b56f7f/family.py |
for original_cat in article.categories(): wikipedia.output('* %s' % original_cat.linkname()) | for cat in article.categories(): wikipedia.output('* %s' % cat.linkname()) | def move_to_category(article, original_cat, current_cat): print wikipedia.output(u'Treating page %s, currently in category %s' % (article.linkname(), current_cat.linkname())) subcatlist = get_subcats(current_cat) supercatlist = get_supercats(current_cat) print if len(subcatlist) == 0: print 'This category has no subcat... | cf94e8b648662c36d52b8f41e5570a4425de3dbb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/cf94e8b648662c36d52b8f41e5570a4425de3dbb/category.py |
except UnicodeEncodeError, arg: return False, u'Non-ASCII Characters in URL: %s' % arg | def check(self, useHEAD = True): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect(useHEAD = useHEAD) except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % ar... | b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98/weblinkchecker.py | |
notInside = '\]\s<>}"' | def checkLinksIn(self, page): try: text = page.get() except wikipedia.NoPage: wikipedia.output(u'%s does not exist.' % page.title()) return # RFC 2396 says that URLs may only contain certain characters. # For this regex we also accept non-allowed characters, so that the bot # will later show these links as broken ('Non... | b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98/weblinkchecker.py | |
linkR = re.compile(r'http[s]?://[^\]\s<>}"]*?[^\]\s\)\.:;,<>}\|"](?=\'\')|http[s]?://[^\]\s<>}"]*[^\]\s\)\.:;,<>}"\|]') | linkR = re.compile(r'http[s]?://[^' + notInside + ']*?[^' + notAtEnd + '](?=[' + notAtEnd+ ']*\'\')|http[s]?://[^' + notInside + ']*[^' + notAtEnd + ']') | def checkLinksIn(self, page): try: text = page.get() except wikipedia.NoPage: wikipedia.output(u'%s does not exist.' % page.title()) return # RFC 2396 says that URLs may only contain certain characters. # For this regex we also accept non-allowed characters, so that the bot # will later show these links as broken ('Non... | b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b147e3c1d7a419a238bb0b5cb764ebf8f0d53b98/weblinkchecker.py |
elif not xpl in shouldlink: | if not xpl in shouldlink: | def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" for site in new.keys(): pl = new[site] if not unequal.bigger(self.inpl, pl) and not pl.hashname(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl... | c97af85724f264d02db3991d82a92cea7b305742 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c97af85724f264d02db3991d82a92cea7b305742/interwiki.py |
'af': u'%d v.Chr.', | 'af':u'%d v.C.', | def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.site.lang]) % d, site = self.site) | 2f8392c560135a8fa55641f181fd3a11ca38d1c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2f8392c560135a8fa55641f181fd3a11ca38d1c1/date.py |
'he': u'%d & | 'he':u'%d לפנה"ס', | def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.site.lang]) % d, site = self.site) | 2f8392c560135a8fa55641f181fd3a11ca38d1c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2f8392c560135a8fa55641f181fd3a11ca38d1c1/date.py |
'ja':'%d& 'zh':'%d& 'ko':'%d& 'minnan':'%d nî', 'ur':'%d& | 'ja':u'%d年', 'zh':u'%d年', 'ko':u'%d년', 'minnan':u'%d nî', 'ur':u'%dسبم' | def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.site.lang]) % d, site = self.site) | 2f8392c560135a8fa55641f181fd3a11ca38d1c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2f8392c560135a8fa55641f181fd3a11ca38d1c1/date.py |
self.todo = [] | self.todo = {} | def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ... | 29afaf2cc9ba765ef5197124c11af690b0ab38bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/29afaf2cc9ba765ef5197124c11af690b0ab38bb/interwiki.py |
if globalvar.bell: sys.stdout.write('\07') | def assemble(self, returnonquestion = False, askall = False): if globalvar.bell: sys.stdout.write('\07') new = {} for pl in self.done.keys(): code = pl.code() if code == wikipedia.mylang and pl.exists() and not pl.isRedirectPage() and not pl.isEmpty(): if pl != self.inpl: if returnonquestion: return None self.problem('... | ec0dc3a3f66f502a390756317a7397732ab0ca28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ec0dc3a3f66f502a390756317a7397732ab0ca28/interwiki.py | |
newfn = wikipedia.input(u'Better name:') | while True: newfn = wikipedia.input(u'Better name:') if '/' in newfn: print "Invalid character: '/'. Please try again" else: break | def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py |
print wikipedia.output(description) | wikipedia.output(description) | def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py |
formdata = {} formdata["wpUploadDescription"] = description if wikipedia.version() >= '1.4': formdata["wpUploadCopyStatus"] = wikipedia.input(u"Copyright status: ") formdata["wpUploadSource"] = wikipedia.input(u"Source of image: ") else: formdata["wpUploadAffirm"] = "1" formdata["wpUpload"] = "upload bestand" formdata[... | def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py | |
try: description = description.encode(wikipedia.myencoding()) except UnicodeEncodeError: description = wikipedia.UnicodeToAsciiHtml(description).encode(wikipedia.myencoding()) except UnicodeDecodeError: description = wikipedia.UnicodeToAsciiHtml(description).encode(wikipedia.myencoding()) | for key in formdata: assert isinstance(key, basestring), "ERROR: %s is not a string but %s" % (key, type(key)) try: formdata[key] = formdata[key].encode(wikipedia.myencoding()) except (UnicodeEncodeError, UnicodeDecodeError): formdata[key] = wikipedia.UnicodeToAsciiHtml(formdata[key]).encode(wikipedia.myencoding()) | def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py |
def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py | ||
(('wpUploadDescription', description), ('wpUploadAffirm', '1'), ('wpIgnoreWarning', '1'), ('wpUpload','upload bestand')), | formdata.items(), | def get_image(original_url, source_wiki, original_description, keep=False, debug=False): # work with a copy of argument variables so we can reuse the # original ones if the upload fails fn = original_url description = original_description # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = fi... | 7b9e6112132fb091773fa3c9270d22690c72ab22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7b9e6112132fb091773fa3c9270d22690c72ab22/lib_images.py |
print repr(data) | def getData(self): import httplib try: addr = self.addr%special[self.code] except KeyError: print "BUG: Can not find name of Special in %s:" % self.code raise pagenames = u'\r\n'.join([x.hashfreeLinkname() for x in self.pages]) pagenames = forCode(pagenames, self.code) data = urlencode(( ('action', 'submit'), ('pages',... | 30adc0573192a7da818e75d22aad0c039225aea8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/30adc0573192a7da818e75d22aad0c039225aea8/wikipedia.py | |
def check(self): | def check(self, useHEAD = True): | def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py |
wasRedirected = self.resolveRedirect() | wasRedirected = self.resolveRedirect(useHEAD = useHEAD) | def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py |
def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py | ||
return False, u'HTTP Redirect Loop: %s' % ' -> '.join(self.redirectChain + [self.url]) | if useHEAD: redirChecker = LinkChecker(self.redirectChain[0]) return redirChecker.check(useHEAD = False) else: return False, u'HTTP Redirect Loop: %s' % ' -> '.join(self.redirectChain + [self.url]) | def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py |
return False, u'Long Chain of Redirects: %s' % ' -> '.join(self.redirectChain + [self.url]) | if useHEAD: redirChecker = LinkChecker(self.redirectChain[0]) return redirChecker.check(useHEAD = False) else: return False, u'Long Chain of Redirects: %s' % ' -> '.join(self.redirectChain + [self.url]) | def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py |
return redirChecker.check() | return redirChecker.check(useHEAD = useHEAD) | def check(self): """ Returns True and the server status message if the page is alive. Otherwise returns false """ try: wasRedirected = self.resolveRedirect() except httplib.error, arg: return False, u'HTTP Error: %s' % arg except socket.error, arg: return False, u'Socket Error: %s' % arg except UnicodeEncodeError, arg:... | 9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9b8b9cb44defccdc6e7b96ff34bbeacd4ebaf1a6/weblinkchecker.py |
cat_namespace = wikipedia.getSite().category_namespace() | cat_namespace = wikipedia.getSite().category_namespaces()[0] | def add_category(sort_by_last_name = False): ''' A robot to mass-add a category to a list of pages. ''' print "This bot has two modes: you can add a category link to all" print "pages mentioned in a List that is now in another wikipedia page" print "or you can add a category link to all pages that link to a" print "spe... | 84cc82cdafbaa3688f93585339ea6f61f02749e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/84cc82cdafbaa3688f93585339ea6f61f02749e0/category.py |
wikipedia.output(u"Current categories: %s" % cats) | wikipedia.output(u"Current categories:") for curpl in cats: wikipedia.output(u"* %s" % cat.aslink()) | def add_category(sort_by_last_name = False): ''' A robot to mass-add a category to a list of pages. ''' print "This bot has two modes: you can add a category link to all" print "pages mentioned in a List that is now in another wikipedia page" print "or you can add a category link to all pages that link to a" print "spe... | 84cc82cdafbaa3688f93585339ea6f61f02749e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/84cc82cdafbaa3688f93585339ea6f61f02749e0/category.py |
def treeview(cat, max_depth, current_depth = 0, parent = None): ''' Returns a multi-line string which contains a tree view of all subcategories of cat, up to level max_depth. Parameters: * cat - a CatLink which will be the tree's root * current_depth - the current level in the tree (for recursion) * parent - the CatLi... | 84cc82cdafbaa3688f93585339ea6f61f02749e0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/84cc82cdafbaa3688f93585339ea6f61f02749e0/category.py | ||
nn=wikipedia.url2link(wikipedia.link2url(old[code])) | nn=wikipedia.url2link(wikipedia.link2url(new[code])) | def compareLanguages(old,new): removing=[] adding=[] modifying=[] for code,name in old.iteritems(): if not new.has_key(code): removing.append(code) elif old[code]!=new[code]: oo=wikipedia.url2link(wikipedia.link2url(old[code])) nn=wikipedia.url2link(wikipedia.link2url(old[code])) if oo!=nn: modifying.append(code) for c... | 59f7c6407a69905bde42718cd2f9079d191f582a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/59f7c6407a69905bde42718cd2f9079d191f582a/treelang.py |
s=compareLanguages(old,new) if not s and only_if_status: | mods=compareLanguages(old,new) if not mods and only_if_status: | def treesearch(code,name): arr={(code,name):None} # First make one step based on the language itself try: n=treestep(arr,code,name,abort_on_redirect=1) except wikipedia.IsRedirectPage: print "Is redirect page" return if n==0 and not arr[code,name]: print "Mother doesn't exist" return # Then add translations if we survi... | 59f7c6407a69905bde42718cd2f9079d191f582a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/59f7c6407a69905bde42718cd2f9079d191f582a/treelang.py |
print s | print mods | def treesearch(code,name): arr={(code,name):None} # First make one step based on the language itself try: n=treestep(arr,code,name,abort_on_redirect=1) except wikipedia.IsRedirectPage: print "Is redirect page" return if n==0 and not arr[code,name]: print "Mother doesn't exist" return # Then add translations if we survi... | 59f7c6407a69905bde42718cd2f9079d191f582a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/59f7c6407a69905bde42718cd2f9079d191f582a/treelang.py |
status,reason,data=wikipedia.putPage(mylang,inname,newtext) | status,reason,data=wikipedia.putPage(mylang,inname,newtext,comment='Rob Hooft: robot '+mods) | def treesearch(code,name): arr={(code,name):None} # First make one step based on the language itself try: n=treestep(arr,code,name,abort_on_redirect=1) except wikipedia.IsRedirectPage: print "Is redirect page" return if n==0 and not arr[code,name]: print "Mother doesn't exist" return # Then add translations if we survi... | 59f7c6407a69905bde42718cd2f9079d191f582a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/59f7c6407a69905bde42718cd2f9079d191f582a/treelang.py |
Page(self, "Non-existing page").get(force = True, sysop = sysop) | Page(self, "Wikipedia:Sandbox").get(force = True, sysop = sysop) | def getToken(self, getalways = True, getagain = False, sysop = False): if getagain or (getalways and ((sysop and not self._sysoptoken) or (not sysop and not self._token))): output(u"Getting page to get a token.") try: Page(self, "Non-existing page").get(force = True, sysop = sysop) except Error: pass if sysop: if not s... | 4551cca19b5746871d4d8311a168b66619b0e8f4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4551cca19b5746871d4d8311a168b66619b0e8f4/wikipedia.py |
sysop = (self.editRestriction is not None) | sysop = (not self.editRestriction) | def put(self, newtext, comment=None, watchArticle = None, minorEdit = True): """Replace the new page with the contents of the first argument. The second argument is a string that is to be used as the summary for the modification | 0b9ac57db7ef582d3cad69c459c53e3093318173 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/0b9ac57db7ef582d3cad69c459c53e3093318173/wikipedia.py |
catlib.change_category(article, original_cat, current_cat.titleWithoutNamespace()) | catlib.change_category(article, original_cat, current_cat) | def move_to_category(self, article, original_cat, current_cat): ''' Given an article which is in category original_cat, ask the user if it should be moved to one of original_cat's subcategories. Recursively run through subcategories' subcategories. NOTE: current_cat is only used for internal recursion. You should alway... | 61f84eee8b9e9337e4cf5300bcebea9707ca9a56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61f84eee8b9e9337e4cf5300bcebea9707ca9a56/category.py |
catlink = catlib.Category(wikipedia.getSite(), 'Category:' + self.catTitle) | cat = catlib.Category(wikipedia.getSite(), 'Category:' + self.catTitle) | def run(self): catlink = catlib.Category(wikipedia.getSite(), 'Category:' + self.catTitle) # get edit summary message wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg_change) % self.catTitle) articles = catlink.articles(recurse = 0) if len(articles) == 0: wikipedia.output(u'There are no articles in ca... | 61f84eee8b9e9337e4cf5300bcebea9707ca9a56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61f84eee8b9e9337e4cf5300bcebea9707ca9a56/category.py |
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg_change) % self.catTitle) articles = catlink.articles(recurse = 0) | wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg_change) % cat.title()) articles = cat.articles(recurse = 0) | def run(self): catlink = catlib.Category(wikipedia.getSite(), 'Category:' + self.catTitle) # get edit summary message wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg_change) % self.catTitle) articles = catlink.articles(recurse = 0) if len(articles) == 0: wikipedia.output(u'There are no articles in ca... | 61f84eee8b9e9337e4cf5300bcebea9707ca9a56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61f84eee8b9e9337e4cf5300bcebea9707ca9a56/category.py |
self.move_to_category(article, catlink, catlink) | self.move_to_category(article, cat, cat) | def run(self): catlink = catlib.Category(wikipedia.getSite(), 'Category:' + self.catTitle) # get edit summary message wikipedia.setAction(wikipedia.translate(wikipedia.getSite(), msg_change) % self.catTitle) articles = catlink.articles(recurse = 0) if len(articles) == 0: wikipedia.output(u'There are no articles in ca... | 61f84eee8b9e9337e4cf5300bcebea9707ca9a56 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61f84eee8b9e9337e4cf5300bcebea9707ca9a56/category.py |
}, | } | def __init__(self): family.Family.__init__(self) self.name = 'wikiquote' self.langs = { 'minnan':'zh-min-nan.wikiquote.org', 'nb':'no.wikiquote.org', 'zh-cn':'zh.wikiquote.org', 'zh-tw':'zh.wikiquote.org' } for lang in self.knownlanguages: self.langs[lang] = lang+'.wikiquote.org' | ef3d8b2ad799c38dc986af43acfdc6fa859c053f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ef3d8b2ad799c38dc986af43acfdc6fa859c053f/wikiquote_family.py |
data = response.read() print response.status, response.reason | returned_html = response.read() | def post_multipart(host, selector, fields, files, cookies): """ Post fields and files to an http host as multipart/form-data. fields is a sequence of (name, value) elements for regular form fields. files is a sequence of (name, filename, value) elements for data to be uploaded as files Return the server's response page... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
return data | return response, returned_html | def post_multipart(host, selector, fields, files, cookies): """ Post fields and files to an http host as multipart/form-data. fields is a sequence of (name, value) elements for regular form fields. files is a sequence of (name, filename, value) elements for data to be uploaded as files Return the server's response page... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
if not self.urlEncoding: self.url = self.url.encode('utf-8') self.url = urllib.quote(self.url) self.urlEncoding = 'utf-8' | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py | |
uo = wikipedia.MyURLopener() file = uo.open(self.url) | if '://' in self.url: uo = wikipedia.MyURLopener() file = uo.open(self.url) else: file = open(self.url) wikipedia.output('Reading file %s' % self.url) | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
filename = filename.encode(self.targetSite.encoding()) | encodedFilename = filename.encode(self.targetSite.encoding()) | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
returned_html = post_multipart(self.targetSite.hostname(), | response, returned_html = post_multipart(self.targetSite.hostname(), | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
(('wpUploadFile', filename, contents),), | (('wpUploadFile', encodedFilename, contents),), | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
success_msg = mediawiki_messages.get('successfulupload', site = self.targetSite) success_msgR = re.compile(re.escape(success_msg)) if success_msgR.search(returned_html): | if response.status == 302: | def upload_image(self, debug=False): """Gets the image at URL self.url, and uploads it to the target wiki. Returns the filename which was used to upload the image. If the upload fails, the user is asked whether to try again or not. If the user chooses not to retry, returns null. """ if not self.urlEncoding: # URL is a ... | 9dec94ac7c50a9fcf171b9372a004229a1876b7e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9dec94ac7c50a9fcf171b9372a004229a1876b7e/upload.py |
if not (trailingChars or label): | if not trailingChars: | def cleanUpLinks(self, text): trailR = re.compile(self.site.linktrail()) # The regular expression which finds links. Results consist of four groups: # group title is the target page title, that is, everything before | or ]. # group section is the page section. It'll include the # to make life easier for us. # group lab... | d217bdeeccb00cabf75bb67506ea60c61365582c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d217bdeeccb00cabf75bb67506ea60c61365582c/cosmetic_changes.py |
else: output( u"DBG>>> Strange title: %s:%s" % (site.lang, title) ) | def __init__(self, site, title, insite = None, tosite = None, defaultNamespace = 0): """ Constructor. Normally called with two arguments: Parameters: 1) The wikimedia site on which the page resides 2) The title of the page as a unicode string | 2a38b30275da1487e3b0b2bde42dec9735cec643 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2a38b30275da1487e3b0b2bde42dec9735cec643/wikipedia.py | |
Rcomment = re.compile("<!--.*?-->", re.M) while True: comment = Rcomment.search(thistxt) if not comment: break thistxt = thistxt[:comment.start()] + thistxt[comment.end():] | thistxt = re.sub("(?ms)<!--.*?-->", "", thistxt) | def linkedPages(self): """Gives the normal (not-interwiki, non-category) pages the page links to, as a list of Page objects """ result = [] try: thistxt = removeLanguageLinks(self.get()) except NoPage: return [] except IsRedirectPage: raise thistxt = removeCategoryLinks(thistxt, self.site()) | 2a38b30275da1487e3b0b2bde42dec9735cec643 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2a38b30275da1487e3b0b2bde42dec9735cec643/wikipedia.py |
Rnowiki = re.compile("<nowiki>.*?</nowiki>", re.M) while True: nowiki = Rnowiki.search(thistxt) if not nowiki: break thistxt = thistxt[:nowiki.start()] + thistxt[nowiki.end():] | thistxt = re.sub("(?ms)<nowiki>.*?</nowiki>", "", thistxt) | def linkedPages(self): """Gives the normal (not-interwiki, non-category) pages the page links to, as a list of Page objects """ result = [] try: thistxt = removeLanguageLinks(self.get()) except NoPage: return [] except IsRedirectPage: raise thistxt = removeCategoryLinks(thistxt, self.site()) | 2a38b30275da1487e3b0b2bde42dec9735cec643 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2a38b30275da1487e3b0b2bde42dec9735cec643/wikipedia.py |
result.append(page) | if page.sectionFreeTitle(): result.append(page) | def linkedPages(self): """Gives the normal (not-interwiki, non-category) pages the page links to, as a list of Page objects """ result = [] try: thistxt = removeLanguageLinks(self.get()) except NoPage: return [] except IsRedirectPage: raise thistxt = removeCategoryLinks(thistxt, self.site()) | 2a38b30275da1487e3b0b2bde42dec9735cec643 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2a38b30275da1487e3b0b2bde42dec9735cec643/wikipedia.py |
for i in range(len(title)): title[i] = title[i].strip() self._title = ':'.join(title) | self._title = ':'.join(title).strip() | def __init__(self, site, title = None, insite = None, tosite = None): """ Constructor. Normally called with two arguments: Parameters: 1) The wikimedia site on which the page resides 2) The title of the page as a unicode string The argument insite can be specified to help decode the name; it is the wikimedia site wher... | fdb5634bb000272114a98f989f9db565183ab86f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/fdb5634bb000272114a98f989f9db565183ab86f/wikipedia.py |
iend = txt.index('<div id="catlinks">') | iend = txt.index('<div class="printfooter">') | def _make_catlist(self, recurse = False, purge = False, site = None): """Make a list of all articles and categories that are in this category. If recurse is set to True, articles and subcategories of any subcategories are also retrieved. | 5225f8cd405243959a9fbc1d926fc3027ebec104 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/5225f8cd405243959a9fbc1d926fc3027ebec104/catlib.py |
except ValueError: iend = txt.index('<div class="printfooter">') | def _make_catlist(self, recurse = False, purge = False, site = None): """Make a list of all articles and categories that are in this category. If recurse is set to True, articles and subcategories of any subcategories are also retrieved. | 5225f8cd405243959a9fbc1d926fc3027ebec104 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/5225f8cd405243959a9fbc1d926fc3027ebec104/catlib.py | |
def dh_singVal( value, match ): """This function helps with matching a single value. formats['CurrEvents']['en'](0) => u'Current Events' formats['CurrEvents']['en'](u'Current Events') => 0""" if type(value) is int: if value == 0: return match else: raise ValueError("unknown value %d" % value) else: if value == match: r... | eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py | ||
return formats['MonthName'][lang](ind) | return formats['MonthName'][lang](ind) | def monthName(lang,ind): return formats['MonthName'][lang](ind) | eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py |
'af' : lambda v: slh( v, [u'Januarie', u'Februarie', u'Maart', u'April', u'Mei', u'Junie', u'Julie', u'Augustus', u'September', u'Oktober', u'November', u'Desember'] ), 'als': lambda v: slh( v, [u'Januar', u'Februar', u'März', u'April', u'Mai', u'Juni', u'Juli', u'August', u'September', u'Oktober', u'November... | 'af' : lambda v: slh( v, [u"Januarie", u"Februarie", u"Maart", u"April", u"Mei", u"Junie", u"Julie", u"Augustus", u"September", u"Oktober", u"November", u"Desember"] ), 'als': lambda v: slh( v, [u"Januar", u"Februar", u"März", u"April", u"Mai", u"Juni", u"Juli", u"August", u"September", u"Oktober", u"November... | def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo... | eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py |
'eo' : lambda v: slh( v, [u'Januaro', u'Februaro', u'Marto', u'Aprilo', u'Majo', u'Junio', u'Julio', u'Aŭgusto', u'Septembro', u'Oktobro', u'Novembro', u'Decembro'] ), 'es' : lambda v: slh( v, [u'Enero', u'Febrero', u'Marzo', u'Abril', u'Mayo', u'Junio', u'Julio', u'Agosto', u'Septiembre', u'Octubre', u'Novie... | 'eo' : lambda v: slh( v, [u"Januaro", u"Februaro", u"Marto", u"Aprilo", u"Majo", u"Junio", u"Julio", u"Aŭgusto", u"Septembro", u"Oktobro", u"Novembro", u"Decembro"] ), 'es' : lambda v: slh( v, [u"enero", u"febrero", u"marzo", u"abril", u"mayo", u"junio", u"julio", u"agosto", u"septiembre", u"octubre", u"novie... | def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo... | eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py |
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo... | eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.