Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nicola Soranzo <[email protected]>
  • Loading branch information
jmchilton and nsoranzo authored Jan 5, 2021
1 parent 8e7e37e commit 06be029
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/galaxy/datatypes/sniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 06be029

Please sign in to comment.