--- a/devtools/dataimport.py Tue Dec 22 13:16:17 2009 +0100
+++ b/devtools/dataimport.py Tue Dec 22 19:23:59 2009 +0100
@@ -51,7 +51,11 @@
"""
__docformat__ = "restructuredtext en"
-import sys, csv, traceback
+import sys
+import csv
+import traceback
+import os.path as osp
+from StringIO import StringIO
from logilab.common import shellutils
from logilab.common.deprecation import deprecated
@@ -59,6 +63,8 @@
def ucsvreader_pb(filepath, encoding='utf-8', separator=',', quote='"',
skipfirst=False, withpb=True):
"""same as ucsvreader but a progress bar is displayed as we iter on rows"""
+ if not osp.exists(filepath):
+ raise Exception("file doesn't exists: %s" % filepath)
rowcount = int(shellutils.Execute('wc -l "%s"' % filepath).out.strip().split()[0])
if skipfirst:
rowcount -= 1
@@ -326,8 +332,7 @@
entity[key] = default
def record_error(self, key, msg=None, type=None, value=None, tb=None):
- import StringIO
- tmp = StringIO.StringIO()
+ tmp = StringIO()
if type is None:
traceback.print_exc(file=tmp)
else: