bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
36,000
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
36,001
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
def retrieve_broken_redirects(source): if source == None: # retrieve information from the live wiki's maintenance page host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.maintenance_address(wikipedia.mylang, 'brokenredirects', default_limit = False) print ...
36,002
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except (wiki...
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except wikip...
36,003
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except (wiki...
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except (wiki...
36,004
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except (wiki...
def delete_broken_redirects(source): # get reason for deletion text reason = reason_broken[wikipedia.chooselang(wikipedia.mylang, reason_broken)] for redir_name in retrieve_broken_redirects(source): redir_page = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target_page = redir_page.getRedirectTo() except (wiki...
36,005
def fix_double_redirects(source): for redir_name in retrieve_double_redirects(source): redir = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target = str(redir.getRedirectTo()) second_redir = wikipedia.PageLink(wikipedia.mylang, target) second_target = str(second_redir.getRedirectTo()) except (wikipedia.IsNotRe...
def fix_double_redirects(source): for redir_name in retrieve_double_redirects(source): redir = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target = str(redir.getRedirectTo()) second_redir = wikipedia.PageLink(wikipedia.mylang, target) second_target = str(second_redir.getRedirectTo()) except (wikipedia.IsNotRe...
36,006
def fix_double_redirects(source): for redir_name in retrieve_double_redirects(source): redir = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target = str(redir.getRedirectTo()) second_redir = wikipedia.PageLink(wikipedia.mylang, target) second_target = str(second_redir.getRedirectTo()) except (wikipedia.IsNotRe...
def fix_double_redirects(source): for redir_name in retrieve_double_redirects(source): redir = wikipedia.PageLink(wikipedia.mylang, redir_name) try: target = str(redir.getRedirectTo()) second_redir = wikipedia.PageLink(wikipedia.mylang, target) second_target = str(second_redir.getRedirectTo()) except (wikipedia.IsNotRe...
36,007
def makepath(path): """ creates missing directories for the given path and returns a normalized absolute version of the path. - if the given path already exists in the filesystem the filesystem is not modified. - otherwise makepath creates directories along the given path using the dirname() of the path. You may appe...
def makepath(path): """ creates missing directories for the given path and returns a normalized absolute version of the path. - if the given path already exists in the filesystem the filesystem is not modified. - otherwise makepath creates directories along the given path using the dirname() of the path. You may appe...
36,008
def showDiff(oldtext, newtext): """ Prints a string showing the differences between oldtext and newtext. The differences are highlighted (only on Unix systems) to show which changes were made. """ # For information on difflib, see http://pydoc.org/2.3/difflib.html color = { '+': 10, # green '-': 12 # red } diff = '' c...
def showDiff(oldtext, newtext): """ Prints a string showing the differences between oldtext and newtext. The differences are highlighted (only on Unix systems) to show which changes were made. """ # For information on difflib, see http://pydoc.org/2.3/difflib.html color = { '+': 10, # green '-': 12 # red } diff = '' c...
36,009
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
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
36,010
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
36,011
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False, throttle = True): """ Get the contents of page 'name' from the 'site' wiki Do not use this directly; for 99% of the possible ideas you can use the Page object instead. Arguments: site - the wiki site name ...
36,012
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...
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...
36,013
def get_redirects_from_dump(sqlfilename): ''' Loads a local sql dump file, looks at all pages which have the redirect flag set, and finds out where they're pointing at. Returns a dictionary where the redirect names are the keys and the redirect targets are the values. NOTE: if the redirect isn't in the main namespace, ...
def get_redirects_from_dump(sqlfilename): ''' Loads a local sql dump file, looks at all pages which have the redirect flag set, and finds out where they're pointing at. Returns a dictionary where the redirect names are the keys and the redirect targets are the values. NOTE: if the redirect isn't in the main namespace, ...
36,014
def fix_double_redirects(source): mysite = wikipedia.getSite() for redir_name in retrieve_double_redirects(source): print '' redir = wikipedia.PageLink(mysite, redir_name) try: target = redir.getRedirectTo() except wikipedia.IsNotRedirectPage: wikipedia.output(u'%s is not a redirect.' % redir.linkname()) except wikiped...
def fix_double_redirects(source): mysite = wikipedia.getSite() for redir_name in retrieve_double_redirects(source): print '' redir = wikipedia.PageLink(mysite, redir_name) try: target = redir.getRedirectTo() except wikipedia.IsNotRedirectPage: wikipedia.output(u'%s is not a redirect.' % redir.linkname()) except wikiped...
36,015
def main(): start = u'!' pageTitle = [] for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'weblinkchecker') if arg: if arg.startswith('-start:'): start = arg[7:] else: pageTitle.append(arg) if pageTitle == []: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikiped...
def main(): start = u'!' pageTitle = [] for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'weblinkchecker') if arg: if arg.startswith('-start:'): start = arg[7:] else: pageTitle.append(arg) if pageTitle == []: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikiped...
36,016
def main(): start = u'!' pageTitle = [] for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'weblinkchecker') if arg: if arg.startswith('-start:'): start = arg[7:] else: pageTitle.append(arg) if pageTitle == []: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikiped...
def main(): start = u'!' pageTitle = [] for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'weblinkchecker') if arg: if arg.startswith('-start:'): start = arg[7:] else: pageTitle.append(arg) if pageTitle == []: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikiped...
36,017
def compareLanguages(old, new): removing = [] adding = [] modifying = [] mysite = wikipedia.getSite() for site in old.keys(): if old[site] != new[site]: modifying.append(site) for site2 in new.keys(): if site2 not in old: adding.append(site2) s = "" if adding: s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[0]...
def compareLanguages(old, new): removing = [] adding = [] modifying = [] mysite = wikipedia.getSite() for site in old.keys(): if site not in new: removing.append(site) elif old[site] != new[site]: modifying.append(site) for site2 in new.keys(): if site2 not in old: adding.append(site2) s = "" if adding: s = s + " %s:"...
36,018
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...
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 # wi...
36,019
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...
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...
36,020
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False xmlfilename = None text...
36,021
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,022
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,023
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,024
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,025
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,026
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
def main(): quietMode = False # use -quiet to get less output # if the -file argument is used, page titles are stored in this array. # otherwise it will only contain one page. articles = [] # if -file is not used, this temporary array is used to read the page title. page_title = [] debug = False source = None for arg i...
36,027
def extractImages(data): """ takes a string with the complete HTML-file and returns the article which is contained in <div id='article'> and the pagestats which contain information on last change """ images = [] s = StringIO.StringIO(data) rImage = re.compile('.*<a href="/wiki/.*?:(.*?)".*?[\n]*?.*?class="internal"'...
def extractImages(data): """ takes a string with the complete HTML-file and returns the article which is contained in <div id='article'> and the pagestats which contain information on last change """ images = [] rImage = re.compile('<a href=[\r\n]*?"/wiki/.*?:(.*?)".*?[\r\n]*?.*?class=[\r\n]*?"image"', re.MULTILINE) ...
36,028
def extractImages(data): """ takes a string with the complete HTML-file and returns the article which is contained in <div id='article'> and the pagestats which contain information on last change """ images = [] s = StringIO.StringIO(data) rImage = re.compile('.*<a href="/wiki/.*?:(.*?)".*?[\n]*?.*?class="internal"'...
def extractImages(data): """ takes a string with the complete HTML-file and returns the article which is contained in <div id='article'> and the pagestats which contain information on last change """ images = [] s = StringIO.StringIO(data) rImage = re.compile('.*<a href="/wiki/.*?:(.*?)".*?[\n]*?.*?class="internal"'...
36,029
def main(): mysite = wikipedia.getSite() sa = [] output_directory = "" save_images = False overwrite_images = False overwrite_articles = False for arg in sys.argv[1:]: if arg.startswith("-lang:"): lang = arg[6:] elif arg.startswith("-file:"): f=open(arg[6:], 'r') R=re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for lin...
def main(): mysite = wikipedia.getSite() sa = [] output_directory = "" save_images = False overwrite_images = False overwrite_articles = False for arg in sys.argv[1:]: if arg.startswith("-lang:"): lang = arg[6:] elif arg.startswith("-file:"): f=open(arg[6:], 'r') R=re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for lin...
36,030
def main(): mysite = wikipedia.getSite() sa = [] output_directory = "" save_images = False overwrite_images = False overwrite_articles = False for arg in sys.argv[1:]: if arg.startswith("-lang:"): lang = arg[6:] elif arg.startswith("-file:"): f=open(arg[6:], 'r') R=re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for lin...
def main(): mysite = wikipedia.getSite() sa = [] output_directory = "" save_images = False overwrite_images = False overwrite_articles = False for arg in sys.argv[1:]: if arg.startswith("-lang:"): lang = arg[6:] elif arg.startswith("-file:"): f=open(arg[6:], 'r') R=re.compile(r'.*\[\[([^\]]*)\]\].*') m = False for lin...
36,031
def urlname(self): """The name of the page this Page refers to, in a form suitable for the URL of the page.""" return urllib.quote(self.title())
def urlname(self): """The name of the page this Page refers to, in a form suitable for the URL of the page.""" return urllib.quote(self.title())
36,032
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
36,033
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
36,034
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeTitle()) == pl: if not hasattr(pl2,'_contents') and not hasattr(pl2,'_getexception'): break else: print repr(title) print repr(pl) print repr(self.pages) print "BUG: page not found in list"
36,035
def putPage(site, name, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, token = None, gettoken = False): """Upload 'text' on page 'name' to the 'site' wiki. Use of this routine can normally be avoided; use Page.put instead. """ safetuple = () # safetuple keeps the old value, but only if w...
def putPage(site, name, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, token = None, gettoken = False): """Upload 'text' on page 'name' to the 'site' wiki. Use of this routine can normally be avoided; use Page.put instead. """ safetuple = () # safetuple keeps the old value, but only if w...
36,036
def run(self): for page in self.generator: if self.interwiki: imagelist = [] for linkedPage in page.interwiki(): imagelist += linkedPage.imagelinks(followRedirects = True) elif page.isImage(): imagelist = [page] else: imagelist = page.imagelinks(followRedirects = True)
def run(self): for page in self.generator: if self.interwiki: imagelist = [] for linkedPage in page.interwiki(): imagelist += linkedPage.imagelinks(followRedirects = True) elif page.isImage(): imagelist = [page] else: imagelist = page.imagelinks(followRedirects = True)
36,037
def run(self): for page in self.generator: if self.interwiki: imagelist = [] for linkedPage in page.interwiki(): imagelist += linkedPage.imagelinks(followRedirects = True) elif page.isImage(): imagelist = [page] else: imagelist = page.imagelinks(followRedirects = True)
def run(self): for page in self.generator: if self.interwiki: imagelist = [] for linkedPage in page.interwiki(): imagelist += linkedPage.imagelinks(followRedirects = True) elif page.isImage(): imagelist = [page] else: imagelist = page.imagelinks(followRedirects = True)
36,038
def getReferences(self): refs = self.disambPl.getReferences(follow_redirects = False) wikipedia.output(u"Found %d references." % len(refs)) # Remove ignorables if ignore_title.has_key(self.disambPl.site().lang): for ig in ignore_title[self.disambPl.site().lang]: for i in range(len(refs)): if re.match(ig, refs[i].linkna...
def getReferences(self): refs = self.disambPl.getReferences(follow_redirects = False) wikipedia.output(u"Found %d references." % len(refs)) # Remove ignorables if ignore_title.has_key(self.disambPl.site().lang): for ig in ignore_title[self.disambPl.site().lang]: for i in range(len(refs)-1, -1, -1): if re.match(ig, refs...
36,039
def treat(refpl, thispl): try: reftxt=refpl.get() except wikipedia.IsRedirectPage: wikipedia.output('%s is a redirect to %s' % (refpl.linkname(), thispl.linkname())) choice = wikipedia.input('Do you want to work on pages linking to %s? [y|N]' % refpl.linkname()) if choice == 'y': for ref_redir in getReferences(refpl): ...
def treat(refpl, thispl): try: reftxt=refpl.get() except wikipedia.IsRedirectPage: wikipedia.output('%s is a redirect to %s' % (refpl.linkname(), thispl.linkname())) choice = wikipedia.input('Do you want to work on pages linking to %s? [y|N]' % refpl.linkname()) if choice == 'y': for ref_redir in getReferences(refpl): ...
36,040
def allpages(start = '%21%200'): """Iterate over all Wikipedia pages in the home language, starting at the given page.""" start = link2url(start, code = mylang) m=0 while 1: text = getPage(mylang, family.allpagesname(mylang, start), do_quote=0, do_edit=0) #print text if family.version(mylang)=="1.2": R = re.compile('/w...
def allpages(start = '%21%200'): """Iterate over all Wikipedia pages in the home language, starting at the given page.""" start = link2url(start, code = mylang) m=0 while 1: text = getPage(mylang, family.allpagesname(mylang, start), do_quote=0, do_edit=0) #print text if family.version(mylang)=="1.2": R = re.compile('/w...
36,041
def putPage(code, name, text, comment = None, watchArticle = '0', minorEdit = '1', newPage = '0'): """Upload 'text' on page 'name' to the 'code' language wikipedia. Use of this routine can normally be avoided; use PageLink.put instead. """ import httplib put_throttle() host = family.hostname(code) address = family.put_...
def putPage(code, name, text, comment = None, watchArticle = '0', minorEdit = '1', newPage = '0'): """Upload 'text' on page 'name' to the 'code' language wikipedia. Use of this routine can normally be avoided; use PageLink.put instead. """ import httplib put_throttle() host = family.hostname(code) address = family.put_...
36,042
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...
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...
36,043
def assemble(self): # No errors have been seen so far errorCount = 0 mysite = wikipedia.getSite() # Build up a dictionary of all pages found, with the site as key. # Each value will be a list of pages. new = {} for page in self.done: site = page.site() if site == mysite and page.exists() and not page.isRedirectPage(): ...
def assemble(self): # No errors have been seen so far errorCount = self.problemfound mysite = wikipedia.getSite() # Build up a dictionary of all pages found, with the site as key. # Each value will be a list of pages. new = {} for page in self.done: site = page.site() if site == mysite and page.exists() and not page.is...
36,044
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if host[-4:]=='.com': # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub('...
def getPage(code, name, do_edit=1, do_quote=1): """Get the contents of page 'name' from the 'code' language wikipedia""" host = langs[code] if host[-4:]=='.com': # Old algorithm name = re.sub('_', ' ', name) n=[] for x in name.split(): n.append(x[0].capitalize()+x[1:]) name='_'.join(n) #print name else: name = re.sub('...
36,045
def setLinkAlive(self, url): """ If the link was previously found dead, removes it from the .dat file and returns True, else returns False. """ if self.historyDict.has_key(url): self.semaphore.acquire() del self.historyDict[url] self.semaphore.release() return True else: return False
def setLinkAlive(self, url): """ If the link was previously found dead, removes it from the .dat file and returns True, else returns False. """ if self.historyDict.has_key(url): self.semaphore.acquire() try: del self.historyDict[url] except KeyError: pass self.semaphore.release() return True else: return False
36,046
def categories(self, withSortKeys = False): """ A list of categories that the article is in. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method. The return value is a list of Category objects, one for each of the category links in the page text.
def categories(self, withSortKeys = False): """ A list of categories that the article is in. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method. The return value is a list of Category objects, one for each of the category links in the page text.
36,047
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. ...
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. ...
36,048
def printLastLine(lastline, lastcolor): # highlight the minus red or the plus green if lastline != None: lastline = '\x1b[' + lastcolor + ';1m' + lastline[0] + '\x1b[0m' + lastline[1:] output(lastline)
def printLastLine(lastline, lastcolor): # highlight the minus red or the plus green if lastline != None: lastline = '\x1b[' + lastcolor + ';1m' + lastline[0] + '\x1b[0m' + lastline[1:] output(lastline)
36,049
def printLastLine(lastline, lastcolor): # highlight the minus red or the plus green if lastline != None: lastline = '\x1b[' + lastcolor + ';1m' + lastline[0] + '\x1b[0m' + lastline[1:] output(lastline)
def printLastLine(lastline, lastcolor): # highlight the minus red or the plus green if lastline != None: lastline = '\x1b[' + lastcolor + ';1m' + lastline[0] + '\x1b[0m' + lastline[1:] output(lastline)
36,050
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
36,051
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
36,052
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
36,053
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
36,054
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
def refresh_messages(site = None): site = site or wikipedia.getSite() # get 'all messages' special page's path path = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages = site.getUrl(path) print 'Parsing Med...
36,055
def main(): debug = False refresh_all = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'mediawiki_messages') if arg: if arg == '-debug': debug = True elif arg == '-all': refresh_all = True if refresh_all: refresh_all_messages() else: refresh_messages(wikipedia.getSite()) if debug: print "DBG> successfu...
defelif arg == '-home': refresh_messages() main():elif arg == '-home': refresh_messages() debugelif arg == '-home': refresh_messages() =elif arg == '-home': refresh_messages() Falseelif arg == '-home': refresh_messages() refresh_allelif arg == '-home': refresh_messages() =elif arg == '-home': refresh_messages() Falseel...
36,056
def __init__(self): family.Family.__init__(self) self.name = 'wikibooks' # Known wikibooks languages, given as a dictionary mapping the language code # to the hostname of the site hosting that wiktibooks. For human consumption, # the full name of the language is given behind each line as a comment self.langs = { 'minna...
def __init__(self): family.Family.__init__(self) self.name = 'wikibooks' # Known wikibooks languages, given as a dictionary mapping the language code # to the hostname of the site hosting that wiktibooks. For human consumption, # the full name of the language is given behind each line as a comment self.langs = { 'minna...
36,057
def get(self, force = False, get_redirect=False, throttle = True, sysop = False): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
def get(self, force = False, get_redirect=False, throttle = True, sysop = False): """The wiki-text of the page. This will retrieve the page if it has not been retrieved yet. This can raise the following exceptions that should be caught by the calling code:
36,058
def run(self): """ Starts the robot's action. """ # regular expression to find the original template. # {{vfd}} does the same thing as {{Vfd}}, so both will be found. # The old syntax, {{msg:vfd}}, will also be found. # The group 'parameters' will either match the parameters, or an # empty string if there are none.
def run(self): """ Starts the robot's action. """ # regular expression to find the original template. # {{vfd}} does the same thing as {{Vfd}}, so both will be found. # The old syntax, {{msg:vfd}}, will also be found. # The group 'parameters' will either match the parameters, or an # empty string if there are none.
36,059
def hashname(self): """The name of the subpage this PageLink refers to. Subpages are denominated by a # in the linkname(). If no subpage is referenced, None is returned.""" ln = self.linkname() ln = re.sub('&#', '&hash;', ln) if not '#' in ln: return None else: hn = ln[ln.find('#') + 1:] hn = re.sub('&hash;', '&#', hn)...
def def hashfreeLinkname(self): hn=self.hashname() if hn: return self.linkname()[:-len(hn)+1] else: return self.linkname() hashname(self): def hashfreeLinkname(self): hn=self.hashname() if hn: return self.linkname()[:-len(hn)+1] else: return self.linkname() """The def hashfreeLinkname(self): hn=self.hashname() if hn:...
36,060
def getRedirectTo(self):
def getRedirectTo(self):
36,061
def getRedirectTo(self):
def getRedirectTo(self):
36,062
def getRedirectTo(self):
defclass WikimediaXmlHandler(xml.sax.handler.ContentHandler): def setCallback(self, callback): self.callback = callback def startElement(self, name, attrs): self.destination = None if name == 'page': self.text=u'' self.title=u'' self.timestamp=u'' elif name == 'text': self.destination = 'text' elif name == 'title': se...
36,063
def getPage(code, name, do_edit = 1, do_quote = 1): """Get the contents of page 'name' from the 'code' language wikipedia Do not use this directly; use the PageLink object instead.""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n = [] for x in name.split(): n.append(x[0].cap...
def getPage(code, name, do_edit = 1, do_quote = 1): """Get the contents of page 'name' from the 'code' language wikipedia Do not use this directly; use the PageLink object instead.""" host = langs[code] if code in oldsoftware: # Old algorithm name = re.sub('_', ' ', name) n = [] for x in name.split(): n.append(x[0].cap...
36,064
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
36,065
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
36,066
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A list of 2-tu...
36,067
def forCode(text, code): """Prepare the unicode string 'text' for inclusion into a page for language 'code'. All of the characters in the text should be encodable, otherwise this will fail! This condition is normally met, except if you would copy text verbatim from an UTF-8 language into a iso-8859-1 language, and none...
def forCode(text, code): """Prepare the unicode string 'text' for inclusion into a page for language 'code'. All of the characters in the text should be encodable, otherwise this will fail! This condition is normally met, except if you would copy text verbatim from an UTF-8 language into a iso-8859-1 language, and none...
36,068
def url2unicode(percentname, language): x=urllib.unquote(percentname) #print "DBG> ",language,repr(percentname),repr(x) # Try utf-8 first. It almost cannot succeed by accident! for encoding in ('utf-8',)+code2encodings(language): try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l ...
def url2unicode(percentname, language): for c in percentname: if ord(c)>128: x=percentname break else: x=urllib.unquote(str(percentname)) #print "DBG> ",language,repr(percentname),repr(x) # Try utf-8 first. It almost cannot succeed by accident! for encoding in ('utf-8',)+code2encodings(language): try: encode_func, ...
36,069
def transferImage(self, sourceImagePage, debug=False): """Gets a wikilink to an image, downloads it and its description, and uploads it to another wikipedia. Returns the filename which was used to upload the image This function is used by imagetransfer.py and by copy_table.py """ sourceSite = sourceImagePage.site() if ...
def transferImage(self, sourceImagePage, debug=False): """Gets a wikilink to an image, downloads it and its description, and uploads it to another wikipedia. Returns the filename which was used to upload the image This function is used by imagetransfer.py and by copy_table.py """ sourceSite = sourceImagePage.site() if ...
36,070
def loggedin(self, check = False): if not hasattr(self,'_loggedin'): self._fill() if check: path = self.get_address('Non-existing page') txt = getUrl(self, path) self._loggedin = 'Userlogin' not in txt return self._loggedin
def loggedin(self, check = False): if not hasattr(self,'_loggedin'): self._fill() if check: path = self.get_address('Non-existing_page') txt = getUrl(self, path) self._loggedin = 'Userlogin' not in txt return self._loggedin
36,071
def run(self): linkChecker = LinkChecker(self.url) ok, message = linkChecker.check() if ok: if self.history.setLinkAlive(self.url): wikipedia.output('*Link to %s in [[%s]] is back alive.' % (self.url, self.title)) else: wikipedia.output('*[[%s]] links to %s - %s.' % (self.title, self.url, message)) self.history.setLink...
def run(self): linkChecker = LinkChecker(self.url) try: ok, message = linkChecker.check() except: wikipedia.output('Exception while processing URL %s in page %s' % (self.url, self.title)) raise if ok: if self.history.setLinkAlive(self.url): wikipedia.output('*Link to %s in [[%s]] is back alive.' % (self.url, self.title...
36,072
def include(pl,checklinks=True,realinclude=True,linkterm=None): cl = checklinks if realinclude: try: text = pl.get() except wikipedia.NoPage: pass except wikipedia.IsRedirectPage: cl = True pass else: cats = pl.categories() if not workingcat in cats: cats = pl.categories(catsWithSortKeys = True) for c in cats: if rawto...
def include(pl,checklinks=True,realinclude=True,linkterm=None): cl = checklinks if realinclude: try: text = pl.get() except wikipedia.NoPage: pass except wikipedia.IsRedirectPage: cl = True pass else: cats = pl.categories() if not workingcat in cats: cats = pl.categories(withSortKeys = True) for c in cats: if rawtoclea...
36,073
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
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
36,074
def fileUrl(self): # There are three types of image pages: # * normal, small images with links like: filename.png (10KB, MIME type: image/png) # * normal, large images with links like: Download high resolution version (1024x768, 200 KB) # * SVG images with links like: filename.svg‎ (1KB, MIME type: image/svg) # This r...
def fileUrl(self): # There are three types of image pages: # * normal, small images with links like: filename.png (10KB, MIME type: image/png) # * normal, large images with links like: Download high resolution version (1024x768, 200 KB) # * SVG images with links like: filename.svg‎ (1KB, MIME type: image/svg) # This r...
36,075
def url2unicode(percentname, language): x=urllib.unquote(percentname) for encoding in code2encodings(language): try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = decode_func(x) return x except UnicodeError: pass raise UnicodeError("Could not decode %s" % repr(percentname))
def url2unicode(percentname, language): x=urllib.unquote(str(percentname)) for encoding in code2encodings(language): try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = decode_func(x) return x except UnicodeError: pass raise UnicodeError("Could not decode %s" % repr(percentname))...
36,076
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = encode_func(x) except UnicodeErro...
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = encode_func(x) except UnicodeErro...
36,077
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = encode_func(x) except UnicodeErro...
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) y,l = encode_func(x) except UnicodeErro...
36,078
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = encode_func(x) except UnicodeErro...
def unicode2html(x, encoding='latin1'): # We have a unicode string. We can attempt to encode it into the desired # format, and if that doesn't work, we encode the unicode into html # # entities. try: encode_func, decode_func, stream_reader, stream_writer = codecs.lookup(encoding) x,l = encode_func(x) except UnicodeErro...
36,079
def main(): oldImage = None newImage = None summary = '' always = False # read command line parameters for arg in wikipedia.handleArgs(): if arg == '-always': always = True elif arg.startswith('-summary'): if len(arg) == len('-summary'): summary = wikipedia.input(u'Choose an edit summary: ') else: summary = arg[len('-s...
def main(): oldImage = None newImage = None summary = '' always = False # read command line parameters for arg in wikipedia.handleArgs(): if arg == '-always': always = True elif arg.startswith('-summary'): if len(arg) == len('-summary'): summary = wikipedia.input(u'Choose an edit summary: ') else: summary = arg[len('-s...
36,080
def __init__(self):
def __init__(self):
36,081
def add_category(): 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 "specific page. If you want the second, please give an empty" print "answer to the first...
def add_category(): 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 "specific page. If you want the second, please give an empty" print "answer to the first...
36,082
def add_category(): 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 "specific page. If you want the second, please give an empty" print "answer to the first...
def add_category(): 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 "specific page. If you want the second, please give an empty" print "answer to the first...
36,083
def linkto(self, linkname, othersite = None): if othersite and othersite.lang == self.lang: return '[[%s:%s]]' % (self.lang, linkname) else: return '[[%s]]' % linkname
def linkto(self, linkname, othersite = None): if othersite and othersite.lang != self.lang: return '[[%s:%s]]' % (self.lang, linkname) else: return '[[%s]]' % linkname
36,084
def assemble(self, returnonquestion = False, askall = False): 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('Someone refers to %s with us' % pl.asasciil...
def assemble(self, returnonquestion = False, askall = False): 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(err) if globalvar.autonomous: return None el...
36,085
def assemble(self, returnonquestion = False, askall = False): 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('Someone refers to %s with us' % pl.asasciil...
def assemble(self, returnonquestion = False, askall = False): 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('Someone refers to %s with us' % pl.asasciil...
36,086
def main(): # if -file is not used, this temporary array is used to read the page title. pageTitle = [] page = None gen = None interwiki = False targetLang = None targetFamily = None for arg in sys.argv[1:]: #for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'imagetransfer') if arg: if arg == '-interwiki': inte...
def main(): # if -file is not used, this temporary array is used to read the page title. pageTitle = [] page = None gen = None interwiki = False targetLang = None targetFamily = None for arg in sys.argv[1:]: #for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'imagetransfer') if arg: if arg == '-interwiki': inte...
36,087
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. """ # Get file contents if '://' in self...
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. """ # Get file contents if '://' in self...
36,088
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. """ # Get file contents if '://' in self...
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. """ # Get file contents if '://' in self...
36,089
def get(key, lang = None): if lang == None: lang = wikipedia.mylang try: # find out how old our saved dump is (in seconds) file_age = time.time() - os.path.getmtime('mediawiki-messages/mediawiki-messages-%s.dat' % lang) # if it's older than 1 month, reload it if file_age > 30 * 24 * 60 * 60: print 'Current MediaWiki me...
def get(key, lang = None): if lang == None: lang = wikipedia.mylang try: # find out how old our saved dump is (in seconds) file_age = time.time() - os.path.getmtime('mediawiki-messages/mediawiki-messages-%s.dat' % lang) # if it's older than 1 month, reload it if file_age > 30 * 24 * 60 * 60: print 'Current MediaWiki me...
36,090
def makepath(path): """ creates missing directories for the given path and returns a normalized absolute version of the path. - if the given path already exists in the filesystem the filesystem is not modified. - otherwise makepath creates directories along the given path using the dirname() of the path. You may appe...
def makepath(path): """ creates missing directories for the given path and returns a normalized absolute version of the path. - if the given path already exists in the filesystem the filesystem is not modified. - otherwise makepath creates directories along the given path using the dirname() of the path. You may appe...
36,091
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....
def run(self): if self.main_only: if not ignore_title.has_key(self.mylang): ignore_title[self.mylang] = [] ignore_title[self.mylang] += [u'%s:' % namespace for namespace in self.mysite.namespaces()] for disambTitle in self.page_list: # when run with -redir argument, there's another summary message if self.solve_redire...
36,092
def delete(self, reason = None, prompt = True): """Deletes the page from the wiki. Requires administrator status. If reason is None, asks for a reason. If prompt is True, asks the user if he wants to delete the page. """ # TODO: Find out if bot is logged in with an admin account, raise exception # or show error message...
def delete(self, reason = None, prompt = True): """Deletes the page from the wiki. Requires administrator status. If reason is None, asks for a reason. If prompt is True, asks the user if he wants to delete the page. """ # TODO: Find out if bot is logged in with an admin account, raise exception # or show error message...
36,093
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...
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...
36,094
def retrieve_double_redirects(self): if self.source == None: mysite = wikipedia.getSite() # retrieve information from the live wiki's maintenance page host = mysite.hostname() # double redirect maintenance page's URL url = mysite.double_redirects_address(default_limit = False) print 'Retrieving special page...' mainte...
def retrieve_double_redirects(self): if self.source == None: mysite = wikipedia.getSite() # retrieve information from the live wiki's maintenance page host = mysite.hostname() # double redirect maintenance page's URL url = mysite.double_redirects_address(default_limit = False) print 'Retrieving special page...' mainte...
36,095
def run(self): for page in self.generator: try: wikipedia.output(u'\n>>>> %s <<<<' % page.title()) commons = wikipedia.Site('commons', 'commons') commonspage = wikipedia.Page(commons, page.title()) try: getcommons = commonspage.get(get_redirect=True) if page.title() == commonspage.title(): oldText = page.get() text = o...
def run(self): for page in self.generator: try: wikipedia.output(u'\n>>>> %s <<<<' % page.title()) commons = wikipedia.Site('commons', 'commons') commonspage = wikipedia.Page(commons, page.title()) try: getcommons = commonspage.get(get_redirect=True) if page.title() == commonspage.title(): oldText = page.get() text = o...
36,096
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...
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...
36,097
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...
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...
36,098
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...
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...
36,099