Changeset 41

Show
Ignore:
Timestamp:
Mon Jun 27 05:23:21 2005
Author:
fredrikc
Message:

Use codecs package to write file instead of manual encoding of strings written.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/transolution/filters/xliff2sgml.py

    r27 r41  
    89 89 def main():  
    90 90     import sys  
      91     import codecs  
      92      
    91 93     contenttypes = {'.html':'html','.htm':'html','.xml':'xml'}  
    92 94     options = parseArgs()  
     
    108 110             outfile = path(fname.parent) / path(filenode.getOriginal()).name  
    109 111             print '  ' + outfile  
    110               outfile_obj = file(outfile,'w')  
      112             outfile_obj = codecs.open(outfile,"w",encoding)  
      113  
    111 114             for seg in xliff.files[0].generateSegments():  
    112 115                 if seg.__class__ is TuSegment:  
    113 116                     text = getTextAndEscape(seg.getNode().childNodes)  
    114                       outfile_obj.write(text.encode(encoding))  
      117                     outfile_obj.write(text)  
    114 117                 elif seg.__class__ is External:  
    115 118                     text = getText(seg.getNode().childNodes)  
    116                       outfile_obj.write(text.encode(encoding))  
      119                     outfile_obj.write(text)  
    116 119             outfile_obj.close()  
    117 120