def openFile(filename, mode=u'rU', continueOnError=False, displayError=True):
try:
if filename != u'-':
return open(os.path.expanduser(filename), mode)
if mode.startswith(u'r'):
return StringIOobject(text_type(sys.stdin.read()))
return sys.stdout
except IOError as e:
if continueOnError:
if displayError:
stderrWarningMsg(e)
setSysExitRC(FILE_ERROR_RC)
return None
systemErrorExit(FILE_ERROR_RC, e)
# Close a file
评论列表
文章目录