<s> """<STR_LIT>""" <EOL> import os <EOL> URLS = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : os . path . join ( "<STR_LIT:/>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> def build_iso639a ( filename ) : <EOL> import urllib2 <EOL> url = URLS [ "<STR_LIT>" ] <EOL> req = urllib2 . Request ( url , None ) <EOL> req . add_header ( "<STR_LIT>" , '<STR_LIT>' ) <EOL> req . add_header ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> req . add_header ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> req . add_header ( "<STR_LIT>" , "<STR_LIT:*>" ) <EOL> ccf = urllib2 . urlopen ( req ) <EOL> outf = open ( filename , "<STR_LIT:w>" ) <EOL> outf . write ( """<STR_LIT>""" ) <EOL> outf . write ( "<STR_LIT>" ) <EOL> for line in ccf . readlines ( ) : <EOL> parts = line . split ( "<STR_LIT:|>" ) <EOL> if len ( parts ) != <NUM_LIT:5> : <EOL> continue <EOL> [ alpha3_bib , alpha3_term , alpha2 , name_en , name_fr ] = map ( str . strip , parts ) <EOL> if alpha2 : <EOL> name_en = unicode ( name_en , '<STR_LIT:utf-8>' ) <EOL> outf . write ( "<STR_LIT>" % ( alpha2 . lower ( ) , name_en . capitalize ( ) ) ) <EOL> outf . write ( "<STR_LIT>" ) <EOL> outf . close ( ) <EOL> ccf . close ( ) <EOL> def build_iso3166 ( filename ) : <EOL> """<STR_LIT>""" <EOL> import urllib2 <EOL> outf = open ( filename , "<STR_LIT:w>" ) <EOL> outf . write ( """<STR_LIT>""" ) <EOL> outf . write ( "<STR_LIT>" ) <EOL> try : <EOL> ccf = urllib2 . urlopen ( URLS [ "<STR_LIT>" ] ) <EOL> except : <EOL> print "<STR_LIT>" % ( URLS [ "<STR_LIT>" ] , ) <EOL> ccf = open ( URLS [ "<STR_LIT>" ] ) <EOL> ccf . readline ( ) <EOL> for line in ccf . readlines ( ) : <EOL> vals = line . strip ( ) . split ( "<STR_LIT:;>" ) <EOL> if len ( vals ) != <NUM_LIT:2> : <EOL> continue <EOL> outf . write ( "<STR_LIT>" % ( vals [ <NUM_LIT:1> ] , vals [ <NUM_LIT:0> ] ) ) <EOL> outf . write ( "<STR_LIT>" ) <EOL> outf . close ( ) <EOL> ccf . close ( ) </s>
