From aec34378a69f4e38c39c703a6baa6d1f09deed5f Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 17 Jul 2013 12:58:20 +0200 Subject: Minor refactoring --- MAT/parser.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'MAT/parser.py') diff --git a/MAT/parser.py b/MAT/parser.py index 2dda074..e956164 100644 --- a/MAT/parser.py +++ b/MAT/parser.py @@ -7,6 +7,7 @@ import hachoir_editor import os import tempfile +import shutil import mat @@ -38,6 +39,12 @@ class GenericParser(object): _, output = tempfile.mkstemp() self.output = hachoir_core.cmd_line.unicodeFilename(output) + def __del__(self): + ''' Remove tempfile if it was not used + ''' + if os.path.exists(self.output): + mat.secure_remove(self.output) + def is_clean(self): ''' Check if the file is clean from harmful metadatas @@ -116,6 +123,11 @@ class GenericParser(object): ''' raise NotImplementedError + def create_backup_copy(self): + ''' Create a backup copy + ''' + shutil.copy2(self.filename, self.filename + '.bak') + def do_backup(self): ''' Keep a backup of the file if asked. -- cgit v1.3