Changeset 537

Show
Ignore:
Timestamp:
09/26/06 15:33:20
Author:
mylan
Message:

Fixed dumping objects with none ascii characters.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneSkinDump/trunk/HISTORY.txt

    r536 r537  
     1qPloneSkinDump 0.7.1 
     2    - Fixed bug of dumping to new Skin Product objects with none ascii 
     3      characters 
     4 
    15qPloneSkinDump 0.7 
    26 
  • qPloneSkinDump/trunk/version.txt

    r536 r537  
    1 0.7 
     10.7.1 
  • qPloneSkinDump/trunk/write_utils.py

    r536 r537  
    108108    return str 
    109109 
    110 def filewrite( filename, data, mode = 'w' ): 
     110def filewrite( filename, data, mode = 'wb' ): 
    111111    f = open( filename, mode ) 
    112     f.write( data
     112    f.write( prepareData(data)
    113113    f.close() 
    114114 
    115115def filewritelines( filename, data ): 
    116116    "Write a list of strings to a file, joining list items with '\n'." 
    117     f = open( filename, 'w' ) 
    118     f.write( '\n'.join( data ) ) 
     117    f = open( filename, 'wb' ) 
     118    f.write( '\n'.join( [prepareData(item) for item in data]) ) 
    119119    f.close() 
     120 
     121def prepareData(data): 
     122    """ Encode unicode type string for prevent UnicodeEncodeError  
     123        while writing none ascii string data to file.""" 
     124    return type(data) == type(u"") and data.encode("utf-8") or data