Mercurial > p > roundup > code
comparison roundup/msgfmt.py @ 5248:198b6e810c67
Use Python-3-compatible 'as' syntax for except statements
Many raise statements near these are also fixed.
So are two ivorrect file encoding marks ('utf8'->'utf-8').
| author | Eric S. Raymond <esr@thyrsus.com> |
|---|---|
| date | Thu, 24 Aug 2017 22:21:37 -0400 |
| parents | c643d693d91e |
| children | 64b05e24dbd8 |
comparison
equal
deleted
inserted
replaced
| 5247:7f00a47b3559 | 5248:198b6e810c67 |
|---|---|
| 114 if outfile is None: | 114 if outfile is None: |
| 115 outfile = os.path.splitext(infile)[0] + '.mo' | 115 outfile = os.path.splitext(infile)[0] + '.mo' |
| 116 | 116 |
| 117 try: | 117 try: |
| 118 lines = open(infile).readlines() | 118 lines = open(infile).readlines() |
| 119 except IOError, msg: | 119 except IOError as msg: |
| 120 print >> sys.stderr, msg | 120 print >> sys.stderr, msg |
| 121 sys.exit(1) | 121 sys.exit(1) |
| 122 | 122 |
| 123 # remove UTF-8 Byte Order Mark, if any. | 123 # remove UTF-8 Byte Order Mark, if any. |
| 124 # (UCS2 BOMs are not handled because messages in UCS2 cannot be handled) | 124 # (UCS2 BOMs are not handled because messages in UCS2 cannot be handled) |
| 187 # Compute output | 187 # Compute output |
| 188 output = generate() | 188 output = generate() |
| 189 | 189 |
| 190 try: | 190 try: |
| 191 open(outfile,"wb").write(output) | 191 open(outfile,"wb").write(output) |
| 192 except IOError,msg: | 192 except IOError as msg: |
| 193 print >> sys.stderr, msg | 193 print >> sys.stderr, msg |
| 194 | 194 |
| 195 | 195 |
| 196 | 196 |
| 197 def main(): | 197 def main(): |
| 198 try: | 198 try: |
| 199 opts, args = getopt.getopt(sys.argv[1:], 'hVo:', | 199 opts, args = getopt.getopt(sys.argv[1:], 'hVo:', |
| 200 ['help', 'version', 'output-file=']) | 200 ['help', 'version', 'output-file=']) |
| 201 except getopt.error, msg: | 201 except getopt.error as msg: |
| 202 usage(1, msg) | 202 usage(1, msg) |
| 203 | 203 |
| 204 outfile = None | 204 outfile = None |
| 205 # parse options | 205 # parse options |
| 206 for opt, arg in opts: | 206 for opt, arg in opts: |
