rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
'simple' : lambda v: dh_noConv( v, u'%dth century' ),
'simple' : lambda v: multi( v, [ (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_noCon...
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
def dh_knYearConverter( value ): if type(value) is int: # Encode an integer value into a textual form. return unicode(value).translate(_knDigitsToLocal) else: # First make sure there are no real digits in the string tmp = value.translate(_knDigitsToLocal) # Test if tmp == value: tmp = value.translate(_knLocalTo...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
def addFmt( type, lang, isMnthOfYear, patterns ): """Add 12 month formats for a specific type ('January','Feb..), for a given language. The function must accept one parameter for the ->int or ->string conversions, just like everywhere else in the formats map. The patterns parameter is a list of 12 elements to be used f...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
def addFmt( type, lang, isMnthOfYear, patterns ): """Add 12 month formats for a specific type ('January','Feb..), for a given language. The function must accept one parameter for the ->int or ->string conversions, just like everywhere else in the formats map. The patterns parameter is a list of 12 elements to be used f...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
addFmt( dayMnthFmts, 'af', False, makeMonthNamedList( 'af', u"%%d %s", True )) addFmt( dayMnthFmts, 'an', False, [ u"%d de chinero", u"%d de frebero", u"%d de marzo", u"%d d'abril", u"%d de mayo", u"%d de chunio", u"%d de chulio", u"%d d'agosto", u"%d de setiembre", u"%d d'otubre", u"%d de nobiembre", u"%d d'abiento"...
addFmt( dayMnthFmts, 'af', False, makeMonthNamedList( 'af', u"%%d %s", True )) addFmt( dayMnthFmts, 'an', False, [ u"%d de chinero", u"%d de frebero", u"%d de marzo", u"%d d'abril", u"%d de mayo", u"%d de chunio", u"%d de chulio", u"%d d'agosto", u"%d de setiembre", u"%d d'otubre", u"%d de nobiembre", u"%d ...
def makeMonthNamedList( lang, pattern, makeUpperCase = None ): """Creates a list of 12 elements based on the name of the month. The language-dependent month name is used as a formating argument to the pattern. The pattern must be have one %s that will be replaced by the localized month name. Use %%d for any other param...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
addFmt( dayMnthFmts, 'wa', False, [ u"%d di djanvî", u"%d di fevrî", u"%d di måss", u"%d di avri", u"%d di may", u"%d di djun", u"%d di djulete", u"%d d' awousse", u"%d di setimbe", u"%d d' octôbe", u"%d di nôvimbe", u"%d di decimbe" ]) addFmt( dayMnthFmts, 'zh', False, makeMonthList( u"%d月%%d日" ))
addFmt( dayMnthFmts, 'wa', False, [ u"%d di djanvî", u"%d di fevrî", u"%d di måss", u"%d di avri", u"%d di may", u"%d di djun", u"%d di djulete", u"%d d' awousse", u"%d di setimbe", u"%d d' octôbe", u"%d di nôvimbe", u"%d di decimbe" ]) addFmt( dayMnthFmts, 'zh', False, makeMonthList( u"%d月%%d日" ))
def makeMonthNamedList( lang, pattern, makeUpperCase = None ): """Creates a list of 12 elements based on the name of the month. The language-dependent month name is used as a formating argument to the pattern. The pattern must be have one %s that will be replaced by the localized month name. Use %%d for any other param...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
addFmt( yrMnthFmts, 'af', True, makeMonthNamedList( 'af', u"%s %%d", True )) addFmt( yrMnthFmts, 'ang',True, [ None, None, None, None, None, None, None, None, None, None, None, u"Gēolmōnaþ %d" ]) addFmt( yrMnthFmts, 'de', True, makeMonthNamedList( 'de', u"%s %%d", True )) addFmt( yrMnthFmts, 'el', True, makeMonthNa...
addFmt( yrMnthFmts, 'af', True, makeMonthNamedList( 'af', u"%s %%d", True )) addFmt( yrMnthFmts, 'ang',True, [ None, None, None, None, None, None, None, None, None, None, None, u"Gēolmōnaþ %d" ]) addFmt( yrMnthFmts, 'de', True, makeMonthNamedList( 'de', u"%s %%d", True )) addFmt( yrMnthFmts, 'el', True, ...
def makeMonthNamedList( lang, pattern, makeUpperCase = None ): """Creates a list of 12 elements based on the name of the month. The language-dependent month name is used as a formating argument to the pattern. The pattern must be have one %s that will be replaced by the localized month name. Use %%d for any other param...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
import wikipedia
def printMonthArray( lang, pattern, capitalize ): """ """ import wikipedia for s in makeMonthNamedList( lang, pattern, capitalize ): wikipedia.output( s )
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
import wikipedia
start,end,step = formatLimits[m] if showAll: wikipedia.output(u"Limits: from %d to %d, with step %d" % (start,stop,step))
def testMapEntry( showAll, m, year, testYear ): """This is a test function, to be used interactivelly to test the validity of the above maps. To test, run this function with the map name, year to be tested, and the final year expected. Usage example: run python interpreter >>> import date >>> date.testMapEntry( 'Decade...
eca5b286217783206ef7fe36053a5ca8845bdaef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/eca5b286217783206ef7fe36053a5ca8845bdaef/date.py
+ "<a href=.+? class=\"new\" title=.+?>.+?<\/a><\/p>\n"
+ "<a href=.+? title=.+?>.+?<\/a><\/p>\n"
def refresh_messages(): host = wikipedia.family.hostname(wikipedia.mylang) # broken redirect maintenance page's URL url = wikipedia.family.allmessages_address(wikipedia.mylang) print 'Retrieving MediaWiki messages...' allmessages, charset = wikipedia.getUrl(host,url) #f=open('/home/daniel/allmessages.html', 'r') #allm...
bfb5ca98f66d10ed554af12556500d242895d127 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bfb5ca98f66d10ed554af12556500d242895d127/mediawiki_messages.py
x=urllib.unquote(str(percentname))
x = urllib.unquote(str(percentname))
def url2unicode(percentname, site): # Does the input string contain non-ascii characters? In that case, # it is not really an url, and we do not have to unquote it.... for c in percentname: if ord(c)>128: x=percentname break else: # Before removing the % encoding, make sure it is an ASCII string. # unquote doesn't work...
31ab56fe544dc7fee708c6c5976f3138512d6894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/31ab56fe544dc7fee708c6c5976f3138512d6894/wikipedia.py
x = x.encode(encoding) return x
return x.decode(encoding)
def url2unicode(percentname, site): # Does the input string contain non-ascii characters? In that case, # it is not really an url, and we do not have to unquote it.... for c in percentname: if ord(c)>128: x=percentname break else: # Before removing the % encoding, make sure it is an ASCII string. # unquote doesn't work...
31ab56fe544dc7fee708c6c5976f3138512d6894 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/31ab56fe544dc7fee708c6c5976f3138512d6894/wikipedia.py
entryR = re.compile('<li>(?P<date>.+?) <a href=".+?" title="(?P<title>.+?)">.+?</a> \((?P<length>\d+)(.+?)\) \. \. (?P<loggedin><a href=".+?" title=".+?">)?(?P<username>.+?)(</a>)?( <em>\((?P<comment>.+?)\)</em>)?</li>')
entryR = re.compile('<li[^>]*>(?P<date>.+?) \S*?<a href=".+?" title="(?P<title>.+?)">.+?</a>.+?\((?P<length>\d+)(.+?)\) \. \. (.*?)(?P<loggedin><a href=".+?" title="(?P<username>.+?)">)')
def newpages(self, number = 10, repeat = False): """Generator which yields new articles subsequently. It starts with the article created 'number' articles ago (first argument). When these are all yielded it fetches NewPages again. If there is no new page, it blocks until there is one, sleeping between subsequent fetche...
7866b68ae9654e4e00321a998aade0541a053a4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7866b68ae9654e4e00321a998aade0541a053a4b/wikipedia.py
comment = m.group('comment')
def newpages(self, number = 10, repeat = False): """Generator which yields new articles subsequently. It starts with the article created 'number' articles ago (first argument). When these are all yielded it fetches NewPages again. If there is no new page, it blocks until there is one, sleeping between subsequent fetche...
7866b68ae9654e4e00321a998aade0541a053a4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7866b68ae9654e4e00321a998aade0541a053a4b/wikipedia.py
yield page, date, length, loggedIn, username, comment
yield page, date, length, loggedIn, username, None
def newpages(self, number = 10, repeat = False): """Generator which yields new articles subsequently. It starts with the article created 'number' articles ago (first argument). When these are all yielded it fetches NewPages again. If there is no new page, it blocks until there is one, sleeping between subsequent fetche...
7866b68ae9654e4e00321a998aade0541a053a4b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7866b68ae9654e4e00321a998aade0541a053a4b/wikipedia.py
defdis = self.site().family.disambig( "_default" )
def isDisambig(self): if not hasattr(self, '_isDisambig'): defdis = self.site().family.disambig( "_default" ) locdis = self.site().family.disambig( self._site.lang )
769cab4d0697135c75febc0fd870ce1ef6e6fed3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/769cab4d0697135c75febc0fd870ce1ef6e6fed3/wikipedia.py
if tn in defdis or tn in locdis:
if tn in locdis:
def isDisambig(self): if not hasattr(self, '_isDisambig'): defdis = self.site().family.disambig( "_default" ) locdis = self.site().family.disambig( self._site.lang )
769cab4d0697135c75febc0fd870ce1ef6e6fed3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/769cab4d0697135c75febc0fd870ce1ef6e6fed3/wikipedia.py
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % oldCat.title())
wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % self.oldCat.title())
def __init__(self, oldCatTitle, newCatTitle): self.oldCat = catlib.Category(wikipedia.getSite(), 'Category:' + oldCatTitle) self.newCatTitle = newCatTitle # get edit summary message wikipedia.setAction(wikipedia.translate(wikipedia.getSite(),msg_change) % oldCat.title())
37bfebc555b9c3d181b8deec5e4e0f7eda5daaa9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/37bfebc555b9c3d181b8deec5e4e0f7eda5daaa9/category.py
'nds': [u'Begreepkloren'],
'nds': [u'Mehrdüdig Begreep'],
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
bb039b740b8914e8939e4cbbdec33d3a6c662d16 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/bb039b740b8914e8939e4cbbdec33d3a6c662d16/wikipedia_family.py
output(u"ERROR> link from %s to %s:%s has leading colon?!" % (self, newsite, newname))
output(u"ERROR> link from %s to %s:%s has leading colon?!" % (self.linkname(), newsite, newname))
def interwiki(self): """A list of interwiki links in the page. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method.
dd21c21fb227369c85f39d2a7bae950123d42d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dd21c21fb227369c85f39d2a7bae950123d42d24/wikipedia.py
output(u"ERROR> link from %s to %s:%s has leading space?!" % (self, newsite, newname))
output(u"ERROR> link from %s to %s:%s has leading space?!" % (self.linkname(), newsite, newname))
def interwiki(self): """A list of interwiki links in the page. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method.
dd21c21fb227369c85f39d2a7bae950123d42d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dd21c21fb227369c85f39d2a7bae950123d42d24/wikipedia.py
output(u"ERROR> link from %s to %s:%s is invalid encoding?!" % (self, newsite, newname))
output(u"ERROR> link from %s to %s:%s is invalid encoding?!" % (self.linkname(), newsite, newname))
def interwiki(self): """A list of interwiki links in the page. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method.
dd21c21fb227369c85f39d2a7bae950123d42d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dd21c21fb227369c85f39d2a7bae950123d42d24/wikipedia.py
output(u"ERROR> link from %s to %s:%s contains invalid character?!" % (self, newsite, newname))
output(u"ERROR> link from %s to %s:%s contains invalid character?!" % (self.linkname(), newsite, newname))
def interwiki(self): """A list of interwiki links in the page. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method.
dd21c21fb227369c85f39d2a7bae950123d42d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dd21c21fb227369c85f39d2a7bae950123d42d24/wikipedia.py
output(u"ERROR> link from %s to %s:%s contains invalid unicode reference?!" % (self, newsite, newname))
output(u"ERROR> link from %s to %s:%s contains invalid unicode reference?!" % (self.linkname(), newsite, newname))
def interwiki(self): """A list of interwiki links in the page. This will retrieve the page text to do its work, so it can raise the same exceptions that are raised by the get() method.
dd21c21fb227369c85f39d2a7bae950123d42d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dd21c21fb227369c85f39d2a7bae950123d42d24/wikipedia.py
templateR=re.compile(r'\{\{([mM][sS][gG]:)?[' + self.old[0].upper() + self.old[0].lower() + ']' + self.old[1:] + '(?P<sortkey>\|[^}]+)?}}')
templateR=re.compile(r'\{\{([mM][sS][gG]:)?[' + self.old[0].upper() + self.old[0].lower() + ']' + self.old[1:] + '(?P<sortkey>\|[^}]+|)}}')
def run(self): # regular expression to find the original template. # {{msg:vfd}} does the same thing as {{msg:Vfd}}, so both will be found. # The new syntax, {{vfd}}, will also be found. templateR=re.compile(r'\{\{([mM][sS][gG]:)?[' + self.old[0].upper() + self.old[0].lower() + ']' + self.old[1:] + '(?P<sortkey>\|[^}]+...
340022ae7ee4898baa4672ae2fda10d9bfdd0949 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/340022ae7ee4898baa4672ae2fda10d9bfdd0949/template.py
print "DBG> addEntity:", repr(name), repr(result)
def addEntity(name): """Convert a unicode name into ascii name with entities""" import htmlentitydefs result = '' for c in name: if ord(c) < 128: result += str(c) else: for k, v in htmlentitydefs.entitydefs.iteritems(): if (len(v) == 1 and ord(c) == ord(v)) or v == '&#%d;'%ord(c): result += '&%s;' % k break else: raise...
f0baaa6839c6e1ebee76a315015d5deda2f4bfeb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f0baaa6839c6e1ebee76a315015d5deda2f4bfeb/wikipedia.py
wikipedia.action += wrd
wikipedia.setAction('Robot-assisted disambiguation '+wrd)
def getreferences(pl): host = wikipedia.langs[pl.code()] url="/w/wiki.phtml?title=Speciaal:Whatlinkshere&target=%s"%(pl.urlname()) txt,charset=wikipedia.getUrl(host,url) Rref=re.compile('<li><a href.* title="([^"]*)"') return Rref.findall(txt)
df48ab896d7d80ef01ed1f429618f79139dae4d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/df48ab896d7d80ef01ed1f429618f79139dae4d5/solve_disambiguation.py
print "== %s =="%(refpl),m.start(),m.end()
print "== %s =="%(refpl)
def getreferences(pl): host = wikipedia.langs[pl.code()] url="/w/wiki.phtml?title=Speciaal:Whatlinkshere&target=%s"%(pl.urlname()) txt,charset=wikipedia.getUrl(host,url) Rref=re.compile('<li><a href.* title="([^"]*)"') return Rref.findall(txt)
df48ab896d7d80ef01ed1f429618f79139dae4d5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/df48ab896d7d80ef01ed1f429618f79139dae4d5/solve_disambiguation.py
'ka' : lambda v: dh_dayOfMnth( v, u'%d იანვარი' ),
'ka' : lambda v: dh_dayOfMnth( v, u'%d იანვარი' ),
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...
c63f7936273a9e20f9ecd868127b6fb80f5e823e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c63f7936273a9e20f9ecd868127b6fb80f5e823e/date.py
'ia' : lambda v: dh_dayOfMnth( v, u'%d de decembre' ),
'ia' : lambda v: dh_dayOfMnth( v, u'%d de Decembre' ),
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...
c63f7936273a9e20f9ecd868127b6fb80f5e823e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/c63f7936273a9e20f9ecd868127b6fb80f5e823e/date.py
self.loggedin = 'Userlogin' not in txt
self._loggedin = 'Userlogin' not in txt
def loggedin(self, check = False): if not hasattr(self,'_loggedin'): self._fill() if check: txt = getPage(self, 'Non-existing page', get_edit_page = False) self.loggedin = 'Userlogin' not in txt return self._loggedin
4a3684af139bda44d84cfdfd02da7965d191586b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/4a3684af139bda44d84cfdfd02da7965d191586b/wikipedia.py
if not globalvar.autonomous:
if globalvar.autonomous: if self.inpl.isDisambig() and not pl.isDisambig(): wikipedia.output(u"NOTE: Ignoring link from disambiguation page %s to non-disambiguation %s" % (self.inpl.aslink(forceInterwiki = True), pl.aslink(forceInterwiki = True))) del self.done[pl] elif not self.inpl.isDisambig() and pl.isDisambig(): w...
def workDone(self, counter): """This is called by a worker to tell us that the promised work was completed as far as possible. The only argument is an instance of a counter class, that has methods minus() and plus() to keep counts of the total work todo.""" # Loop over all the pages that should have been taken care of ...
d0234998ad2c450d18ca82954a3c40986bc05c9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d0234998ad2c450d18ca82954a3c40986bc05c9e/interwiki.py
firstLabel = '"%s:%s"' % (inpl.site().language(), wikipedia.unicode2html(inpl.title(), 'ascii'))
firstLabel = '"%s:%s"' % (self.inpl.site().language(), wikipedia.unicode2html(inpl.title(), 'ascii'))
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') ...
cb4d87fe4acd8d7f5519487daea96863ab5a0154 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/cb4d87fe4acd8d7f5519487daea96863ab5a0154/interwiki.py
result[k] = v[answer-1] break
try: result[k] = v[answer-1] except IndexError: pass else: break
def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the code as key. # Each value will be a list. new = {} for pl in self.done.keys(): code = pl.code() if code == wikipedia.mylang and pl.exists() and not pl.isRedirectPage() and not pl.isEmpty(): if pl != self....
9f42032e72cf07ecb1528b2c6a69ee8d0a50ba1b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/9f42032e72cf07ecb1528b2c6a69ee8d0a50ba1b/interwiki.py
pl = wikipedia.PageLink(wikipedia.getSit(), refpage)
pl = wikipedia.PageLink(wikipedia.getSite(), refpage)
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...
74d9d9b59d3cc5cbc230f5b0767cfda6c261d2be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/74d9d9b59d3cc5cbc230f5b0767cfda6c261d2be/category.py
def print_treeview(catname, max_depth = 10): """ Prints the multi-line string generated by treeview or saves it to a file. Parameters: * catname - the title of the category which will be the tree's root * max_depth - the limit beyond which no subcategories will be listed """ # TODO: make max_depth changeable with a pa...
74d9d9b59d3cc5cbc230f5b0767cfda6c261d2be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/74d9d9b59d3cc5cbc230f5b0767cfda6c261d2be/category.py
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[0]) + ",".join([x.lang for x in adding])
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[0]) + " " + ", ".join([x.lang for x in adding])
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:"...
2d60eab01a8f8ce486347930a6d545a0a8e97b01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2d60eab01a8f8ce486347930a6d545a0a8e97b01/interwiki.py
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[1]) + ",".join([x.lang for x in removing])
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[1]) + " " + ", ".join([x.lang for x in removing])
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:"...
2d60eab01a8f8ce486347930a6d545a0a8e97b01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2d60eab01a8f8ce486347930a6d545a0a8e97b01/interwiki.py
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[2]) + ",".join([x.lang for x in modifying])
s = s + " %s:" % (wikipedia.translate(mysite.lang, msg)[2]) + " " + ", ".join([x.lang for x in modifying])
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:"...
2d60eab01a8f8ce486347930a6d545a0a8e97b01 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/2d60eab01a8f8ce486347930a6d545a0a8e97b01/interwiki.py
i = 0 for page in self.pageGenerator: if page not in globalvar.skip: i += 1
for i in range(number): try: page = self.pageGenerator.next() while page in globalvar.skip: page = self.pageGenerator.next()
def generateMore(self, number): """Generate more subjects. This is called internally when the list of subjects becomes to small, but only if there is a PageGenerator""" fs = self.firstSubject() if fs: wikipedia.output(u"NOTE: The first unfinished subject is " + fs.pl().aslink()) print "NOTE: Number of pages queued is %...
3e3aff92db609309ad67c18ea48c5692d7bcb0c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3e3aff92db609309ad67c18ea48c5692d7bcb0c6/interwiki.py
if i >= number: return self.pageGenerator = None
except StopIteration: self.pageGenerator = None break
def generateMore(self, number): """Generate more subjects. This is called internally when the list of subjects becomes to small, but only if there is a PageGenerator""" fs = self.firstSubject() if fs: wikipedia.output(u"NOTE: The first unfinished subject is " + fs.pl().aslink()) print "NOTE: Number of pages queued is %...
3e3aff92db609309ad67c18ea48c5692d7bcb0c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3e3aff92db609309ad67c18ea48c5692d7bcb0c6/interwiki.py
bot.setPageGenerator(hintlessPageGen)
bot.setPageGenerator(iter(hintlessPageGen))
def readWarnfile(filename, sa): import warnfile reader = warnfile.WarnfileReader(filename) # we won't use removeHints (hints, removeHints) = reader.getHints() pages = hints.keys() for page in pages: # The WarnfileReader gives us a list of pagelinks, but titletranslate.py expects a list of strings, so we convert it back...
3e3aff92db609309ad67c18ea48c5692d7bcb0c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/3e3aff92db609309ad67c18ea48c5692d7bcb0c6/interwiki.py
ns = []
namespaces = []
def category_namespaces(code): ns = [] if not category.has_key(code): #print "DBG> No category namespace known for %s" % code import mediawiki_messages ns.append(mediawiki_messages.get('nstab-category', lang = code)) else: ns.append(category[code]) ns.append(category[code].lower()) if category[code] != category['en']: ...
42ea9e6438b59a3fbf631d49715bbb819828bfbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/42ea9e6438b59a3fbf631d49715bbb819828bfbf/wikipedia_family.py
def category_namespaces(code): ns = [] if not category.has_key(code): #print "DBG> No category namespace known for %s" % code import mediawiki_messages ns.append(mediawiki_messages.get('nstab-category', lang = code)) else: ns.append(category[code]) ns.append(category[code].lower()) if category[code] != category['en']: ...
42ea9e6438b59a3fbf631d49715bbb819828bfbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/42ea9e6438b59a3fbf631d49715bbb819828bfbf/wikipedia_family.py
ns.append(mediawiki_messages.get('nstab-category', lang = code))
namespace_title = mediawiki_messages.get('nstab-category', lang = code)
def category_namespaces(code): ns = [] if not category.has_key(code): #print "DBG> No category namespace known for %s" % code import mediawiki_messages ns.append(mediawiki_messages.get('nstab-category', lang = code)) else: ns.append(category[code]) ns.append(category[code].lower()) if category[code] != category['en']: ...
42ea9e6438b59a3fbf631d49715bbb819828bfbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/42ea9e6438b59a3fbf631d49715bbb819828bfbf/wikipedia_family.py
ns.append(category[code]) ns.append(category[code].lower()) if category[code] != category['en']: ns.append(category['en']) ns.append(category['en'].lower()) return ns
namespace_title = category[code] namespaces.append(namespace_title) namespaces.append(namespace_title.lower()) if namespace_title != category['en']: namespaces.append(category['en']) namespaces.append(category['en'].lower()) return namespaces
def category_namespaces(code): ns = [] if not category.has_key(code): #print "DBG> No category namespace known for %s" % code import mediawiki_messages ns.append(mediawiki_messages.get('nstab-category', lang = code)) else: ns.append(category[code]) ns.append(category[code].lower()) if category[code] != category['en']: ...
42ea9e6438b59a3fbf631d49715bbb819828bfbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/42ea9e6438b59a3fbf631d49715bbb819828bfbf/wikipedia_family.py
ns = wikipedia.family.category_namespaces(wikipedia.mylang) cat_namespace = ns[0].encode(wikipedia.myencoding())
cat_namespace = wikipedia.family.category_namespace(wikipedia.mylang)
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...
a072f60ffe416d383a3769672b31b3981ab29025 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a072f60ffe416d383a3769672b31b3981ab29025/category.py
print "WARNING: Link to unknown language %s" % (match.group(1))
print "WARNING: Link to unknown language %s" % (interwikiMatch.group(1))
def removeLanguageLinks(text, site = None): """Given the wiki-text of a page, return that page with all interwiki links removed. If a link to an unknown language is encountered, a warning is printed.""" if site == None: site = getSite() # This regular expression will find every link that is possibly an # interwiki link...
b7d4fa477f88c561305f357c169aeb2b0357b085 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b7d4fa477f88c561305f357c169aeb2b0357b085/wikipedia.py
print "OK. I'm not uploading"
def convert(text): ''' Converts all HTML tables in text to wiki syntax. If text contains wiki tables, tries to beautify them. Returns converted text if page was successfully changed, otherwise returns None. ''' warnings = 0 # this array will contain strings that will be shown in case of possible # errors, before the us...
a8cdc42d9509bed8e7853c1e8165b54e34df9c10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a8cdc42d9509bed8e7853c1e8165b54e34df9c10/table2wiki.py
print "No changes were necessary in " + article
print "No changes were necessary"
def convert(text): ''' Converts all HTML tables in text to wiki syntax. If text contains wiki tables, tries to beautify them. Returns converted text if page was successfully changed, otherwise returns None. ''' warnings = 0 # this array will contain strings that will be shown in case of possible # errors, before the us...
a8cdc42d9509bed8e7853c1e8165b54e34df9c10 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a8cdc42d9509bed8e7853c1e8165b54e34df9c10/table2wiki.py
self.langs[lang] = lang+'.wikipedia.org'
if lang not in self.langs: self.langs[lang] = lang+'.wikipedia.org'
def __init__(self): family.Family.__init__(self) self.name = 'wikipedia'
dcc78e240cbce1efadbdbb742d29a10ed7ab07ba /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/dcc78e240cbce1efadbdbb742d29a10ed7ab07ba/wikipedia_family.py
pass try: thistxt = removeCategoryLinks(self.get(), self.code()) except IsRedirectPage: pass
return thistxt = removeCategoryLinks(thistxt, self.code())
def links(self): # Gives the normal (not-interwiki, non-category) pages the page # directs to, as strings result = [] try: thistxt = removeLanguageLinks(self.get()) except IsRedirectPage: pass try: thistxt = removeCategoryLinks(self.get(), self.code()) except IsRedirectPage: pass w=r'([^\]\|]*)' Rlink = re.compile(r'\[...
863b07175505667441be704084680a3f72623b17 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/863b07175505667441be704084680a3f72623b17/wikipedia.py
return getPage(self.code(),self.urlname())
if not hasattr(self,'_contents'): self._contents=getPage(self.code(),self.urlname()) return self._contents
def get(self): return getPage(self.code(),self.urlname())
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
('wpEdittime', edittime[code,space2underline(name)]),
('wpEdittime', edittime[code,link2url(name,code)]),
def putPage(code, name, text, comment=None): """Upload 'text' on page 'name' to the 'code' language wikipedia.""" import httplib host = langs[code] if host[-4:] == '.com': raise Error("Cannot put pages on a .com wikipedia") address = '/w/wiki.phtml?title=%s&action=submit'%space2underline(name) if comment is None: comme...
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
uo=urllib.FancyURLopener()
uo=MyURLopener()
def getUrl(host,address): uo=urllib.FancyURLopener() f=uo.open('http://%s%s'%(host,address)) text=f.read() ct=f.info()['Content-Type'] R=re.compile('charset=([^\'\"]+)') m=R.search(ct) if m: charset=m.group(1) else: charset=None return text,charset
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
edittime[code,space2underline(name)]=m.group(1)
edittime[code,link2url(name,code)]=m.group(1)
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('...
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
edittime[code,name]=m.group(1)
edittime[code,link2url(name,code)]=m.group(1)
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('...
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
edittime[code,name]=0
edittime[code,link2url(name,code)]=0
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('...
13c34ebdb18669c5213a85367d51775d0cb8e26f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/13c34ebdb18669c5213a85367d51775d0cb8e26f/wikipedia.py
description = raw_input('Description : ')
description = description.encode('utf-8') if description=='': description = raw_input('Description : ')
def get_image(fn,target,description): # Get file contents uo = wikipedia.MyURLopener() file = uo.open(fn) contents = file.read() file.close() # Isolate the pure name if '/' in fn: fn = fn.split('/')[-1] if '\\' in fn: fn = fn.split('\\')[-1] print "The filename on wikipedia will default to:",fn newfn = raw_input("Bette...
7f20160c07b590d8ec6ecbf6ca4ed0e964035c83 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7f20160c07b590d8ec6ecbf6ca4ed0e964035c83/lib_images.py
pls.append(pl) i += 1 if i >= 60: self.start = pl.urlname() + '!' break wikipedia.getall(wikipedia.getSite(), pls) for pl in pls: if not pl.isRedirectPage(): yield pl.linkname(), pl.get()
pls.append(pl) i += 1 if i >= 60: wikipedia.getall(wikipedia.getSite(), pls) for pl in pls: if not pl.isRedirectPage(): yield pl.linkname(), pl.get() i = 0 pls = []
def generate(self): while True: i = 0 pls = [] for pl in wikipedia.allpages(start = self.start): pls.append(pl) i += 1 if i >= 60: self.start = pl.urlname() + '!' break wikipedia.getall(wikipedia.getSite(), pls) for pl in pls: if not pl.isRedirectPage(): yield pl.linkname(), pl.get()
e68ece15539bd9fa1bd8a963d733252156bf4c84 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/e68ece15539bd9fa1bd8a963d733252156bf4c84/weblinkchecker.py
acceptall = True
self.acceptall = True
def run(self): """ Starts the robot. """ # Run the generator which will yield PageLinks to pages which might need to be # changed. for pl in self.generator(): print '' try: # Load the page's text from the wiki original_text = pl.get() except wikipedia.NoPage: wikipedia.output(u'Page %s not found' % pl.linkname()) conti...
f362334a59524e439f8e3ae5258248e1de9f9853 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f362334a59524e439f8e3ae5258248e1de9f9853/replace.py
newTable = re.sub("(CAPTION|caption)([\w\W]*?)<\/caption>",
newTable = re.sub("<(CAPTION|caption)([\w\W]*?)<\/caption>",
def convertTable(self, table): ''' Converts an HTML table to wiki syntax. If the table already is a wiki table or contains a nested wiki table, tries to beautify it. Returns the converted table, the number of warnings that occured and a list containing these warnings.
747a2da52898455e5a09b544388a4ce7cb928af7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/747a2da52898455e5a09b544388a4ce7cb928af7/table2wiki.py
fix = fixes[fix]
try: fix = fixes[fix] except KeyError: wikipedia.output(u'Available predefined fixes are: %s' % fixes.keys()) sys.exit()
def generator(source, replacements, exceptions, regex, namespace, textfilename = None, sqlfilename = None, pagenames = None): ''' Generator which will yield PageLinks for pages that might contain text to replace. These pages might be retrieved from a local SQL dump file or a text file, or as a list of pages entered by ...
16c69a5b8d29e00341786f0a35452415b62b5554 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/16c69a5b8d29e00341786f0a35452415b62b5554/replace.py
1: 31, 2: 29, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 }
1: 31, 2: 29, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31 }
def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.code]) % d, language = self.code)
ca48d3138797b7e59dd655330057f8c316aa4626 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ca48d3138797b7e59dd655330057f8c316aa4626/date.py
yearBCfmt = {'da':'%d f.Kr.', 'de':'%d v. Chr.', 'en':'%d BC', 'fr':'-%d', 'pl':'%d p.n.e.', 'es':'%d adC', 'eo':'-%d', 'nl':'%d v. Chr.'}
yearBCfmt = { 'da':'%d f.Kr.', 'de':'%d v. Chr.', 'en':'%d BC', 'fr':'-%d', 'pl':'%d p.n.e.', 'es':'%d adC', 'eo':'-%d', 'nl':'%d v. Chr.', 'is':'%d f. Kr.' }
def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.code]) % d, language = self.code)
ca48d3138797b7e59dd655330057f8c316aa4626 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ca48d3138797b7e59dd655330057f8c316aa4626/date.py
yearADfmt = {'ja':'%d& 'zh':'%d& 'ko':'%d& }
yearADfmt = { 'ja':'%d& 'zh':'%d& 'ko':'%d& }
def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.code]) % d, language = self.code)
ca48d3138797b7e59dd655330057f8c316aa4626 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ca48d3138797b7e59dd655330057f8c316aa4626/date.py
datetable = {'nl': { 'januari':{ 'sl':'%d. januar', 'it':'%d gennaio', 'en':'January %d', 'de':'%d. Januar', 'fr':'%d janvier', 'af':'01-%02d', 'ca':'%d de gener', 'oc':'%d de geni%%C3%%A8r', }, 'februari':{ 'sl':'%d. februar', 'it':'%d febbraio', 'en':'February %d', 'de':'%d. Februar', 'fr':'...
datetable = { 'nl':{ 'januari':{ 'sl':'%d. januar', 'it':'%d gennaio', 'en':'January %d', 'de':'%d. Januar', 'fr':'%d janvier', 'af':'01-%02d', 'ca':'%d de gener', 'oc':'%d de geni%%C3%%A8r', 'is':'%d. janúar', }, 'februari':{ 'sl':'%d. februar', 'it':'%d febbraio', 'en':'February %d', 'de':'%d. Februar', 'fr':'%d fevr...
def __call__(self, m, d): import wikipedia return wikipedia.html2unicode((date_format[m][self.code]) % d, language = self.code)
ca48d3138797b7e59dd655330057f8c316aa4626 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/ca48d3138797b7e59dd655330057f8c316aa4626/date.py
isoDate = time.strftime('%Y-%m-%d %H:%M:%S', date)
isoDate = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(date))
def log(self, url, error, containingPage): """ Logs an error report to a text file in the deadlinks subdirectory. """ site = wikipedia.getSite() errorReport = u'* %s\n' % url for (pageTitle, date, error) in self.historyDict[url]: # ISO 8601 formulation isoDate = time.strftime('%Y-%m-%d %H:%M:%S', date) errorReport += "...
f8a8b843fb94eb866aa003936cd43d66caab5c93 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f8a8b843fb94eb866aa003936cd43d66caab5c93/weblinkchecker.py
elif pl.linkname().lower() == pl.linkname():
elif pl.linkname()[0].upper() == pl.linkname()[0]:
def sametranslate(pl, arr, same): site = pl.site() for newcode in site.family.seriouslangs: # Put as suggestion into array newname = pl.linkname() if newcode in ['eo','cs'] and same == 'name': newname = newname.split(' ') newname[-1] = newname[-1].upper() newname = ' '.join(newname) x=wikipedia.PageLink(wikipedia.getSi...
b86ff826b1ebd215ad7b8fbbaa420ccc5387a0e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/b86ff826b1ebd215ad7b8fbbaa420ccc5387a0e4/titletranslate.py
start = None
start = u'!'
def main(): start = None 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 start: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikipedia.Page(wi...
f4437fa35847ac0ebea26bc2934c0d958cd4f107 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f4437fa35847ac0ebea26bc2934c0d958cd4f107/weblinkchecker.py
if start:
if pageTitle == []:
def main(): start = None 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 start: gen = pagegenerators.AllpagesPageGenerator(start) else: pageTitle = ' '.join(pageTitle) page = wikipedia.Page(wi...
f4437fa35847ac0ebea26bc2934c0d958cd4f107 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f4437fa35847ac0ebea26bc2934c0d958cd4f107/weblinkchecker.py
wikipedia.output(u"* %s" % pl.aslink())
wikipedia.output(u"* %s" % curpl.aslink())
def add_category(sort_by_last_name = False): ''' A robot to mass-add a category to a list of pages. ''' print "This bot has two modes: you can add a category link to all" print "pages mentioned in a List that is now in another wikipedia page" print "or you can add a category link to all pages that link to a" print "spe...
f6ecf9a5931e1c4c8aac83057e513ba1985e64ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f6ecf9a5931e1c4c8aac83057e513ba1985e64ab/category.py
cats.append(catpl)
rawcats.append(catpl)
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...
f6ecf9a5931e1c4c8aac83057e513ba1985e64ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f6ecf9a5931e1c4c8aac83057e513ba1985e64ab/category.py
text = wikipedia.replaceCategoryLinks(text, cats)
text = wikipedia.replaceCategoryLinks(text, rawcats)
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...
f6ecf9a5931e1c4c8aac83057e513ba1985e64ab /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/f6ecf9a5931e1c4c8aac83057e513ba1985e64ab/category.py
def resolveRedirect(self): ''' Requests the header from the server. If the page is an HTTP redirect, returns the redirect target URL as a string. Otherwise returns None. ''' # TODO: Malconfigured HTTP servers might give a redirect loop. A # recursion counter and limit would help. conn = httplib.HTTPConnection(self.host...
d331aecbdaea9cb357a2c3b20bac912533d164ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d331aecbdaea9cb357a2c3b20bac912533d164ee/weblinkchecker.py
newURL = None
def resolveRedirect(self): ''' Requests the header from the server. If the page is an HTTP redirect, returns the redirect target URL as a string. Otherwise returns None. ''' # TODO: Malconfigured HTTP servers might give a redirect loop. A # recursion counter and limit would help. conn = httplib.HTTPConnection(self.host...
d331aecbdaea9cb357a2c3b20bac912533d164ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d331aecbdaea9cb357a2c3b20bac912533d164ee/weblinkchecker.py
if redirTarget.startswith('http://') or redirTarget.startswith('https://'): newURL = redirTarget elif redirTarget.startswith('/'): newURL = '%s://%s%s' % (self.protocol, self.host, redirTarget) else: newURL = '%s://%s/%s' % (self.protocol, self.host, redirTarget)
if redirTarget: if redirTarget.startswith('http://') or redirTarget.startswith('https://'): newURL = redirTarget elif redirTarget.startswith('/'): newURL = '%s://%s%s' % (self.protocol, self.host, redirTarget) else: newURL = '%s://%s/%s' % (self.protocol, self.host, redirTarget)
def resolveRedirect(self): ''' Requests the header from the server. If the page is an HTTP redirect, returns the redirect target URL as a string. Otherwise returns None. ''' # TODO: Malconfigured HTTP servers might give a redirect loop. A # recursion counter and limit would help. conn = httplib.HTTPConnection(self.host...
d331aecbdaea9cb357a2c3b20bac912533d164ee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d331aecbdaea9cb357a2c3b20bac912533d164ee/weblinkchecker.py
result = {}
result = []
def translate(page, hints = None, auto = True): """ Please comment your source code! --Daniel Does some magic stuff. Returns a list of pages. """ result = {} site = page.site() if hints: for h in hints: if h.find(':') == -1: # argument given as -hint:xy where xy is a language code codes = h newname = '' else: codes, n...
fc96d1e046b58d826dbb849ea0f2b2c9a4fd2cbe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/fc96d1e046b58d826dbb849ea0f2b2c9a4fd2cbe/titletranslate.py
newtext = replaceLanguageLinks(newtext, interwiki_links)
newtext = replaceLanguageLinks(newtext, interwiki_links, site = site)
def replaceCategoryLinks(oldtext, new, site = None): """Replace the category links given in the wikitext given in oldtext by the new links given in new. 'new' should be a list of Category objects. """ if site is None: site = getSite() # first remove interwiki links and add them later, so that # interwiki tags appear b...
799dabdfcbaf4bf1953fc5be54a087b64d695c94 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/799dabdfcbaf4bf1953fc5be54a087b64d695c94/wikipedia.py
if not disambPage.isRedirectPage(): disambigText = editor.edit(disambPage.get(), jumpIndex = m.start())
if disambPage.isRedirectPage(): disambredir1 = disambPage.getRedirectTarget() disambredir2 = wikipedia.Page(wikipedia.getSite(), disambredir1) disambigText = editor.edit(disambredir2.get(), jumpIndex = m.start(), highlight = disambredir2.title()) else: disambigText = editor.edit(disambPage.get(), jumpIndex = m.start(),...
def treat(self, refPage, disambPage): """ Parameters: disambPage - The disambiguation page or redirect we don't want anything to link on refPage - A page linking to disambPage Returns False if the user pressed q to completely quit the program. Otherwise, returns True. """ # TODO: break this function up into subroutines...
d2595bf2b76d1648bf808aa26ddc8c0214d49e9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/d2595bf2b76d1648bf808aa26ddc8c0214d49e9e/solve_disambiguation.py
dictionary = cache[site]
watchlist = cache[site]
def get(site = None): if site is None: site = wikipedia.getSite() if cache.has_key(site): # Use cached copy if it exists. dictionary = cache[site] else: fn = 'watchlists/watchlist-%s-%s.dat' % (site.family.name, site.lang) try: # find out how old our saved dump is (in seconds) file_age = time.time() - os.path.getmtime(...
a0ccfabb67d19d7da49c242b64e964726c67f543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a0ccfabb67d19d7da49c242b64e964726c67f543/watchlist.py
def refresh(site): # get watchlist special page's URL path = site.watchlist_address() print 'Retrieving watchlist for %s' % repr(site) #wikipedia.put_throttle() # It actually is a get, but a heavy one. watchlistHTML = wikipedia.getUrl(site, path) print 'Parsing watchlist' watchlist = [] itemR = re.compile(r'<input typ...
a0ccfabb67d19d7da49c242b64e964726c67f543 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/a0ccfabb67d19d7da49c242b64e964726c67f543/watchlist.py
wikipedia.output(u"Current categories: ", cats)
wikipedia.output(u"Current categories: %s" % cats)
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...
7735201791be443bc42dafe0c7b7a464e1c7d85e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/7735201791be443bc42dafe0c7b7a464e1c7d85e/category.py
Rredir = re.compile('\<li\>\<a href=\"\/w\/wiki.phtml\?title=(.*?)&amp;redirect=no\"')
Rredir = re.compile('\<li\>\<a href=".+?" title="(.*?)"')
def retrieve_broken_redirects(self): if self.source == None: # retrieve information from the live wiki's maintenance page mysite = wikipedia.getSite() # broken redirect maintenance page's URL path = mysite.broken_redirects_address(default_limit = False) print 'Retrieving special page...' maintenance_txt = wikipedia.get...
22d00555270c0d2c93b5e459d7d5788241239a60 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/22d00555270c0d2c93b5e459d7d5788241239a60/redirect.py
for hit in R.findall(text):
for hit in R.findall(tet):
def allpages(start = '%21%200'): """Iterate over all Wikipedia pages in the home language, starting at the given page. This will raise an exception if the home language does not have a translation of 'Special' listed above.""" import sys start = link2url(start, code = mylang) m=0 while 1: text = getPage(mylang, '%s:All...
085ea95a68983029be7d08aafc811581e16fb9d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/085ea95a68983029be7d08aafc811581e16fb9d3/wikipedia.py
Rref = re.compile('<li><a href.* title="([^"]*)"')
Rref = re.compile('<li><a href.*="([^"]*)"')
def getReferences(pl): host = langs[pl.code()] url = "/w/wiki.phtml?title=%s:Whatlinkshere&target=%s"%(special[mylang], pl.urlname()) txt, charset = getUrl(host,url) Rref = re.compile('<li><a href.* title="([^"]*)"') x = Rref.findall(txt) x.sort() # Remove duplicates for i in range(len(x)-1, 0, -1): if x[i] == x[i-1]: ...
085ea95a68983029be7d08aafc811581e16fb9d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/085ea95a68983029be7d08aafc811581e16fb9d3/wikipedia.py
self.problem("Found link to %s" % pl.aslink() )
self.problem("Found link to %s" % pl.aslink(forceInterwiki = True) )
def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the site as key. # Each value will be a list. mysite = wikipedia.getSite() new = {} for pl in self.done.keys(): site = pl.site() if site == mysite and pl.exists() and not pl.isRedirectPage(): if pl != self.i...
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
for pl2 in v:
for page2 in v:
def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the site as key. # Each value will be a list. mysite = wikipedia.getSite() new = {} for pl in self.done.keys(): site = pl.site() if site == mysite and pl.exists() and not pl.isRedirectPage(): if pl != self.i...
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
wikipedia.output(u" (%d) Found link to %s in:" % (i, pl2.aslink())) self.whereReport(pl2, indent=8)
wikipedia.output(u" (%d) Found link to %s in:" % (i, page2.aslink(forceInterwiki = True))) self.whereReport(page2, indent=8)
def assemble(self): # No errors have been seen so far nerr = 0 # Build up a dictionary of all links found, with the site as key. # Each value will be a list. mysite = wikipedia.getSite() new = {} for pl in self.done.keys(): site = pl.site() if site == mysite and pl.exists() and not pl.isRedirectPage(): if pl != self.i...
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
updatedSites = []
def finish(self, sa = None): """Round up the subject, making any necessary changes. This method should be called exactly once after the todo list has gone empty.
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
self.replaceLinks(page, new, sa)
if self.replaceLinks(page, new, sa): updatedSites.append(site) for site in updatedSites: del new[site]
def finish(self, sa = None): """Round up the subject, making any necessary changes. This method should be called exactly once after the todo list has gone empty.
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
try: wikipedia.showDiff(oldtext, newtext) except: wikipedia.output(u'Error executing showDiff')
wikipedia.showDiff(oldtext, newtext)
def replaceLinks(self, pl, new, sa): wikipedia.output(u"Updating links on page %s." % pl.aslink(forceInterwiki = True))
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
if globalvar.forreal:
ask = False if removing: self.problem('removing: %s'%(",".join([x.lang for x in removing]))) ask = True if globalvar.force:
def replaceLinks(self, pl, new, sa): wikipedia.output(u"Updating links on page %s." % pl.aslink(forceInterwiki = True))
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
if removing: self.problem('removing: %s'%(",".join([x.lang for x in removing]))) ask = True if globalvar.force: ask = False if globalvar.confirm: ask = True if ask: if globalvar.autonomous: answer = 'n'
if globalvar.confirm: ask = True if ask: if globalvar.autonomous: answer = 'n' else: answer = wikipedia.inputChoice(u'Submit?', ['Yes', 'No'], ['y', 'N'], 'N') else: answer = 'y' if answer == 'y': if sa: while wikipedia.get_throttle.waittime() + 2.0 < wikipedia.put_throttle.waittime(): print "NOTE: Performing a r...
def replaceLinks(self, pl, new, sa): wikipedia.output(u"Updating links on page %s." % pl.aslink(forceInterwiki = True))
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
answer = wikipedia.inputChoice(u'Submit?', ['Yes', 'No'], ['y', 'N'], 'N')
break if str(status) == '302': return True
def replaceLinks(self, pl, new, sa): wikipedia.output(u"Updating links on page %s." % pl.aslink(forceInterwiki = True))
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
answer = 'y' if answer == 'y': if sa: while wikipedia.get_throttle.waittime() + 2.0 < wikipedia.put_throttle.waittime(): print "NOTE: Performing a recursive query first to save time...." qdone = sa.oneQuery() if not qdone: break print "NOTE: Updating live wiki..." timeout=60 while 1: try: print "DBG> updating ",...
print status, reason return False
def replaceLinks(self, pl, new, sa): wikipedia.output(u"Updating links on page %s." % pl.aslink(forceInterwiki = True))
02fc12a4124b63d8e2a4be36fe82132950863eae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/4404/02fc12a4124b63d8e2a4be36fe82132950863eae/interwiki.py
for site in new.keys(): pl = new[site] if not pl.section():
for site, page in new.iteritems(): if not page.section():
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
linked = pl.interwiki() for xpl in shouldlink: if xpl != pl and not xpl in linked:
linked = page.interwiki() for xpage in shouldlink: if xpage != page and not xpage in linked:
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