diff --git a/lib/galaxy/datatypes/sniff.py b/lib/galaxy/datatypes/sniff.py index 5f0d88045e1b..00ce45133067 100644 --- a/lib/galaxy/datatypes/sniff.py +++ b/lib/galaxy/datatypes/sniff.py @@ -598,20 +598,18 @@ def search(self, pattern): def search_str(self, query_str): return query_str in self.contents_header - def unpack_header(self, pattern): + def magic_header(self, pattern): + """ + Unpack header and get first element + """ size = struct.calcsize(pattern) - header_bytes = self.contents_header_bytes[0:size] + header_bytes = self.contents_header_bytes[:size] if len(header_bytes) < size: return None - return struct.unpack(pattern, header_bytes) - - def magic_header(self, pattern): - # unpack header and get first element - unpacked = self.unpack_header(pattern) - return None if not unpacked else unpacked[0] + return struct.unpack(pattern, header_bytes)[0] def startswith_bytes(self, test_bytes): - return self.contents_header_bytes[0:len(test_bytes)] == test_bytes + return self.contents_header_bytes.startswith(test_bytes) def build_sniff_from_prefix(klass):