@flake8ext
def check_builtins_gettext(logical_line, tokens, filename, lines, noqa):
 if noqa:
  return
 modulename = os.path.normpath(filename).split('/')[0]
 if (('%s/tests' % modulename) in filename):
  return
 if (os.path.basename(filename) in ('i18n.py', '_i18n.py')):
  return
 token_values = [t[1] for t in tokens]
 i18n_wrapper = ('%s._i18n' % modulename)
 if ('_' in token_values):
  i18n_import_line_found = False
  for line in lines:
   split_line = [elm.rstrip(',') for elm in line.split()]
   if ((len(split_line) > 1) and (split_line[0] == 'from') and (split_line[1] == i18n_wrapper) and ('_' in split_line)):
    i18n_import_line_found = True
    break
  if (not i18n_import_line_found):
   msg = ('N341: _ from python builtins module is used. Use _ from %s instead.' % i18n_wrapper)
   (yield (0, msg))

@ flake8ext def check_builtins_gettext ( logical_line , tokens , filename , lines , noqa ) : if noqa : return modulename = os . path . normpath ( filename ) . split ( '/' ) [ 0 ] if ( ( '%s/tests' % modulename ) in filename ) : return if ( os . path . basename ( filename ) in ( 'i18n.py' , '_i18n.py' ) ) : return token_values = [ t [ 1 ] for t in tokens ] i18n_wrapper = ( '%s._i18n' % modulename ) if ( '_' in token_values ) : i18n_import_line_found = False for line in lines : split_line = [ elm . rstrip ( ',' ) for elm in line . split ( ) ] if ( ( len ( split_line ) > 1 ) and ( split_line [ 0 ] == 'from' ) and ( split_line [ 1 ] == i18n_wrapper ) and ( '_' in split_line ) ) : i18n_import_line_found = True break if ( not i18n_import_line_found ) : msg = ( 'N341: _ from python builtins module is used. Use _ from %s instead.' % i18n_wrapper ) ( yield ( 0 , msg ) )
n341 - check usage of builtins gettext _() .