<s> """<STR_LIT>""" <EOL> import yaki . Engine , yaki . Store , yaki . Locale <EOL> from BeautifulSoup import * <EOL> from yaki . Utils import * <EOL> import urllib <EOL> class InterWikiListWikiPlugin ( yaki . Plugins . WikiPlugin ) : <EOL> def __init__ ( self , registry , webapp ) : <EOL> registry . register ( '<STR_LIT>' , self , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . ac = webapp . getContext ( ) <EOL> self . i18n = yaki . Locale . i18n [ self . ac . locale ] <EOL> def run ( self , serial , tag , tagname , pagename , soup , request , response ) : <EOL> if not self . ac . indexer . done : <EOL> tag . replaceWith ( self . i18n [ '<STR_LIT>' ] % self . i18n [ '<STR_LIT>' ] ) <EOL> return False <EOL> buffer = [ u'<STR_LIT>' % ( self . i18n [ '<STR_LIT>' ] , self . i18n [ '<STR_LIT>' ] ) ] <EOL> try : <EOL> schema = tag [ '<STR_LIT:src>' ] . lower ( ) <EOL> except : <EOL> tag . replaceWith ( self . i18n [ '<STR_LIT>' ] % self . i18n [ '<STR_LIT>' ] ) <EOL> return False <EOL> try : <EOL> if schema not in self . ac . indexer . interwikilinks . keys ( ) : <EOL> tag . replaceWith ( self . i18n [ '<STR_LIT>' ] % self . i18n [ '<STR_LIT>' ] ) <EOL> return False <EOL> data = self . ac . indexer . interwikilinks [ schema ] <EOL> except : <EOL> tag . replaceWith ( self . i18n [ '<STR_LIT>' ] % self . i18n [ '<STR_LIT>' ] ) <EOL> return False <EOL> pageinfo = self . ac . indexer . pageinfo <EOL> items = data . keys ( ) <EOL> items . sort ( lambda b , a : cmp ( data [ a ] [ '<STR_LIT>' ] , data [ b ] [ '<STR_LIT>' ] ) ) <EOL> for item in items : <EOL> link = data [ item ] <EOL> link [ '<STR_LIT>' ] = "<STR_LIT>" % ( schema , item ) <EOL> try : <EOL> row = [ u'<STR_LIT>' % link ] <EOL> references = link [ '<STR_LIT>' ] <EOL> references . sort ( lambda b , a : cmp ( pageinfo [ a ] [ '<STR_LIT>' ] , pageinfo [ b ] [ '<STR_LIT>' ] ) ) <EOL> for reference in references : <EOL> row . append ( u'<STR_LIT>' % ( self . ac . base + reference , self . i18n [ '<STR_LIT>' ] % timeSince ( self . i18n , pageinfo [ reference ] [ '<STR_LIT>' ] ) , pageinfo [ reference ] [ '<STR_LIT:title>' ] ) ) <EOL> buffer . append ( u'<STR_LIT>' . join ( row ) [ : - <NUM_LIT:5> ] ) <EOL> buffer . append ( u'<STR_LIT>' ) <EOL> except : <EOL> print "<STR_LIT>" % item <EOL> buffer . append ( u'<STR_LIT>' ) <EOL> tag . replaceWith ( u'<STR_LIT>' . join ( buffer ) ) </s>
