def task_locale():
 def set_nikola_test_locales():
  try:
   out = subprocess.check_output(['locale', '-a'])
   out = out.decode('utf-8')
   locales = []
   languages = set()
   for line in out.splitlines():
    if ((line.endswith('.utf8') or line.endswith('.UTF-8')) and ('_' in line)):
     lang = line.split('_')[0]
     if (lang not in languages):
      try:
       locale.setlocale(locale.LC_ALL, str(line))
      except:
       continue
      languages.add(lang)
      locales.append((lang, line))
      if (len(locales) == 2):
       break
   if (len(locales) != 2):
    return False
   else:
    os.environ['NIKOLA_LOCALE_DEFAULT'] = ','.join(locales[0])
    os.environ['NIKOLA_LOCALE_OTHER'] = ','.join(locales[1])
  finally:
   locale.resetlocale()
 return {'actions': [set_nikola_test_locales], 'verbosity': 2}

def task_locale ( ) : def set_nikola_test_locales ( ) : try : out = subprocess . check_output ( [ 'locale' , '-a' ] ) out = out . decode ( 'utf-8' ) locales = [ ] languages = set ( ) for line in out . splitlines ( ) : if ( ( line . endswith ( '.utf8' ) or line . endswith ( '.UTF-8' ) ) and ( '_' in line ) ) : lang = line . split ( '_' ) [ 0 ] if ( lang not in languages ) : try : locale . setlocale ( locale . LC_ALL , str ( line ) ) except : continue languages . add ( lang ) locales . append ( ( lang , line ) ) if ( len ( locales ) == 2 ) : break if ( len ( locales ) != 2 ) : return False else : os . environ [ 'NIKOLA_LOCALE_DEFAULT' ] = ',' . join ( locales [ 0 ] ) os . environ [ 'NIKOLA_LOCALE_OTHER' ] = ',' . join ( locales [ 1 ] ) finally : locale . resetlocale ( ) return { 'actions' : [ set_nikola_test_locales ] , 'verbosity' : 2 }
set environ locale vars used in nikola tests .