try raw_rec join conv val size dec for conv name size dec val in izip

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
try:
raw_rec = ''.join(conv(val, size, dec)
for (conv, name, size, dec), val
in izip(converters, record))
except UnicodeDecodeError, err:
if use_unicode:
msg = "Error occured while writing rec #%d. You are "
"using YDbfWriter with unicode mode turned on (encoding "
"set to %s, lang code %s), but probably push 8-bit string "
"data to writer. Check yourself, please. Record data: %s "
% (i, self.encoding, hex(self.lang), record)
else:
msg = "Error occured while writing rec #%d. You are "
"using YDbfWriter with unicode mode turned off, so "
"we doesn't know why it occurs, so may be it is an "
"bug inside ydbf, or corrupted data. Record data: %s" %
(i, record)
args = list(err.args[:-1]) + [msg]
raise UnicodeDecodeError(*args)
except UnicodeEncodeError, err:
if use_unicode:
msg = "Error occured while writing rec #%d. You are "
"using YDbfWriter with unicode mode turned on and encoding "
"%s (lang code %s). Probably, data you are pushing to "
"writer doesn't fit to %s encoding, please choose "
"another encoding (recommended), or encode your data "
"yourself and turn off unicode mode for writer. Record "
"data: %s" % (i, self.encoding, hex(self.lang),
self.encoding, record)
else:
msg = "Error occured while writing rec #%d. You are "
"using YDbfWriter with unicode mode turned off, but "
"probably push unicode data to writer. Check yourself, "
"please. Record data: %s " % (i, record)
args = list(err.args[:-1]) + [msg]
raise UnicodeEncodeError(*args)