Description

If you try to recode a .po file with the Moin tool recode.py you get on Windows systems always the error "IOError: [Errno 9] Bad file descriptor"

Steps to reproduce

  1. Try to recode a .po file with recode.py on Windows systems
  2. This fails.

Example

traceback.jpg

Component selection

  • i18n/tools/recode.py

Details

MoinMoin Version

1.6, 1.5.x

OS and Version

Windows XP Sp2

Python Version

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32

Server Setup

Server Details

Language you are using the wiki in (set in the browser/UserPreferences)

Workaround

Recode tool works fine on MacOS X (10.5) and other unix-like systems.

Discussion

I think Windows has some problems with the way to read data from stdin, write data to stdout and pipe these things into files. To get recode.py work I had to do some changes, mainly that the scr_file and dst_file are now calling args. This works fine now.

 1 #!/usr/bin/env python
 2 # -*- coding: iso-8859-1 -*-
 3 """
 4  MoinMoin - file encoding conversion
 5 
 6  @copyright: 2006 by Thomas Waldmann, Oliver Siemoneit
 7  @license: GNU GPL, see COPYING for details.
 8 
 9  Convert data of src file in encoding src_enc to encoding
 10  dst_enc in dst_file.
 11 
 12  Usage:
 13 
 14  recode.py src_enc dst_enc src_file dst_file
 15 
 16  Example:
 17 
 18  # Using non utf-8 editor to edit utf-8 file:
 19 
 20  # Make a working copy using iso-8859-1 encoding
 21  recode.py utf-8 iso-8859-1 de.po de-iso1.po
 22 
 23  # Use non-utf8 editor
 24  $EDITOR de-iso1.po
 25 
 26  # Recode back to utf-8
 27  recode.py iso-8859-1 utf-8 de-iso1.po de-utf8.po
 28 
 29  # Review changes and replace original if everything is ok
 30  diff de.po de-utf8.po | less
 31  mv de-utf8.po de.po
 32 
 33 """
 34 
 35 import sys
 36 
 37 def error(msg):
 38  sys.stderr.write(msg + '\n')
 39  
 40 def run():
 41  try:
 42  cmd, src_enc, dst_enc, src_file, dst_file = sys.argv
 43 
 44  lines = []
 45  for line in open(src_file).readlines():
 46  lines += unicode(line, src_enc).encode(dst_enc)
 47 
 48  open(dst_file,"w").writelines(lines)
 49 
 50  except UnicodeError, err:
 51  error("Can't recode: %s" % str(err))
 52  except LookupError, err:
 53  error(str(err))
 54  except ValueError:
 55  error("Wrong number of arguments")
 56  error(__doc__)
 57 
 58 
 59 if __name__ == "__main__":
 60  run()

recode.py

-- OliverSiemoneit 2006年12月25日 14:02:08

Plan

  • Priority:
  • Assigned to:
  • Status:


CategoryMoinMoinBug

MoinMoin: MoinMoinBugs/RecodingToolForPoFilesDoesNotWorkOnWin (last edited 2007年12月26日 16:03:21 by OliverSiemoneit )

AltStyle によって変換されたページ (->オリジナル) /