def ensure_file_exists(filename):
"""Ensure file exists and is not empty, otherwise raise an IOError.
:type filename: string
:param filename: file to check"""
if not os.path.exists(filename):
raise IOError("File %s doesn't exist or not correctly created"
% filename)
if not (os.path.getsize(filename) > 0):
raise IOError("File %s empty" % filename)
(shortname, extension) = os.path.splitext(filename)
if sys.platform == 'win32' and extension=='.seg':
import fileinput
for line in fileinput.FileInput(filename,inplace=0):
line = line.replace("\\\\","/")
评论列表
文章目录