@@ -105,26 +105,31 @@ def generate(messages):
105105def make (filenames , outfile = None ):
106106 """ Compiles one or more po files(s).
107107
108- filenames is a string or an iterable of strings representing input file(s).
109- outfile is a string for the name of an input file or None.
108+ filenames an iterable of strings representing the input file(s).
109+ outfile is a string for the name of an output file or None.
110110
111111 If it is not None, the output file receives a merge of the input files.
112- If it is None, then filenames must be a string and the name of the output
112+ If it is None, then for each file from filenames the name of the output
113113 file is obtained by replacing the po extension with mo.
114- Both ways are for compatibility reasons with previous behaviour.
114+ BEWARE: in previous version of make the first parameter was a string
115+ containing a single filename.
115116 """
116- messages = {}
117- if isinstance (filenames , str ):
118- infile , outfile = get_names (filenames , outfile )
119- process (infile , messages )
120- elif outfile is None :
121- raise TypeError ("outfile cannot be None with more than one infile" )
117+ if outfile is None :
118+ # each PO file generates its corresponding MO file
119+ for filename in filenames :
120+ messages = {}
121+ infile , outfile = get_names (filename , None )
122+ process (infile , messages )
123+ output = generate (messages )
124+ writefile (outfile , output )
122125 else :
126+ # all PO files are combined into one single output file
127+ messages = {}
123128 for filename in filenames :
124129 infile , _ = get_names (filename , outfile )
125130 process (infile , messages )
126- output = generate (messages )
127- writefile (outfile , output )
131+ output = generate (messages )
132+ writefile (outfile , output )
128133
129134def get_names (filename , outfile ):
130135 # Compute .mo name from .po name and arguments
@@ -276,11 +281,7 @@ def main():
276281 print ('No input file given' , file = sys .stderr )
277282 print ("Try `msgfmt --help' for more information." , file = sys .stderr )
278283 return
279- if outfile is None :
280- for filename in args :
281- make (filename , None )
282- else :
283- make (args , outfile )
284+ make (args , outfile )
284285
285286
286287if __name__ == '__main__' :
0 commit comments