def unpack(filepath, contents=None, password=None, filename=None, duplicates=None): """Unpacks the file or contents provided.""" if contents: f = File(filepath, contents, filename=filename) else: f = File.from_path(filepath, filename=filename) if duplicates is None: duplicates = [] # Determine how we're going to unpack this file (if at all). It may not # have a file extension, e.g., when its filename is a hash. In those cases # we're going to take a look at the contents of the file. f.unpacker = Unpacker.guess(f) # Actually unpack any embedded files in this archive. if f.unpacker: plugin = plugins[f.unpacker](f) if plugin.supported(): f.children = plugin.unpack(password, duplicates) return f
def unpack(filepath, contents=None): """Unpacks the file or contents provided.""" if contents: f = File(filepath, contents) else: f = File.from_path(filepath) # Determine how we're going to unpack this file (if at all). It may not # have a file extension, e.g., when its filename is a hash. In those cases # we're going to take a look at the contents of the file. unpacker = picker(filepath) if not unpacker and f.get_signature(): unpacker = f.get_signature()["unpacker"] # Actually unpack any embedded files in this archive. if unpacker: f.children = plugins[unpacker](f).unpack() return f
def unpack(filepath=None, contents=None, password=None, filename=None, duplicates=None): """Unpacks the file or contents provided.""" if contents: f = File(filepath, contents, filename=filename) else: f = File.from_path(filepath, filename=filename) if duplicates is None: duplicates = [] # Determine how we're going to unpack this file (if at all). It may not # have a file extension, e.g., when its filename is a hash. In those cases # we're going to take a look at the contents of the file. f.unpacker = Unpacker.guess(f) # Actually unpack any embedded files in this archive. if f.unpacker: plugin = plugins[f.unpacker](f) if plugin.supported(): f.children = plugin.unpack(password, duplicates) return f
def unpack(filepath, contents=None, password=None): """Unpacks the file or contents provided.""" if contents: f = File(filepath, contents) else: f = File.from_path(filepath) duplicates = [] # Determine how we're going to unpack this file (if at all). It may not # have a file extension, e.g., when its filename is a hash. In those cases # we're going to take a look at the contents of the file. unpacker = picker(filepath) if not unpacker and f.get_signature(): unpacker = f.get_signature()["unpacker"] # Actually unpack any embedded files in this archive. if unpacker: plugin = plugins[unpacker](f) if plugin.supported(): f.children = plugin.unpack(password, duplicates) return f