def make_gettext_patterns():
 kwstr = 'msgid msgstr'
 kw = (('\\b' + any('keyword', kwstr.split())) + '\\b')
 fuzzy = any('builtin', ['#,[^\\n]*'])
 links = any('normal', ['#:[^\\n]*'])
 comment = any('comment', ['#[^\\n]*'])
 number = any('number', ['\\b[+-]?[0-9]+[lL]?\\b', '\\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\\b', '\\b[+-]?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b'])
 sqstring = "(\\b[rRuU])?'[^'\\\\\\n]*(\\\\.[^'\\\\\\n]*)*'?"
 dqstring = '(\\b[rRuU])?"[^"\\\\\\n]*(\\\\.[^"\\\\\\n]*)*"?'
 string = any('string', [sqstring, dqstring])
 return '|'.join([kw, string, number, fuzzy, links, comment, any('SYNC', ['\\n'])])

def make_gettext_patterns ( ) : kwstr = 'msgid msgstr' kw = ( ( '\\b' + any ( 'keyword' , kwstr . split ( ) ) ) + '\\b' ) fuzzy = any ( 'builtin' , [ '#,[^\\n]*' ] ) links = any ( 'normal' , [ '#:[^\\n]*' ] ) comment = any ( 'comment' , [ '#[^\\n]*' ] ) number = any ( 'number' , [ '\\b[+-]?[0-9]+[lL]?\\b' , '\\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\\b' , '\\b[+-]?[0-9]+(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b' ] ) sqstring = "(\\b[rRuU])?'[^'\\\\\\n]*(\\\\.[^'\\\\\\n]*)*'?" dqstring = '(\\b[rRuU])?"[^"\\\\\\n]*(\\\\.[^"\\\\\\n]*)*"?' string = any ( 'string' , [ sqstring , dqstring ] ) return '|' . join ( [ kw , string , number , fuzzy , links , comment , any ( 'SYNC' , [ '\\n' ] ) ] )
strongly inspired from idlelib .