示例#1
0
 def __init__(self, filename, parser, mime, backup, **kwargs):
     self.filename = ""
     self.parser = parser
     self.mime = mime
     self.backup = backup
     self.editor = hachoir_editor.createEditor(parser)
     try:
         self.filename = hachoir_core.cmd_line.unicodeFilename(filename)
     except TypeError:  # get rid of "decoding Unicode is not supported"
         self.filename = filename
     self.basename = os.path.basename(filename)
     _, output = tempfile.mkstemp()
     self.output = hachoir_core.cmd_line.unicodeFilename(output)
示例#2
0
    def save_as(self, path):
        ''' Writes the media file out with edited values to specified path. '''
        if self.is_modified():
            from hachoir_editor import createEditor
            editor = createEditor(self.parser)
            self._update_fields(editor)
            writer = editor
        else:
            writer = self.parser

        from hachoir_core.stream import FileOutputStream
        stream = FileOutputStream(path)
        writer.writeInto(stream)
示例#3
0
文件: parser.py 项目: rukhairy/MAT
 def __init__(self, filename, parser, mime, backup, is_writable, **kwargs):
     self.filename = ''
     self.parser = parser
     self.mime = mime
     self.backup = backup
     self.is_writable = is_writable
     self.editor = hachoir_editor.createEditor(parser)
     try:
         self.filename = hachoir_core.cmd_line.unicodeFilename(filename)
     except TypeError:  # get rid of "decoding Unicode is not supported"
         self.filename = filename
     self.basename = os.path.basename(filename)
     self.output = hachoir_core.cmd_line.unicodeFilename(
         tempfile.mkstemp()[1])
 def __init__(self, filename, parser, mime, backup, add2archive):
     self.filename = ''
     self.parser = parser
     self.mime = mime
     self.backup = backup
     self.editor = hachoir_editor.createEditor(parser)
     self.realname = filename
     try:
         self.filename = hachoir_core.cmd_line.unicodeFilename(filename)
     except TypeError:  # get rid of "decoding Unicode is not supported"
         self.filename = filename
     basename, ext = os.path.splitext(filename)
     self.output = basename + '.cleaned' + ext
     self.basename = os.path.basename(filename)  # only filename