diff options
| author | jvoisin | 2011-06-24 19:41:51 +0200 |
|---|---|---|
| committer | jvoisin | 2011-06-24 19:41:51 +0200 |
| commit | 9ebc62273ec8abfc4520660597fa80fe3de40203 (patch) | |
| tree | f1d6f4ed1824a46b9dcc7ab142950cc0eb04692c /lib/parser.py | |
| parent | 15e58d472dd942a675110cff8085124c0088f54f (diff) | |
Preliminary support of .tar archives
Diffstat (limited to 'lib/parser.py')
| -rw-r--r-- | lib/parser.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/parser.py b/lib/parser.py index d629619..12ef15a 100644 --- a/lib/parser.py +++ b/lib/parser.py | |||
| @@ -6,6 +6,7 @@ import hachoir_core.error | |||
| 6 | import hachoir_parser | 6 | import hachoir_parser |
| 7 | import hachoir_editor | 7 | import hachoir_editor |
| 8 | import sys | 8 | import sys |
| 9 | import os | ||
| 9 | import shutil | 10 | import shutil |
| 10 | 11 | ||
| 11 | POSTFIX = ".cleaned" | 12 | POSTFIX = ".cleaned" |
| @@ -25,6 +26,7 @@ class Generic_parser(): | |||
| 25 | #FIXME : not secure at all ! | 26 | #FIXME : not secure at all ! |
| 26 | try: | 27 | try: |
| 27 | shutil.rmtree(self.filename) | 28 | shutil.rmtree(self.filename) |
| 29 | #shutil.subprocess('shutil' , '--remove', 'self.filename') | ||
| 28 | except: | 30 | except: |
| 29 | print('Unable to remove %s' % self.filename) | 31 | print('Unable to remove %s' % self.filename) |
| 30 | 32 | ||
| @@ -47,7 +49,7 @@ class Generic_parser(): | |||
| 47 | hachoir_core.field.writeIntoFile(self.editor, self.filename + POSTFIX) | 49 | hachoir_core.field.writeIntoFile(self.editor, self.filename + POSTFIX) |
| 48 | if self.backup is False: | 50 | if self.backup is False: |
| 49 | self.secure_remove() #remove the old file | 51 | self.secure_remove() #remove the old file |
| 50 | shutil.rename(self.filename+ POSTFIX, self.filename)#rename the new | 52 | os.rename(self.filename+ POSTFIX, self.filename)#rename the new |
| 51 | 53 | ||
| 52 | def remove_all_ugly(self): | 54 | def remove_all_ugly(self): |
| 53 | ''' | 55 | ''' |
| @@ -57,7 +59,7 @@ class Generic_parser(): | |||
| 57 | In a perfect world, with nice fileformat, | 59 | In a perfect world, with nice fileformat, |
| 58 | this method does not exist. | 60 | this method does not exist. |
| 59 | ''' | 61 | ''' |
| 60 | raise NotImplementedError() | 62 | self.remove_all() |
| 61 | 63 | ||
| 62 | 64 | ||
| 63 | def _remove(self, field): | 65 | def _remove(self, field): |
