Mercurial > p > roundup > code
comparison roundup/msgfmt.py @ 7874:a363bb8c0ed4
feat: make msgfmt.py support -o flag
Make msgfmt.py support -o flag like gnu msgfmt.
This allows:
make -C locale local_install MSGFMT="python3 ../roundup/msgfmt.py"
to compile locale files for use when running roundup_server in
development mode.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 10 Apr 2024 19:01:54 -0400 |
| parents | 37a98ec62e2e |
| children |
comparison
equal
deleted
inserted
replaced
| 7873:867418c24339 | 7874:a363bb8c0ed4 |
|---|---|
| 286 | 286 |
| 287 if __name__ == '__main__': | 287 if __name__ == '__main__': |
| 288 # a really dumb attempt to make this into a command | 288 # a really dumb attempt to make this into a command |
| 289 # Usage: python msgfmy.py <input_file>.po <output_file>.mo | 289 # Usage: python msgfmy.py <input_file>.po <output_file>.mo |
| 290 import sys | 290 import sys |
| 291 | 291 input_filename = "" |
| 292 mo = Msgfmt(sys.argv[1]).get() | 292 output_filename = "" |
| 293 with open(sys.argv[2], 'wb') as mofile: | 293 |
| 294 if sys.argv[1] == "-o": | |
| 295 output_filename = sys.argv[2] | |
| 296 input_filename = sys.argv[3] | |
| 297 else: | |
| 298 input_filename = sys.argv[1] | |
| 299 output_filename = sys.argv[2] | |
| 300 | |
| 301 mo = Msgfmt(input_filename).get() | |
| 302 with open(output_filename, 'wb') as mofile: | |
| 294 mofile.write(mo) | 303 mofile.write(mo) |
| 295 mofile.close() | 304 mofile.close() |
| 296 | 305 |
