mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-13 06:34:42 -04:00
Format detectors now accept input bytes or path
This commit is contained in:
parent
a2eca0aac6
commit
982e3f3fc9
4 changed files with 27 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue