<s> import subprocess <EOL> import re <EOL> from collections import defaultdict <EOL> from babel import Locale <EOL> authors_by_locale = defaultdict ( set ) <EOL> file_listing = subprocess . Popen ( '<STR_LIT>' , shell = True , stdout = subprocess . PIPE ) <EOL> for file_listing_line in file_listing . stdout : <EOL> filename = file_listing_line . strip ( ) <EOL> locale = re . search ( r'<STR_LIT>' , filename ) . group ( <NUM_LIT:1> ) <EOL> if locale == '<STR_LIT>' : <EOL> continue <EOL> with file ( filename ) as f : <EOL> has_found_translators_heading = False <EOL> for line in f : <EOL> line = line . strip ( ) <EOL> if line . startswith ( '<STR_LIT:#>' ) : <EOL> if has_found_translators_heading : <EOL> author = re . match ( r'<STR_LIT>' , line ) . group ( <NUM_LIT:1> ) <EOL> authors_by_locale [ locale ] . add ( author ) <EOL> elif line . startswith ( '<STR_LIT>' ) : <EOL> has_found_translators_heading = True <EOL> else : <EOL> if has_found_translators_heading : <EOL> break <EOL> else : <EOL> raise Exception ( "<STR_LIT>" % filename ) <EOL> language_names = [ <EOL> ( Locale . parse ( locale_string ) . english_name , locale_string ) <EOL> for locale_string in authors_by_locale . keys ( ) <EOL> ] <EOL> language_names . sort ( ) <EOL> for ( language_name , locale ) in language_names : <EOL> print ( ( "<STR_LIT>" % ( language_name , locale ) ) . encode ( '<STR_LIT:utf-8>' ) ) <EOL> print ( "<STR_LIT>" ) <EOL> for author in sorted ( authors_by_locale [ locale ] ) : <EOL> print ( author ) <EOL> print ( '<STR_LIT>' ) </s>
