#NEWLINE# def _run_domain( self , domain ) : #NEWLINE# #INDENT# po_files = [ ] #NEWLINE# mo_files = [ ] #NEWLINE# if ( not self . input_file ) : #NEWLINE# #INDENT# if self . locale : #NEWLINE# #INDENT# po_files . append ( ( self . locale , os . path . join ( self . directory , self . locale , 'LC_MESSAGES' , ( domain + '.po' ) ) ) ) #NEWLINE# mo_files . append ( os . path . join ( self . directory , self . locale , 'LC_MESSAGES' , ( domain + '.mo' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for locale in os . listdir ( self . directory ) : #NEWLINE# #INDENT# po_file = os . path . join ( self . directory , locale , 'LC_MESSAGES' , ( domain + '.po' ) ) #NEWLINE# if os . path . exists ( po_file ) : #NEWLINE# #INDENT# po_files . append ( ( locale , po_file ) ) #NEWLINE# mo_files . append ( os . path . join ( self . directory , locale , 'LC_MESSAGES' , ( domain + '.mo' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# po_files . append ( ( self . locale , self . input_file ) ) #NEWLINE# if self . output_file : #NEWLINE# #INDENT# mo_files . append ( self . output_file ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# mo_files . append ( os . path . join ( self . directory , self . locale , 'LC_MESSAGES' , ( domain + '.mo' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not po_files ) : #NEWLINE# #INDENT# raise DistutilsOptionError ( 'no message catalogs found' ) #NEWLINE# #UNINDENT# for ( idx , ( locale , po_file ) ) in enumerate ( po_files ) : #NEWLINE# #INDENT# mo_file = mo_files [ idx ] #NEWLINE# infile = open ( po_file , 'rb' ) #NEWLINE# try : #NEWLINE# #INDENT# catalog = read_po ( infile , locale ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# infile . close ( ) #NEWLINE# #UNINDENT# if self . statistics : #NEWLINE# #INDENT# translated = 0 #NEWLINE# for message in list ( catalog ) [ 1 : ] : #NEWLINE# #INDENT# if message . string : #NEWLINE# #INDENT# translated += 1 #NEWLINE# #UNINDENT# #UNINDENT# percentage = 0 #NEWLINE# if len ( catalog ) : #NEWLINE# #INDENT# percentage = ( ( translated * 100 ) // len ( catalog ) ) #NEWLINE# #UNINDENT# self . log . info ( '%d of %d messages (%d%%) translated in %s' , translated , len ( catalog ) , percentage , po_file ) #NEWLINE# #UNINDENT# if ( catalog . fuzzy and ( not self . use_fuzzy ) ) : #NEWLINE# #INDENT# self . log . info ( 'catalog %s is marked as fuzzy, skipping' , po_file ) #NEWLINE# continue #NEWLINE# #UNINDENT# for ( message , errors ) in catalog . check ( ) : #NEWLINE# #INDENT# for error in errors : #NEWLINE# #INDENT# self . log . error ( 'error: %s:%d: %s' , po_file , message . lineno , error ) #NEWLINE# #UNINDENT# #UNINDENT# self . log . info ( 'compiling catalog %s to %s' , po_file , mo_file ) #NEWLINE# outfile = open ( mo_file , 'wb' ) #NEWLINE# try : #NEWLINE# #INDENT# write_mo ( outfile , catalog , use_fuzzy = self . use_fuzzy ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# outfile . close ( )