version 1.116, 2010/03/23 16:20:40
|
version 1.117, 2011/04/27 16:19:27
|
Line 306 def manage_addCDLIFile(self,id,title,loc
|
Line 306 def manage_addCDLIFile(self,id,title,loc
|
|
|
def checkUTF8(data): |
def checkUTF8(data): |
"""check utf 8""" |
"""check utf 8""" |
|
if not isinstance(data, str): |
|
logging.error("checkUTF8 data is not string! (%s)"%repr(data)) |
|
|
try: |
try: |
data.encode('utf-8') |
data.decode('utf-8') |
|
logging.debug("checkUTF8: ok!") |
return True |
return True |
except: |
except: |
|
logging.debug("checkUTF8: false!") |
return False |
return False |
|
|
|
|
Line 335 def splitatf(fh,dir=None,ext=None):
|
Line 340 def splitatf(fh,dir=None,ext=None):
|
i=0 |
i=0 |
|
|
#ROC: why split \n first and then \r??? |
#ROC: why split \n first and then \r??? |
if (type(fh) is StringType) or (type(fh) is UnicodeType): |
if isinstance(fh, basestring): |
iter=fh.split("\n") |
iter=fh.split("\n") |
else: |
else: |
iter=fh.readlines() |
iter=fh.readlines() |
Line 369 def splitatf(fh,dir=None,ext=None):
|
Line 374 def splitatf(fh,dir=None,ext=None):
|
if dir: |
if dir: |
filename=os.path.join(dir,filename) |
filename=os.path.join(dir,filename) |
nf=file(filename,"w") |
nf=file(filename,"w") |
logging.info("open %s"%filename) |
logging.debug("open %s"%filename) |
if nf: |
if nf: |
nf.write(line.replace("\n","")+"\n") |
nf.write(line.replace("\n","")+"\n") |
|
|
Line 378 def splitatf(fh,dir=None,ext=None):
|
Line 383 def splitatf(fh,dir=None,ext=None):
|
except: |
except: |
pass |
pass |
|
|
if not((type(fh) is StringType) or (type(fh) is UnicodeType)): |
if not isinstance(fh, basestring): |
fh.close() |
fh.close() |
|
|
return ret,len(os.listdir(dir)) |
return ret,len(os.listdir(dir)) |
|
|
|
|