Changeset 2264
- Timestamp:
- 05/19/05 23:26:05 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r2262 r2264 24 24 - 1.23alpha3 : 25 25 26 - Data dumper improved : it's faster and now datas are correctly 27 escaped. 28 26 29 - The URL to the logo displayed in the CGI scripts is configurable. 27 30 -
pykota/trunk/pykota/dumper.py
r2219 r2264 25 25 import os 26 26 import pwd 27 from xml.sax import saxutils 28 27 29 from mx import DateTime 28 30 … … 113 115 """Dumps datas with a separator.""" 114 116 for entry in entries : 115 line = separator.join([ '"%s"' % field for field in entry ]) 117 line = [] 118 for value in entry : 119 if type(value).__name__ in ("str", "NoneType") : 120 line.append('"%s"' % str(value).replace(separator, "\\%s" % separator).replace('"', '\\"')) 121 else : 122 line.append(str(value)) 116 123 try : 117 self.outfile.write("%s\n" % line)124 self.outfile.write("%s\n" % separator.join(line)) 118 125 except IOError, msg : 119 126 sys.stderr.write("%s : %s\n" % (_("PyKota data dumper failed : I/O error"), msg)) … … 165 172 x._push() 166 173 x.entry() 167 for i in range(len(entry)) : 168 value = str(entry[i]) 169 typval = type(entry[i]).__name__ 170 try : 171 value = unicode(value, self.getCharset()).encode("UTF-8") 172 except UnicodeError : 173 pass 174 x.attribute(value, type=typval, name=headers[i]) 174 for (header, value) in zip(headers, entry) : 175 strvalue = str(value) 176 typval = type(value).__name__ 177 if header in ("filename", "title", "options", "billingcode") \ 178 and (typval == "str") : 179 try : 180 strvalue = unicode(strvalue, self.getCharset()).encode("UTF-8") 181 except UnicodeError : 182 pass 183 strvalue = saxutils.escape(strvalue, { "'" : "'", \ 184 '"' : """ }) 185 x.attribute(strvalue, type=typval, name=header) 175 186 x._pop() 176 187 x._output(self.outfile) -
pykota/trunk/TODO
r2262 r2264 26 26 Winboxes it seems) 27 27 28 - Ensures that all special characters in strings are properly29 escaped when dumping datas : quotes, xml entities, etc...30 31 28 - Add date filtering options to dumpykota, something like 32 29 date=+20050101 date=-20050201