From 29f8e29b0bf5d50c0b735aa707d2a61623cc805b Mon Sep 17 00:00:00 2001 From: John Chilton Date: Fri, 29 Jun 2018 15:52:38 -0700 Subject: [PATCH] Fix empty datatypes. --- lib/galaxy/datatypes/proteomics.py | 6 ++++-- lib/galaxy/datatypes/sniff.py | 3 +++ lib/galaxy/datatypes/test/empty.txt | 0 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 lib/galaxy/datatypes/test/empty.txt diff --git a/lib/galaxy/datatypes/proteomics.py b/lib/galaxy/datatypes/proteomics.py index b3de1f5a97a..4afad30d276 100644 --- a/lib/galaxy/datatypes/proteomics.py +++ b/lib/galaxy/datatypes/proteomics.py @@ -393,8 +393,10 @@ class Ms2(Text): header_lines = [] while True: line = contents.readline() - if line is None or len(line) == 0: - pass + if not line: + return False + if line.strip() == "": + continue elif line.startswith('H\t'): header_lines.append(line) else: diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index e89b24c3380..b0fb78fe812 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -290,6 +290,9 @@ def guess_ext(fname, sniff_order, is_binary=False): >>> from galaxy.datatypes.registry import example_datatype_registry_for_sample >>> datatypes_registry = example_datatype_registry_for_sample() >>> sniff_order = datatypes_registry.sniff_order + >>> fname = get_test_fname('empty.txt') + >>> guess_ext(fname, sniff_order) + 'txt' >>> fname = get_test_fname('megablast_xml_parser_test1.blastxml') >>> guess_ext(fname, sniff_order) 'blastxml' diff --git a/lib/galaxy/datatypes/test/empty.txt b/lib/galaxy/datatypes/test/empty.txt new file mode 100644 index 00000000000..e69de29bb2d