Skip to content
Snippets Groups Projects
Commit 6d0c659d authored by Vermaat's avatar Vermaat
Browse files

Transparently support different line ending styles in batch checker input...

Transparently support different line ending styles in batch checker input files (Unix, Mac, and Windows styles).

git-svn-id: https://humgenprojects.lumc.nl/svn/mutalyzer/trunk@165 eb6bd6ab-9ccd-42b9-aceb-e2899b4a52f1
parent c79994d0
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,26 @@ class File() :
@rtype: list
"""
# If we naively assume the input file uses \n characters as
# newlines, the CSV parser can trip over e.g. Windows style
# newlines. It will probably complain with a message like:
#
# new-line character seen in unquoted field - do you need to open
# the file in universal-newline mode?
#
# Here we try to support multiplatform newline modes in the input
# file, so \n, \r, \r\n are all recognized as a newline.
#
# This can be done by opening the file in 'U' mode, but in this case
# we already have an opened file (probably, if the call originated
# from a web request, opened by the web.py input handler, which uses
# the Python cgi module for opening uploaded files).
#
# The fix is to get the handle's file descriptor and create a new
# handle for it, using 'U' mode.
handle = os.fdopen(handle.fileno(), 'rU')
# I don't think the .seek(0) is needed now we created a new handle
handle.seek(0)
buf = handle.read(self.__config.bufSize)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment