def _build_locale_table(filename_or_file):
 from xml.dom.minidom import parse
 dom = parse(filename_or_file)
 reps = dom.getElementsByTagName('representation')
 locs = map((lambda r: r.childNodes[0].data), reps)
 locale_map = {}
 for loc in locs:
  (lang, _, reg) = loc.partition('_')
  lang_map = locale_map.setdefault(lang, {'regs': [], 'default': reg})
  lang_map['regs'].append(reg)
 locale_map['en']['default'] = 'US'
 locale_map['es']['default'] = 'LA'
 locale_map['zh']['default'] = 'CN'
 locale_map['fr']['default'] = 'FR'
 locale_map['pt']['default'] = 'PT'
 return locale_map

def _build_locale_table ( filename_or_file ) : from xml . dom . minidom import parse dom = parse ( filename_or_file ) reps = dom . getElementsByTagName ( 'representation' ) locs = map ( ( lambda r : r . childNodes [ 0 ] . data ) , reps ) locale_map = { } for loc in locs : ( lang , _ , reg ) = loc . partition ( '_' ) lang_map = locale_map . setdefault ( lang , { 'regs' : [ ] , 'default' : reg } ) lang_map [ 'regs' ] . append ( reg ) locale_map [ 'en' ] [ 'default' ] = 'US' locale_map [ 'es' ] [ 'default' ] = 'LA' locale_map [ 'zh' ] [ 'default' ] = 'CN' locale_map [ 'fr' ] [ 'default' ] = 'FR' locale_map [ 'pt' ] [ 'default' ] = 'PT' return locale_map
parses the facebooklocales .