Format detectors now accept input bytes or path

This commit is contained in:
platomav 2022-04-21 13:59:40 +03:00
parent a2eca0aac6
commit 982e3f3fc9
4 changed files with 27 additions and 9 deletions

View file

@ -17,3 +17,13 @@ def to_string(input_object, sep_char=''):
output_string = str(input_object)
return output_string
# Get Bytes from given buffer or file path
def file_to_bytes(in_object):
object_bytes = in_object
if type(in_object).__name__ not in ('bytes','bytearray'):
with open(to_string(in_object), 'rb') as object_data:
object_bytes = object_data.read()
return object_bytes