details: http://www.bx.psu.edu/hg/galaxy/rev/2f4d3387c589 changeset: 2349:2f4d3387c589 user: Nate Coraor nate@bx.psu.edu date: Fri Apr 17 13:54:00 2009 -0400 description: Previous addition of check_newlines to sniff was lost at some point.
1 file(s) affected in this change:
lib/galaxy/datatypes/sniff.py
diffs (26 lines):
diff -r 8d63860c3b83 -r 2f4d3387c589 lib/galaxy/datatypes/sniff.py --- a/lib/galaxy/datatypes/sniff.py Thu Apr 16 14:01:10 2009 -0400 +++ b/lib/galaxy/datatypes/sniff.py Fri Apr 17 13:54:00 2009 -0400 @@ -51,6 +51,22 @@ os.write( fd, chunk ) os.close( fd ) return temp_name, is_multi_byte + +def check_newlines( fname, bytes_to_read=52428800 ): + """ + Determines if there are any non-POSIX newlines in the first + number_of_bytes (by default, 50MB) of the file. + """ + CHUNK_SIZE = 2 ** 20 + f = open( fname, 'r' ) + for chunk in f.read( CHUNK_SIZE ): + if f.tell() > bytes_to_read: + break + if chunk.count( '\r' ): + f.close() + return True + f.close() + return False
def convert_newlines( fname ): """
galaxy-dev@lists.galaxyproject.org