rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
if l.site() == xpl.site(): wikipedia.output(u"WARNING: %s: %s does not link to %s but to %s" % (pl.site().family.name, pl.aslink(forceInterwiki = True), xpl.aslink(forceInterwiki = True), l.aslink(forceInterwiki = True)))
if l.site() == xpage.site(): wikipedia.output(u"WARNING: %s: %s does not link to %s but to %s" % (page.site().family.name, page.aslink(forceInterwiki = True), xpage.aslink(forceInterwiki = True), l.aslink(forceInterwiki = True)))
def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" try: for site in new.keys(): pl = new[site] if not pl.section(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked: for l in linked: if l....
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
wikipedia.output(u"WARNING: %s: %s does not link to %s" % (pl.site().family.name, pl.aslink(forceInterwiki = True), xpl.aslink(forceInterwiki = True)))
wikipedia.output(u"WARNING: %s: %s does not link to %s" % (page.site().family.name, page.aslink(forceInterwiki = True), xpage.aslink(forceInterwiki = True)))
def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" try: for site in new.keys(): pl = new[site] if not pl.section(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked: for l in linked: if l....
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
for xpl in linked: if not xpl in shouldlink:
for xpage in linked: if not xpage in shouldlink:
def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" try: for site in new.keys(): pl = new[site] if not pl.section(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked: for l in linked: if l....
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
if l.site() == xpl.site():
if l.site() == xpage.site():
def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" try: for site in new.keys(): pl = new[site] if not pl.section(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked: for l in linked: if l....
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
wikipedia.output(u"WARNING: %s: %s links to incorrect %s" % (pl.site().family.name, pl.aslink(forceInterwiki = True), xpl.aslink(forceInterwiki = True)))
wikipedia.output(u"WARNING: %s: %s links to incorrect %s" % (page.site().family.name, page.aslink(forceInterwiki = True), xpage.aslink(forceInterwiki = True)))
def reportBacklinks(self, new): """Report missing back links. This will be called from finish() if needed.""" try: for site in new.keys(): pl = new[site] if not pl.section(): shouldlink = new.values() + [self.inpl] linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked: for l in linked: if l....
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
print pl.site().hostname() print pl.site().delete_address(pl.urlname())
def encode_multipart_formdata(fields): """ 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 (content_type, body) ready for httplib.HTTP instance """ BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$' CRLF =...
5f9fc92da44e65c5927343247a1e2b3970355138 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/5f9fc92da44e65c5927343247a1e2b3970355138/wikipedia.py
print arg
def main(args): filename = '' description = [] keep = False wiki = '' for arg in args: if wikipedia.argHandler(arg, 'upload'): print arg if arg.startswith('-keep'): keep = True elif arg.startswith('-wiki:'): wiki=arg[6:] elif filename == '': filename = arg else: description.append(arg) description = ' '.join(descripti...
d7eca63189738ebe008d0da021d5f4785441fa09 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d7eca63189738ebe008d0da021d5f4785441fa09/upload.py
except IsRedirectPage:
except wikipedia.IsRedirectPage:
def handlebadpage(self): try: self.content = self.page.get() except IsRedirectPage: wikipedia.output(u'Already redirected, skipping.') return
af772c3789ebe593b89d77c00e9755aca4d2d7eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/af772c3789ebe593b89d77c00e9755aca4d2d7eb/followlive.py
wikipedia.output(u'Found: "',d, '" in content, nothing necessary')
wikipedia.output(u'Found: "%s" in content, nothing necessary'%d)
def handlebadpage(self): try: self.content = self.page.get() except IsRedirectPage: wikipedia.output(u'Already redirected, skipping.') return
af772c3789ebe593b89d77c00e9755aca4d2d7eb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/af772c3789ebe593b89d77c00e9755aca4d2d7eb/followlive.py
output(url2unicode("Creating page [[%s:%s]]" % site.lang, name, site = site))
output(url2unicode("Creating page [[%s:%s]]" % (site.lang, name), site = site))
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...
89131f4c75abaccf39272af28ed8bc7adef6c128 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/89131f4c75abaccf39272af28ed8bc7adef6c128/wikipedia.py
output(url2unicode("Changing page [[%s:%s]]" % site.lang, name, site = site))
output(url2unicode("Changing page [[%s:%s]]" % (site.lang, name), site = site))
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...
89131f4c75abaccf39272af28ed8bc7adef6c128 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/89131f4c75abaccf39272af28ed8bc7adef6c128/wikipedia.py
output(url2unicode(u'Getting page [[%s:%s]]' % site.lang, name, site = site))
output(url2unicode(u'Getting page [[%s:%s]]' % (site.lang, name), site = site))
def getEditPage(site, name, 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 - the page n...
89131f4c75abaccf39272af28ed8bc7adef6c128 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/89131f4c75abaccf39272af28ed8bc7adef6c128/wikipedia.py
wikipedia.getall(wikipedia.getSite(), pages, throttle=False)
site = pages[0].site() wikipedia.getall(site, pages, throttle=False) except IndexError: pass
def preload(self, pages): try: wikipedia.getall(wikipedia.getSite(), pages, throttle=False) except wikipedia.SaxError: # Ignore this error, and get the pages the traditional way later. pass
5291af0d37ba1784f743f9bb9b8eb3ab2e15118f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/5291af0d37ba1784f743f9bb9b8eb3ab2e15118f/pagegenerators.py
output("WARNING: Section does not exist: %s" % self.linkname())
output(u"WARNING: Section does not exist: %s" % self.linkname())
def get(self, read_only = False, force = False, get_redirect=False, throttle = True): """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:
61850a42ea16fb7eec9b804196791671e790ccf7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61850a42ea16fb7eec9b804196791671e790ccf7/wikipedia.py
output("WARNING: Section does not exist: %s" % self)
output(u"WARNING: Section does not exist: %s" %pl2.linkname())
def oneDone(self, title, timestamp, text): pl = Page(self.site, title) for pl2 in self.pages: if Page(self.site, pl2.sectionFreeLinkname()) == 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> bug, page not found in ...
61850a42ea16fb7eec9b804196791671e790ccf7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/61850a42ea16fb7eec9b804196791671e790ccf7/wikipedia.py
txt = "
txt = redir.get(get_redirect=True).replace('[['+target,'[['+second_target)
def fix_double_redirects(self): mysite = wikipedia.getSite() for redir_name in self.generator.retrieve_double_redirects(): print '' redir = wikipedia.Page(mysite, redir_name) try: target = redir.getRedirectTarget() except wikipedia.IsNotRedirectPage: wikipedia.output(u'%s is not a redirect.' % redir.title()) except wik...
39d4cb0ec95c85a5b7bbf4855e884bddee4e4ec0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/39d4cb0ec95c85a5b7bbf4855e884bddee4e4ec0/redirect.py
wikipedia.link2url(start)
start=link2url(start)
def allnlpages(start='%20%200'): wikipedia.link2url(start) m=0 while 1: text=wikipedia.getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0) #print text R=re.compile('/wiki/(.*?)" *class=[\'\"]printable') n=0 for hit in R.findall(text): if not ':' in hit: if not hit in ['Hoofdpagina','In_he...
bfd79666aeda85c89eb6356290904952022367a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfd79666aeda85c89eb6356290904952022367a1/wikipedia.py
text=wikipedia.getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0)
text=getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0)
def allnlpages(start='%20%200'): wikipedia.link2url(start) m=0 while 1: text=wikipedia.getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0) #print text R=re.compile('/wiki/(.*?)" *class=[\'\"]printable') n=0 for hit in R.findall(text): if not ':' in hit: if not hit in ['Hoofdpagina','In_he...
bfd79666aeda85c89eb6356290904952022367a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfd79666aeda85c89eb6356290904952022367a1/wikipedia.py
yield wikipedia.url2link(hit)
yield url2link(hit)
def allnlpages(start='%20%200'): wikipedia.link2url(start) m=0 while 1: text=wikipedia.getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0) #print text R=re.compile('/wiki/(.*?)" *class=[\'\"]printable') n=0 for hit in R.findall(text): if not ':' in hit: if not hit in ['Hoofdpagina','In_he...
bfd79666aeda85c89eb6356290904952022367a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfd79666aeda85c89eb6356290904952022367a1/wikipedia.py
sys.stderr.write('AllNLPages: %d done; continuing from "%s";\n'%(m,wikipedia.link2url(start)))
sys.stderr.write('AllNLPages: %d done; continuing from "%s";\n'%(m,url2link(start)))
def allnlpages(start='%20%200'): wikipedia.link2url(start) m=0 while 1: text=wikipedia.getPage('nl','Speciaal:Allpages&printable=yes&from=%s'%start,do_quote=0,do_edit=0) #print text R=re.compile('/wiki/(.*?)" *class=[\'\"]printable') n=0 for hit in R.findall(text): if not ':' in hit: if not hit in ['Hoofdpagina','In_he...
bfd79666aeda85c89eb6356290904952022367a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfd79666aeda85c89eb6356290904952022367a1/wikipedia.py
result[code] = m.group(1)
t=m.group(1) if '|' in t: t.replace('|','') result[code] = t
def getLanguageLinks(text): """Returns a dictionary of other language links mentioned in the text in the form {code:pagename}""" result = {} for code in langs: m=re.search(r'\[\['+code+':([^\]]*)\]\]', text) if m: if m.group(1): result[code] = m.group(1) else: print "ERROR: empty link to %s:"%(code) return result
bfd79666aeda85c89eb6356290904952022367a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfd79666aeda85c89eb6356290904952022367a1/wikipedia.py
elif arg.startswith('-page:'):
elif arg.startswith('-page'):
def main(): template_names = [] resolve = False remove = False namespaces = [] editSummary = '' acceptAll = False pageTitles = [] extras = False # If xmlfilename is None, references will be loaded from the live wiki. xmlfilename = None new = None # read command line parameters for arg in wikipedia.handleArgs(): if arg ...
0ddf4175823943f012b494fbfb5edf4ef1efdb5d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/0ddf4175823943f012b494fbfb5edf4ef1efdb5d/template.py
m = re.search('value="(\d+)" name=["\']wpEdittime["\']', text) if m: self._editTime = m.group(1) else: self._editTime = "0" m = re.search('value="(\d+)" name=["\']wpStarttime["\']', text) if m: self._startTime = m.group(1) else: self._startTime = "0"
def getEditPage(self, get_redirect=False, throttle = True, sysop = False): """ Get the contents of the Page via the edit page. Do not use this directly, use get() instead. Arguments: get_redirect - Get the contents, even if it is a redirect page This routine returns a unicode string containing the wiki text. """ isW...
96cf7eeba930c03c67985c8fe0c128c94122d3f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/96cf7eeba930c03c67985c8fe0c128c94122d3f6/wikipedia.py
m = re.search('value="(\d+)" name=["\']wpEdittime["\']', text) if m: self._editTime = m.group(1) else: self._editTime = "0" m = re.search('value="(\d+)" name=["\']wpStarttime["\']', text) if m: self._startTime = m.group(1) else: self._startTime = "0"
def getEditPage(self, get_redirect=False, throttle = True, sysop = False): """ Get the contents of the Page via the edit page. Do not use this directly, use get() instead. Arguments: get_redirect - Get the contents, even if it is a redirect page This routine returns a unicode string containing the wiki text. """ isW...
96cf7eeba930c03c67985c8fe0c128c94122d3f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/96cf7eeba930c03c67985c8fe0c128c94122d3f6/wikipedia.py
def isTalkPage(self): ns = self.namespace() return ns >= 0 and ns % 2 == 1
def isEmpty(self): """ True if the page has less than 4 characters, except for language links and category links, False otherwise. Can raise the same exceptions as get() """ txt = self.get() txt = removeLanguageLinks(txt) txt = removeCategoryLinks(txt, site = self.site()) if len(txt) < 4: return True else: return False
96cf7eeba930c03c67985c8fe0c128c94122d3f6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/96cf7eeba930c03c67985c8fe0c128c94122d3f6/wikipedia.py
R=re.compile(r'\[\[(.*)]\]')
R=re.compile(r'\[\[(.+?)\]\]')
def PagesFromFile(fn, site = None): """Read a file of page links between double-square-brackets, and return them as a list of Page objects. 'fn' is the name of the file that should be read.""" if site is None: site = getSite() f=open(fn, 'r') R=re.compile(r'\[\[(.*)]\]') for line in f.readlines(): m=R.match(line) if m:...
f349cd2969a3dda8cd58d19cc6d0ca0e54a455c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f349cd2969a3dda8cd58d19cc6d0ca0e54a455c7/wikipedia.py
except ValueError:
except:
def PagesFromFile(fn, site = None): """Read a file of page links between double-square-brackets, and return them as a list of Page objects. 'fn' is the name of the file that should be read.""" if site is None: site = getSite() f=open(fn, 'r') R=re.compile(r'\[\[(.*)]\]') for line in f.readlines(): m=R.match(line) if m:...
f349cd2969a3dda8cd58d19cc6d0ca0e54a455c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f349cd2969a3dda8cd58d19cc6d0ca0e54a455c7/wikipedia.py
if summary == None:
if summary_commandline == None:
def main(): gen = None # How we want to retrieve information on which pages need to be changed. # Can either be 'xmldump', 'textfile' or 'userinput'. source = None # summary message summary_commandline = None # Array which will collect commandline parameters. # First element is original text, second element is replacem...
e1fc9b894c1b0281116c57d6d59f7e255e93d772 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/e1fc9b894c1b0281116c57d6d59f7e255e93d772/replace.py
Rnowiki = re.compile("<nowiki>*?</nowiki>")
Rnowiki = re.compile("<nowiki>.*?</nowiki>")
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())
3e644f59879dcd768335eaeafa686a7c04460def /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3e644f59879dcd768335eaeafa686a7c04460def/wikipedia.py
def url2link(percentname,incode,code):
def url2link(percentname, incode, code):
def url2link(percentname,incode,code): """Convert a url-name of a page into a proper name for an interwiki link the argument 'incode' specifies the encoding of the target wikipedia """ result = underline2space(percentname) x = url2unicode(result, language = code) e = code2encoding(incode) if e == 'utf-8': # utf-8 can h...
713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21/wikipedia.py
e = code2encoding(incode) if e == 'utf-8':
return unicode2html(x, encoding = code2encoding(incode))
def url2link(percentname,incode,code): """Convert a url-name of a page into a proper name for an interwiki link the argument 'incode' specifies the encoding of the target wikipedia """ result = underline2space(percentname) x = url2unicode(result, language = code) e = code2encoding(incode) if e == 'utf-8': # utf-8 can h...
713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21/wikipedia.py
return x elif e == code2encoding(code): return unicode2html(x, encoding = code2encoding(code)) else: return unicode2html(x, encoding = 'ascii')
def url2link(percentname,incode,code): """Convert a url-name of a page into a proper name for an interwiki link the argument 'incode' specifies the encoding of the target wikipedia """ result = underline2space(percentname) x = url2unicode(result, language = code) e = code2encoding(incode) if e == 'utf-8': # utf-8 can h...
713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/713cd30d5f8de84645fe8dcc2c11b8a7f4bf5b21/wikipedia.py
if hasattr(self, '_redirarg'): if not get_redirect: raise IsRedirectPage,self._redirarg elif hasattr(self, '_getexception'):
if hasattr(self, '_getexception'):
def get(self, read_only = False, force = False, get_redirect=False, throttle = True): """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:
184b1577d9d6e78833f6b08382598a3850e5156d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/184b1577d9d6e78833f6b08382598a3850e5156d/wikipedia.py
except LockedPage: self._getexception = LockedPage raise
def get(self, read_only = False, force = False, get_redirect=False, throttle = True): """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:
184b1577d9d6e78833f6b08382598a3850e5156d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/184b1577d9d6e78833f6b08382598a3850e5156d/wikipedia.py
self.get(read_only = True)
self.get(read_only = read_only)
def getRedirectTarget(self, read_only = False): """ If the page is a redirect page, gives the title of the page it redirects to. Otherwise it will raise an IsNotRedirectPage exception. This function can raise a NoPage exception, and unless the argument read_only is True, a LockedPage exception as well. """ try: self.g...
184b1577d9d6e78833f6b08382598a3850e5156d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/184b1577d9d6e78833f6b08382598a3850e5156d/wikipedia.py
if edittime[site, name] == "0" and not read_only: output(u"DBG> page may be locked?!") raise LockedPage()
def getEditPage(site, name, read_only = False, 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 - the page name read_only ...
184b1577d9d6e78833f6b08382598a3850e5156d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/184b1577d9d6e78833f6b08382598a3850e5156d/wikipedia.py
import mediawiki_messages for i in pages_for_exclusion_database: path = 'copyright/' + i[0] + '/' + i[2] mediawiki_messages.makepath(path) p = wikipedia.Page(wikipedia.getSite(i[0]),i[1]) yield p, path
for i in pages_for_exclusion_database: path = 'copyright/' + i[0] + '/' + i[2] mediawiki_messages.makepath(path) p = wikipedia.Page(wikipedia.getSite(i[0]),i[1]) yield p, path
def exclusion_file_list(): import mediawiki_messages for i in pages_for_exclusion_database: path = 'copyright/' + i[0] + '/' + i[2] mediawiki_messages.makepath(path) p = wikipedia.Page(wikipedia.getSite(i[0]),i[1]) yield p, path
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
import time, os write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()) f.clos...
write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(page.get()) f.close() return
def load_pages(): import time, os write = False for page, path in exclusion_file_list(): try: file_age = time.time() - os.path.getmtime(path) if file_age > 24 * 60 * 60: print 'Updating source pages to exclude new URLs...' write = True except OSError: write = True if write: f = codecs.open(path, 'w', 'utf-8') f.write(...
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text return True
for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text return True
def check_list(text, cl): for entry in cl: if entry: if text.find(entry) != -1: print 'SKIP URL ' + text
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
import glob prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:http://)?(.*?)\]?", data) if 'copyright/it/Cloni.tx...
prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Site:\s*\[?(?:http://)?(.*?)\]?", data) if 'copyright/it/Cloni.txt' in path: ...
def exclusion_list(): import glob prelist = [] load_pages() for page, path in exclusion_file_list(): f = codecs.open(path, "r", 'utf-8') data = f.read() f.close() # wikipedia:en:Wikipedia:Mirrors and forks prelist += re.findall("(?i)url\s*=\s*<nowiki>(?:http://)?(.*?)</nowiki>", data) prelist += re.findall("(?i)\*\s*Si...
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
return ""
return ""
def cleanwikicode(text): if not text: return ""
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$", "", text) text = re.sub('^[:*]?["][^"]+["]\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$', "", text) text = re.sub('^[:*]?[«][^»]+[»]\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$', "", text) text = re.sub('^[:*]?[“][^”]+[”]\.?\s...
text = re.sub("(?i){{quote|.*?}}", "", text) text = re.sub("^:''.*?''\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$", "", text) text = re.sub('^[:*]?["][^"]+["]\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$', "", text) text = re.sub('^[:*]?[«][^»]+[»]\.?\s*((\(|<ref>).*?(\)|</ref>))?\.?$', "", text) text = re.sub('^[:*]?[“][^”]+[...
def cleanwikicode(text): if not text: return ""
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
output = u"" n_query = 0 for line in lines: line = cleanwikicode(line) if len(line)>200: n_query+=1 if n_query>max_query_for_page: print "Max query limit for page reached" return output if len(line)>max_query_len: line=line[:max_query_len] glen=len(line) while line[glen-1] != ' ': glen -= 1 line = line[:glen] resul...
output = u"" n_query = 0 for line in lines: line = cleanwikicode(line) if len(line)>200: n_query+=1 if n_query>max_query_for_page: print "Max query limit for page reached" return output if len(line)>max_query_len: line=line[:max_query_len] glen=len(line) while line[glen-1] != ' ': glen -= 1 line = line[:glen] resul...
def query(lines = [], max_query_len = 1300):
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
if add_item in url[i]: url[i] = (add_item, 'google, yahoo') return True
if add_item in url[i]: url[i] = (add_item, 'google, yahoo') return True
def check_urllist(url, add_item): for i in range(len(url)): if add_item in url[i]: url[i] = (add_item, 'google, yahoo') return True return False
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry:
url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry:
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry:
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
try: data = google.doGoogleSearch('-Wikipedia "' + query + '"') search_request_retry = 0 for entry in data.results: url.append((entry.URL, 'google')) except Exception, err: print "Got an error ->", err search_request_retry -= 1 if search_in_yahoo: import yahoo.search.web print " yahoo query..." data = yahoo.search.web...
try: data = google.doGoogleSearch('-Wikipedia "' + query + '"') search_request_retry = 0 for entry in data.results: url.append((entry.URL, 'google')) except Exception, err: print "Got an error ->", err search_request_retry -= 1 if search_in_yahoo: import yahoo.search.web print " yahoo query..." data = yahoo.search.web...
def get_results(query, numresults = 10): url = list() if search_in_google: import google google.LICENSE_KEY = config.google_key print " google query..." search_request_retry = 6 while search_request_retry:
1fc8304d6ddd18fcd83597ff7597b54525735edf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1fc8304d6ddd18fcd83597ff7597b54525735edf/copyright.py
if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1)
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
answer =wikipedia.input(u"Include image %s (y/N/s(top))?"%image)
answer = wikipedia.inputChoice(u'Include image %s?' % image, ['yes', 'no', 'stop'], ['y', 'N', 's'], 'N')
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
lib_images.get_image(image, None, desc)
uploadBot = upload.UploadRobot(image, desc) uploadBot.run()
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
url = ''
url = u''
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
if wikipedia.argHandler(arg, 'imageharvest'):
arg = wikipedia.argHandler(arg, 'imageharvest') if arg:
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
elif url == '':
elif url == u'':
def main(give_url,image_url): url = give_url basicdesc = [] if not mysite.loggedin(): print "You must be logged in to upload images" import sys sys.exit(1) if url == '': if image_url: url = wikipedia.input(u"What URL range should I check (use $ for the part that is changeable)") else: url = wikipedia.input(u"From wha...
3ff37e4776e4f2076ee04d2ad111c88b3418b675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3ff37e4776e4f2076ee04d2ad111c88b3418b675/imageharvest.py
self.version = '1.5'
def version(self, code): return "1.5"
def __init__(self): family.Family.__init__(self) self.name = 'commons' self.langs = { 'commons': 'commons.wikimedia.org', } self.namespaces[4] = { '_default': 'Commons', } self.namespaces[5] = { '_default': 'Commons talk', }
546c0e2fc0a6b434f2a3f8f6defb0d98e0a6f071 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/546c0e2fc0a6b434f2a3f8f6defb0d98e0a6f071/commons_family.py
print mediawiki_messages.get('spamprotectiontitle', self.site())
output(u""+mediawiki_messages.get('spamprotectiontitle', self.site()))
def putPage(self, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, token = None, gettoken = False, sysop = False): """ Upload 'text' as new contents for this Page by filling out the edit page.
eb04903a3983842359e703c06998ef54aabe04df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eb04903a3983842359e703c06998ef54aabe04df/wikipedia.py
if code in ['eml','lij','lmo','nap','pms','roa-tará','sc','scn','vec']:
if code in ['eml','lij','lmo','nap','pms','roa-tara','sc','scn','vec']:
def altlang(code): if code=='aa': return ['am'] if code in ['fa','so']: return ['ar'] if code=='ku': return ['ar','tr'] if code=='sk': return ['cs'] if code in ['bar','hsb','ksh']: return ['de'] if code in ['als','lb']: return ['de','fr'] if code=='io': return ['eo'] if code in ['an','ast','ay','ca','gn','nah','qu']: r...
eb04903a3983842359e703c06998ef54aabe04df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eb04903a3983842359e703c06998ef54aabe04df/wikipedia.py
def showdiff(old, new):
def showdiff(self,old, new):
def showdiff(old, new): diff = difflib.context_diff(old.splitlines(), new.splitlines()) wikipedia.output(u"\n".join(diff))
02a8db40b7c0ea2d2fb073a1cac9a38d0d400bcb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02a8db40b7c0ea2d2fb073a1cac9a38d0d400bcb/editarticle.py
raise
wikipedia.stopme()
def main(): # How we want to retrieve information on which pages need to be changed. # Can either be 'sqldump', 'textfile' or 'userinput'. source = None # Array which will collect commandline parameters. # First element is original text, second element is replacement text. commandline_replacements = [] # A dictionary w...
0f6111967a56439243352b05e70f6ac2ae37f280 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/0f6111967a56439243352b05e70f6ac2ae37f280/replace.py
return "[[user:%s" % username in text.lower()
return "[[user:%s" % username.lower() in text.lower()
def allowedbot(username, site): """Checks whether the bot is listed on Wikipedia:bots""" pl = wikipedia.Page(site, "Wikipedia:Bots") text = pl.get() return "[[user:%s" % username in text.lower()
c4fe80fe7894c6a7737def328fd459922cecdab8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c4fe80fe7894c6a7737def328fd459922cecdab8/login.py
catlib.change_category(article, original_cat, None)
catlib.change_category(article, original_cat.catname(), None)
def move_to_subcategory(article, original_cat, current_cat): print print 'Treating page ' + article.ascii_linkname() + ', currently in category ' + current_cat.ascii_linkname() subcatlist = get_subcats(current_cat) print if len(subcatlist) == 0: print 'This category has no subcategories.' print # show subcategories as ...
182596a0eafb007bcd0d00be114cf7f8f327e1cf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/182596a0eafb007bcd0d00be114cf7f8f327e1cf/category.py
ns = mysite.template_namespace(fallback = None)
ns = mysite.template_namespace()
def main(): template_names = [] resolve = False remove = False # If xmlfilename is None, references will be loaded from the live wiki. xmlfilename = None new = None # read command line parameters for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg, 'template') if arg: if arg == '-remove': remove = True elif arg.sta...
b8b3f04fb50a26beed1867f4c32603a5ada6e638 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b8b3f04fb50a26beed1867f4c32603a5ada6e638/template.py
if "</noinclude>" in s2[firstafter:]: newtext = s2[:firstafter+1] + s + s2[firstafter+1:]
if "</noinclude>" in s2[firstafter:] and firstafter < 0: newtext = s2[:firstafter] + s + s2[firstafter:]
def replaceLanguageLinks(oldtext, new, site = None): """Replace the interwiki language links given in the wikitext given in oldtext by the new links given in new. 'new' should be a dictionary with the language names as keys, and Page objects as values. """ if site == None: site = getSite() s = interwikiFormat(new, ins...
99b4367f5401b44178520228402cbd6851144cda /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/99b4367f5401b44178520228402cbd6851144cda/wikipedia.py
return self.lang in self.site().family.category_on_one_line
return self.lang in self.family.category_on_one_line
def category_on_one_line(self): return self.lang in self.site().family.category_on_one_line
c79fb25a1ba71d90a27b6bdafb45d7670f9ffa23 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c79fb25a1ba71d90a27b6bdafb45d7670f9ffa23/wikipedia.py
if regex:
if self.regex:
def read_pages_from_sql_dump(self): """ 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 - a dictionary where old texts are keys...
778ae66dc07cebfb604ed6e98ccfe9533fcf13bb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/778ae66dc07cebfb604ed6e98ccfe9533fcf13bb/replace.py
filename = 'interwiki-graphs/%s.png' % inpl.urlname() graph.write(filename, prog = 'dot', format = 'png') wikipedia.output(u'Graph saved as %s' % filename)
filename = 'interwiki-graphs/%s-%s-%s.png' % (inpl.site().family.name, inpl.site().language(), inpl.urlname()) if graph.write(filename, prog = 'dot', format = 'png'): wikipedia.output(u'Graph saved as %s' % filename) else: wikipedia.output(u'Graph could not be saved as %s' % filename)
def createGraph(self): import pydot # create empty graph graph = pydot.Dot() graph.add_node(pydot.Node('start', shape = 'point')) for page in self.foundin.iterkeys(): # a node for each found page node = pydot.Node('"%s:%s"' % (page.site().language(), wikipedia.unicode2html(page.title(), 'ascii')), shape = 'rectangle') ...
903a1baf93254b4c32e58cf956cb6a51538a6756 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/903a1baf93254b4c32e58cf956cb6a51538a6756/interwiki.py
wikipedia.output(u"WARNING: Page %s does no longer exist?!"%page)
wikipedia.output(u"WARNING: Page %s does no longer exist?!" % page.title())
def reportBacklinks(self, new, updatedSites): """ Report missing back links. This will be called from finish() if needed.
903a1baf93254b4c32e58cf956cb6a51538a6756 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/903a1baf93254b4c32e58cf956cb6a51538a6756/interwiki.py
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...
8b1ef8e199c0c8bf8d753e9d01b50ce8f994e442 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/8b1ef8e199c0c8bf8d753e9d01b50ce8f994e442/wikipedia.py
for i in range(len(line)):
for i in range(min(len(line), len(lastline))):
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...
8b1ef8e199c0c8bf8d753e9d01b50ce8f994e442 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/8b1ef8e199c0c8bf8d753e9d01b50ce8f994e442/wikipedia.py
del new[zh]
del new['zh']
def assemble(self): new = {} nerr = 0 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: self.problem("Found link to %s"%pl.asasciilink()) for pl2 in self.foundin[pl]: print " ",pl2.asasciilink() nerr += 1 eli...
d3bf4bdfdb3dc8499cf71f539412b0d7830ca3f8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d3bf4bdfdb3dc8499cf71f539412b0d7830ca3f8/interwiki.py
itemR = re.compile("<tr bgcolor=\"
itemR = re.compile("<tr bgcolor=\"
def refresh_messages(site): host = site.hostname() # get 'all messages' special page's URL url = site.allmessages_address() print 'Retrieving MediaWiki messages for %s' % repr(site) wikipedia.put_throttle() # It actually is a get, but a heavy one. allmessages, charset = wikipedia.getUrl(host, url, site) print 'Parsing...
cb028ea3a49016ceaa3e9ffc07fb0813865480f0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/cb028ea3a49016ceaa3e9ffc07fb0813865480f0/mediawiki_messages.py
print "DBG> successfulupload contains %s" % get('successfulupload')
print "DBG> successfulupload contains %s" % get('successfulupload') print "DBG> deletedtext contains %s" % get('deletedtext')
def main(): debug = False refresh_all = False for arg in sys.argv[1:]: arg = wikipedia.argHandler(arg) 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> successfulupload contains %s" %...
cb028ea3a49016ceaa3e9ffc07fb0813865480f0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/cb028ea3a49016ceaa3e9ffc07fb0813865480f0/mediawiki_messages.py
alternatives = []
alternatives = []
def resafe(s): s=s.replace('(','\\(') s=s.replace(')','\\)') return s
a95b64ecb8f20fa2191be07dc6e6a5ae90c4a955 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a95b64ecb8f20fa2191be07dc6e6a5ae90c4a955/solve_disambiguation.py
print data
def putPage(site, name, text, comment = None, watchArticle = False, minorEdit = True, newPage = False, anon=False, token = None): """Upload 'text' on page 'name' to the 'site' wiki. Use of this routine can normally be avoided; use PageLink.put instead. """ # Check whether we are not too quickly after the previous putPa...
1c06f3033318568e0a7ed257e72c647b39d0d497 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1c06f3033318568e0a7ed257e72c647b39d0d497/wikipedia.py
elif not site.gettoken:
elif not site.gettoken():
def getPage(site, name, get_edit_page = True, read_only = False, do_quote = True, get_redirect=False): """ 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 PageLink object instead. Arguments: site - the wiki site name - the p...
1c06f3033318568e0a7ed257e72c647b39d0d497 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/1c06f3033318568e0a7ed257e72c647b39d0d497/wikipedia.py
titleLength = len(titleWithSection) titleWithSection = titleWithSection.rstrip() hadTrailingSpaces = (len(titleWithSection) != titleLength)
if not trailingChars or label: titleLength = len(titleWithSection) titleWithSection = titleWithSection.rstrip() hadTrailingSpaces = (len(titleWithSection) != titleLength)
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...
9266b7019cd0cbe4f741d83191d85c5df713e0c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9266b7019cd0cbe4f741d83191d85c5df713e0c8/cosmetic_changes.py
label = m.group('label')
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...
9266b7019cd0cbe4f741d83191d85c5df713e0c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9266b7019cd0cbe4f741d83191d85c5df713e0c8/cosmetic_changes.py
labelLength = len(label) label = label.rstrip() hadTrailingSpaces = (len(label) != label)
if not trailingChars: labelLength = len(label) label = label.rstrip() hadTrailingSpaces = (len(label) != labelLength)
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...
9266b7019cd0cbe4f741d83191d85c5df713e0c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9266b7019cd0cbe4f741d83191d85c5df713e0c8/cosmetic_changes.py
label = titleWithSection trailingChars = m.group('linktrail') if trailingChars and not hadTrailingSpaces:
label = titleWithSection if 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...
9266b7019cd0cbe4f741d83191d85c5df713e0c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9266b7019cd0cbe4f741d83191d85c5df713e0c8/cosmetic_changes.py
if trailingChars: newLink += 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...
9266b7019cd0cbe4f741d83191d85c5df713e0c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9266b7019cd0cbe4f741d83191d85c5df713e0c8/cosmetic_changes.py
second is a predicate function with an integer parameter that returns true or false if the 1st function applies or not.
second is a predicate function with an integer parameter that returns true or false. When the 2nd function evaluates to true, the 1st function is used.
def multi( value, tuplst ): """This method is used when different patterns are used for the same entry. Example: 1st century, 2nd century, etc. The tuplst is a list of tupples. Each tupple must contain two functions: first to encode/decode a single value (e.g. simpleInt), second is a predicate function with an integer ...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
"""This function helps with matching a single value. formats['CurrEvents']['en'](0) => u'Current Events' formats['CurrEvents']['en'](u'Current Events') => 0"""
return dh_constVal( value, 0, match ) def dh_constVal( value, ind, match ): """This function helps with matching a single value to a constant. formats['CurrEvents']['en'](ind) => u'Current Events' formats['CurrEvents']['en'](u'Current Events') => ind"""
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
if value == 0:
if value == ind:
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
return 0
return ind
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
return unicode(value).translate(_knDigitsToLocal)
return unicode(value).translate(digitsToLocal)
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
tmp = value.translate(_knDigitsToLocal)
tmp = value.translate(digitsToLocal)
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
tmp = value.translate(_knLocalToDigits)
tmp = value.translate(localToDigits)
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'ca' : lambda v: dh_dec( v, u'Dècada del %d' ),
'ca' : lambda v: multi( v, [ (lambda x: dh_dec( x, u'Dècada de %d' ), lambda p: p == 1970), (lambda x: dh_dec( x, u'Dècada del %d' ), alwaysTrue)]),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'fi' : lambda v: dh_dec( v, u'%d-luku' ),
'fi' : lambda v: multi( v, [ (lambda x: dh_dec( x, u'%d-luku' ), lambda p: (p % 100 != 0)), (lambda x: dh_dec( x, u'%d-vuosikymmen' ), alwaysTrue)]),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'hr' : lambda v: dh( v, u'%d-%d', lambda i: (encDec0(i),encDec0(i)+9), lambda v: v[0] ), 'hu' : lambda v: dh_dec( v, u'%d-as évek' ),
'hr' : lambda v: dh( v, u'%d-%d', lambda i: (encDec0(i),encDec0(i)+9), lambda ii: ii[0] ), 'hu' : lambda v: multi( v, [ (lambda x: dh_dec( x, u'%d-ás évek' ), lambda p: p == 0), (lambda x: dh_dec( x, u'%d-as évek' ), lambda p: (p % 100 / 10) in [0,2,3,6,8]), (lambda x: dh_dec( x, u'%d-es év...
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'is' : lambda v: dh( v, u'%d–%d', lambda i: (encDec1(i),encDec1(i)+9), lambda v: v[0]-1 ),
'is' : lambda v: dh( v, u'%d–%d', lambda i: (encDec1(i),encDec1(i)+9), lambda ii: ii[0]-1 ),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_dec( v, u'%d-talet (decennium)' ), lambda x: (x % 100 == 0)), (lambda x: dh_dec( v, u'%d-talet' ), alwaysTrue)]),
(lambda x: dh_dec( x, u'%d-talet (decennium)' ), lambda p: (p % 100 == 0)), (lambda x: dh_dec( x, u'%d-talet' ), alwaysTrue)]),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_dec( x, u'%d-ві' ), lambda x: x == 0 or (x % 100 == 40)), (lambda x: dh_dec( x, u'%d-ні' ), lambda x: x % 1000 == 0),
(lambda x: dh_dec( x, u'%d-ві' ), lambda p: p == 0 or (p % 100 == 40)), (lambda x: dh_dec( x, u'%d-ні' ), lambda p: p % 1000 == 0),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_dec( v, u'%d-talet f.Kr. (decennium)' ), lambda x: (x % 100 == 0)), (lambda x: dh_dec( v, u'%d-talet f.Kr.' ), alwaysTrue)]),
(lambda x: dh_dec( x, u'%d-talet f.Kr. (decennium)' ), lambda p: (p % 100 == 0)), (lambda x: dh_dec( x, u'%d-talet f.Kr.' ), alwaysTrue)]),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_dec( x, u'%d-ві до Р.Х.' ), lambda x: x == 0 or (x % 100 == 40)),
(lambda x: dh_dec( x, u'%d-ві до Р.Х.' ), lambda p: p == 0 or (p % 100 == 40)),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_noConv( v, u'%dste eeu' ), lambda x: x in [1,8] or (x >= 20)), (lambda x: dh_noConv( x, u'%dde eeu' ), alwaysTrue)]),
(lambda x: dh_noConv( x, u'%dste eeu' ), lambda p: p in [1,8] or (p >= 20)), (lambda x: dh_noConv( x, u'%dde eeu' ), alwaysTrue)]), 'als': lambda v: dh_noConv( v, u'%d. Jahrhundert' ),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_noConv( x, u'%dst century' ), lambda x: x == 1 or (x > 20 and x%10 == 1)), (lambda x: dh_noConv( x, u'%dnd century' ), lambda x: x == 2 or (x > 20 and x%10 == 2)), (lambda x: dh_noConv( x, u'%drd century' ), lambda x: x == 3 or (x > 20 and x%10 == 3)),
(lambda x: dh_noConv( x, u'%dst century' ), lambda p: p == 1 or (p > 20 and p%10 == 1)), (lambda x: dh_noConv( x, u'%dnd century' ), lambda p: p == 2 or (p > 20 and p%10 == 2)), (lambda x: dh_noConv( x, u'%drd century' ), lambda p: p == 3 or (p > 20 and p%10 == 3)),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'fi' : lambda v: dh( v, u'%d00-luku', lambda i: i-1, lambda v: v[0]+1 ),
'en' : lambda v: multi( v, [ (lambda x: dh_constVal( x, 20, u'سده ۲۰ (میلادی)'), lambda p: p == 20)]), 'fi' : lambda v: dh( v, u'%d00-luku', lambda i: i-1, lambda ii: ii[0]+1 ),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_noConv( v, u'%dsa kansblydhen' ), lambda x: x <= 3), (lambda x: dh_noConv( v, u'%da kansblydhen' ), lambda x: x == 4), (lambda x: dh_noConv( v, u'%des kansblydhen' ), lambda x: x == 5), (lambda x: dh_noConv( v, u'%dns kansblydhen' ), lambda x: x >= 20), (lambda x: dh_noConv( v, u'%dves kansblydhen' ), alw...
(lambda x: dh_noConv( x, u'%dsa kansblydhen' ), lambda p: p <= 3), (lambda x: dh_noConv( x, u'%da kansblydhen' ), lambda p: p == 4), (lambda x: dh_noConv( x, u'%des kansblydhen' ), lambda p: p == 5), (lambda x: dh_noConv( x, u'%dns kansblydhen' ), lambda p: p >= 20), (lambda x: dh_noConv( x, u'%dves kansblydhen' )...
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'li' : lambda v: slh( v, [u'Ierste iew', u'Twiede iew', u'Derde iew', u'Veerde iew', u'Viefde iew', u'Zesde iew', u'Zevende iew', u'Achste iew', u'Negende iew', u'Tiende iew', u'Elfde iew', u'Twelfde iew', u'Dertiende iew', u'Veertiende iew', u'Vieftiende iew', u'Zestiende iew', u'Zeventiende iew', u'Achtiende i...
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
'nn' : lambda v: dh( v, u'%d00-talet', lambda i: i-1, lambda v: v[0]+1 ),
'nn' : lambda v: dh( v, u'%d00-talet', lambda i: i-1, lambda ii: ii[0]+1 ),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py
(lambda x: dh_noConv( x, u'%dst century' ), lambda x: x == 1 or (x > 20 and x%10 == 1)), (lambda x: dh_noConv( x, u'%dnd century' ), lambda x: x == 2 or (x > 20 and x%10 == 2)), (lambda x: dh_noConv( x, u'%drd century' ), lambda x: x == 3 or (x > 20 and x%10 == 3)),
(lambda x: dh_noConv( x, u'%dst century' ), lambda p: p == 1 or (p > 20 and p%10 == 1)), (lambda x: dh_noConv( x, u'%dnd century' ), lambda p: p == 2 or (p > 20 and p%10 == 2)), (lambda x: dh_noConv( x, u'%drd century' ), lambda p: p == 3 or (p > 20 and p%10 == 3)),
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...
32e5f5c1a30bc02fc3075b9c456f10fafab05a66 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/32e5f5c1a30bc02fc3075b9c456f10fafab05a66/date.py