<s> import six <EOL> from django . utils . functional import allow_lazy <EOL> try : <EOL> from django . utils . encoding import force_unicode <EOL> except ImportError : <EOL> from django . utils . encoding import force_text as force_unicode <EOL> def truncate_letters ( s , num ) : <EOL> """<STR_LIT>""" <EOL> s = force_unicode ( s ) <EOL> length = int ( num ) <EOL> if len ( s ) > length : <EOL> s = s [ : length ] <EOL> if not s . endswith ( '<STR_LIT>' ) : <EOL> s += '<STR_LIT>' <EOL> return s <EOL> truncate_letters = allow_lazy ( truncate_letters , six . text_type ) </s>
