def apply_change_ubuntu(targetState, name):
 if (targetState == 'present'):
  localeGenExitValue = call(['locale-gen', name])
 else:
  try:
   f = open('/var/lib/locales/supported.d/local', 'r')
   content = f.readlines()
  finally:
   f.close()
  try:
   f = open('/var/lib/locales/supported.d/local', 'w')
   for line in content:
    (locale, charset) = line.split(' ')
    if (locale != name):
     f.write(line)
  finally:
   f.close()
  localeGenExitValue = call(['locale-gen', '--purge'])
 if (localeGenExitValue != 0):
  raise EnvironmentError(localeGenExitValue, ('locale.gen failed to execute, it returned ' + str(localeGenExitValue)))

def apply_change_ubuntu ( targetState , name ) : if ( targetState == 'present' ) : localeGenExitValue = call ( [ 'locale-gen' , name ] ) else : try : f = open ( '/var/lib/locales/supported.d/local' , 'r' ) content = f . readlines ( ) finally : f . close ( ) try : f = open ( '/var/lib/locales/supported.d/local' , 'w' ) for line in content : ( locale , charset ) = line . split ( ' ' ) if ( locale != name ) : f . write ( line ) finally : f . close ( ) localeGenExitValue = call ( [ 'locale-gen' , '--purge' ] ) if ( localeGenExitValue != 0 ) : raise EnvironmentError ( localeGenExitValue , ( 'locale.gen failed to execute, it returned ' + str ( localeGenExitValue ) ) )
create or remove locale .