<s> '''<STR_LIT:U+0020>''' <EOL> import meaning <EOL> import structs <EOL> class Entry : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , entrylang , meaning = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . entrylang = entrylang <EOL> self . meanings = { } <EOL> if meaning : <EOL> self . addMeaning ( meaning ) <EOL> self . posorder = [ ] <EOL> def addMeaning ( self , meaning ) : <EOL> """<STR_LIT>""" <EOL> term = meaning . term <EOL> self . meanings . setdefault ( term . pos , [ ] ) . append ( meaning ) <EOL> if not term . pos in self . posorder : <EOL> self . posorder . append ( term . pos ) <EOL> def getMeanings ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . meanings <EOL> def wikiWrap ( self , wikilang ) : <EOL> """<STR_LIT>""" <EOL> entry = structs . wiktionaryformats [ wikilang ] [ '<STR_LIT>' ] . replace ( <EOL> '<STR_LIT>' , langnames [ wikilang ] [ self . entrylang ] ) . replace ( <EOL> '<STR_LIT>' , self . entrylang ) + '<STR_LIT:\n>' <EOL> for pos in self . posorder : <EOL> meanings = self . meanings [ pos ] <EOL> entry += structs . wiktionaryformats [ wikilang ] [ '<STR_LIT>' ] [ pos ] <EOL> entry += '<STR_LIT:\n>' <EOL> if wikilang == '<STR_LIT>' : <EOL> entry += meanings [ <NUM_LIT:0> ] . term . wikiWrapAsExample ( wikilang ) + '<STR_LIT>' <EOL> for meaning in meanings : <EOL> entry += '<STR_LIT>' % ( meaning . getLabel ( ) , <EOL> meaning . definition ) <EOL> entry += meaning . wikiWrapExamples ( ) <EOL> entry += '<STR_LIT:\n>' <EOL> if wikilang == '<STR_LIT>' : <EOL> for meaning in meanings : <EOL> term = meaning . term <EOL> entry += meaning . getLabel ( ) + term . wikiWrapAsExample ( <EOL> wikilang ) + '<STR_LIT>' % meaning . definition <EOL> entry += meaning . wikiWrapExamples ( ) <EOL> entry += '<STR_LIT:\n>' <EOL> if meaning . hasSynonyms ( ) : <EOL> entry += '<STR_LIT>' % ( <EOL> structs . wiktionaryformats [ wikilang ] [ '<STR_LIT>' ] ) <EOL> for meaning in meanings : <EOL> entry += "<STR_LIT>" % ( meaning . getLabel ( ) , <EOL> meaning . getConciseDef ( ) , <EOL> meaning . wikiWrapSynonyms ( <EOL> wikilang ) ) <EOL> entry += '<STR_LIT:\n>' <EOL> if meaning . hasTranslations ( ) : <EOL> entry += '<STR_LIT>' % ( <EOL> structs . wiktionaryformats [ wikilang ] [ '<STR_LIT>' ] ) <EOL> for meaning in meanings : <EOL> entry += "<STR_LIT>" % ( <EOL> meaning . getLabel ( ) , meaning . getConciseDef ( ) , <EOL> meaning . wikiWrapTranslations ( wikilang , self . entrylang ) ) <EOL> entry += '<STR_LIT:\n>' <EOL> return entry <EOL> def showContents ( self , indentation ) : <EOL> """<STR_LIT>""" <EOL> print '<STR_LIT:U+0020>' * indentation + '<STR_LIT>' % self . entrylang <EOL> print '<STR_LIT:U+0020>' * indentation + '<STR_LIT>' + repr ( self . posorder ) <EOL> meaningkeys = self . meanings . keys ( ) <EOL> for meaningkey in meaningkeys : <EOL> for meaning in self . meanings [ meaningkey ] : <EOL> meaning . showContents ( indentation + <NUM_LIT:2> ) </s>
