def jinja_messages_to_python(src, origin=None):
 output = StringIO(u'')
 output_lineno = 1
 for (lineno, message, comments, context) in extract_jinja(src, origin):
  for comment in comments:
   output.write((u'# %s %s\n' % (COMMENT_TAG, comment)))
   output_lineno += 1
  lines_to_add = (lineno - output_lineno)
  if (lines_to_add > 0):
   output.write((lines_to_add * u'\n'))
   output_lineno += lines_to_add
  output.write((u'gettext(%r),' % (message,)))
 return output.getvalue()

def jinja_messages_to_python ( src , origin = None ) : output = StringIO ( u'' ) output_lineno = 1 for ( lineno , message , comments , context ) in extract_jinja ( src , origin ) : for comment in comments : output . write ( ( u'# %s %s\n' % ( COMMENT_TAG , comment ) ) ) output_lineno += 1 lines_to_add = ( lineno - output_lineno ) if ( lines_to_add > 0 ) : output . write ( ( lines_to_add * u'\n' ) ) output_lineno += lines_to_add output . write ( ( u'gettext(%r),' % ( message , ) ) ) return output . getvalue ( )
convert jinja2 file to python preserving only messages .